An HTTP 402-based payment protocol for AI agent commerce. Agents discover prices, sign card tokens, and pay for resources in a single retry — no wallets, no redirects, no human in the loop.
View live schemeReturns the payment scheme specification — supported currency, token format, and facilitator status. Use this to discover whether card payments are configured and what parameters to use.
Validates a payment token without charging the card. Checks the JWT signature, nonce uniqueness, amount limits, card status, and available balance. Returns { isValid: true } or a reason for rejection.
Settles a payment — debits the card balance, records the transaction, and marks the nonce as used. Auto-closes the card when balance reaches zero. Returns a transaction ID on success.
Card tokens are signed JWTs issued to agents. Each token is scoped to a specific card and capped at a maximum spend amount.
{
"cardId": "card_8xK2m...", // Virtual card ID
"userId": "user_3jF9...", // Card owner
"maxAmountCents": 5000, // Max $50.00 per tx
"iat": 1709337600, // Issued at
"exp": 1709341200 // Expires in 1 hour
}The full payment payload wraps the card token with the transaction details. This is base64-encoded and sent in the X-PAYMENT header.
{
"x402Version": 1,
"scheme": "card",
"payload": {
"cardToken": "eyJhbGciOiJIUzI1NiI...",
"amountCents": 250, // $2.50
"currency": "USD",
"nonce": "a1b2c3d4...", // Unique per request
"validBefore": 1709338200, // 10-min window
"resourceUrl": "https://api.example.com/data"
}
}HTTP/1.1 402 Payment Required
x-payment-required: {
"scheme": "card",
"currency": "USD",
"amountCents": 250,
"facilitator": "https://x402.agentcard.sh/x402",
"description": "API access — 1 request"
}GET /protected-resource HTTP/1.1
X-PAYMENT: eyJ4NDAyVmVyc2lvbiI6MSwic2NoZW1lIjoiY2FyZCIs...
↑ base64-encoded payment payload