Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mag3nt.com/llms.txt

Use this file to discover all available pages before exploring further.

Installation

npm install @mag3nt/sdk

Setup

import { Mag3nt } from "@mag3nt/sdk";

const mag3nt = new Mag3nt({
  serverURL: "https://mag3nt.com",
  security: {
    bearerAuth: process.env.MAG3NT_API_KEY,
  },
});

Usage

// Issue a card
const card = await mag3nt.cards.cardsCreate({
  purpose: "Research Agent",
  limitAmount: 50,
});

// Pay for an API
const payment = await mag3nt.x402.x402Pay({
  cardId: card.card.id,
  cardToken: card.card.token,
  amount: 0.50,
  merchant: "weather-api.com",
});

// Check balance
const balance = await mag3nt.funding.fundingGetBalance();

Error handling

import * as errors from "@mag3nt/sdk/models/errors";

try {
  await mag3nt.cards.cardsCreate({ purpose: "Agent", limitAmount: 100 });
} catch (error) {
  if (error instanceof errors.BalanceError) {
    console.log(`Need ${error.data$.requested}, have ${error.data$.available}`);
  }
}

Available methods

ModuleDescription
mag3nt.authWallet authentication and sessions
mag3nt.cardsCard issuance, controls, and transactions
mag3nt.keysAPI key management
mag3nt.fundingBalance and withdrawals
mag3nt.x402x402 protocol payments
mag3nt.ap2Agent-to-agent payments
mag3nt.mppMicropayment streaming
mag3nt.payLinksShareable payment links
mag3nt.settlementSettlement status
mag3nt.statusPlatform health
See the API Reference for full method documentation.