Skip to main content

1. Get an API key

Sign in at mag3nt.com with your wallet, then generate an API key from the dashboard.
# Your key looks like this:
mag3nt_live_a1b2c3d4e5f6g7h8i9j0...

2. Install the SDK

npm install @mag3nt/sdk

3. Initialize the client

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

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

4. Fund your treasury

Send USDC or pathUSD to your treasury address (e.g. Base, Solana, or Tempo). Check your balance:
const config = await mag3nt.status.statusGetConfig();
console.log("Treasury address:", config.treasury?.evm);
// Send USDC/pathUSD to this address

const balance = await mag3nt.funding.fundingGetBalance();
console.log("Available:", balance.balances);

5. Issue a card

const card = await mag3nt.cards.cardsCreate({
  purpose: "Research Agent",
  limitAmount: 50,
  network: "eip155:8453",
  asset: "USDC",
});

console.log("Card ID:", card.card?.id);
console.log("Card Token:", card.card?.token);
console.log("Status:", card.card?.status);

6. Make a payment

Use your card to make a payment. mag3nt. automatically detects the protocol (x402, MPP, or AP2) and settles on-chain:
const payment = await mag3nt.payments.paymentsExecute({
  cardId: card.card.id,
  cardToken: card.card.token,
  url: "https://api.weather.com/forecast",
});

console.log("Payment successful:", payment.transactionId);

Next steps

Card controls

MCC locks, single-use cards, spending limits

W3C HTTP Headers

How 402 payment challenges work

Funding

Deposits, balance, multi-network support

API Reference

All 42 endpoints with interactive examples