LinkexLinkex Docs
For Agents

x402 protocol reference

Endpoints, challenge schema, signing methods, spend caps, and error codes.

Linkex implements x402 version 2 with the exact scheme for account top-ups. This page is the complete integration reference. For the guided version see x402 autonomous top-up.

Sequence

Endpoints

Method & pathAuthPurpose
GET /api/user/topup/x402/configAPI key or sessionDiscover enabled networks, tokens, bounds, recipients
GET /api/user/topup/x402/ordersAPI key or sessionList pending orders with fresh challenges
POST /api/user/topup/x402/ordersAPI key or sessionCreate an order (rate-limited)
POST /api/user/topup/x402/orders/{id}/resumeAPI key or sessionRe-issue the challenge for a pending order
POST /api/x402/pay/{orderId}none — signature is the authSubmit the signed payment (rate-limited, 1 MiB max body)

Interactive schemas: API reference → x402.

Order creation

POST /api/user/topup/x402/orders
{ "amount_usd": 5, "network": "eip155:8453", "symbol": "USDC" }
  • amount_usd — within [min_topup_usd, max_topup_usd] from config (defaults $1–$1,000).
  • network / symbol — optional; omitted → platform default network and its default token (BNB Chain defaults to $U, everything else USDC).
  • Agent binding: with an agent key, the order is force-bound to that agent's wallet; agent_wallet_id in the body is ignored.
  • At most 3 pending orders per account (X402_PENDING_CAP).
  • Orders expire 600 seconds after creation.

The challenge

{
  "x402Version": 2,
  "accepts": [{
    "scheme": "exact",
    "network": "eip155:8453",
    "amount": "5000000",
    "maxAmountRequired": "5000000",
    "resource": "https://linkex.ai/api/x402/pay/12345",
    "payTo": "0xRECIPIENT",
    "maxTimeoutSeconds": 300,
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "extra": { "name": "USD Coin", "version": "2" }
  }]
}

extra depends on the settlement method:

MethodNetworksextra
EIP-3009Base USDC, BNB $U{ "name", "version" } — the token's EIP-712 domain (BNB additionally "assetTransferMethod": "eip3009")
Permit2BNB USDT / USDC{ "assetTransferMethod": "permit2-exact", "spenderAddress" }
SVMSolana USDC{ "feePayer", "memo" } — sponsored fee payer and the invoice memo to include

Always verify payTo (and on Solana the derived token account) against GET /api/user/topup/x402/config before signing. Linkex clients refuse mismatched recipients; yours should too.

Submitting payment

POST /api/x402/pay/{orderId} with the signed payload. The gateway validates that scheme, network, asset, payTo, and the exact amount match the order, then settles.

Responses are always HTTP 200 with an envelope:

{ "success": true, "data": { "order_id": 12345, "status": "settled", "balance_added": 5, "new_balance": 12.34 } }

status values: settled (credited) or credit_pending (on-chain confirmation still in flight; a background reconciler — every 2 minutes, with on-chain verification — completes the credit).

Spend caps (agent orders)

For agent-bound orders the caps are charged atomically at the pending→settling transition:

  • per_call_cap_usd — per-order
  • daily_cap_usd — resets by calendar day
  • total_cap_usd — lifetime

Exceeding any returns SPEND_CAP_EXCEEDED; failed or reset orders reverse the charge.

Error codes

Returned as success: false with an uppercase message:

CodeMeaning
X402_DISABLEDRail disabled on this deployment
X402_INVALID_AMOUNTOutside min/max bounds
X402_UNSUPPORTED_ASSETUnknown network/token combination
X402_PENDING_CAPAlready 3 pending orders
ORDER_NOT_FOUND / INVALID_ORDER_IDBad order reference
ORDER_EXPIREDPast the 600 s window — create a new order
PAYLOAD_MISMATCHSigned payload doesn't match the order
SETTLING_IN_PROGRESSDuplicate submit while settling
ORDER_NOT_PENDING / ORDER_ALREADY_SETTLEDWrong state
SPEND_CAP_EXCEEDEDAgent cap would be breached
X402_SETTLE_PENDINGFacilitator confirmation pending — credit follows automatically
X402_SOLANA_FEEPAYER_UNAVAILABLESponsored fee payer temporarily unavailable

Compatible signers

  • Binance Agentic Walletbaw x402-payment preview / sign
  • @linkexai/agent-sdkbuildX402PaymentPayload (EVM), buildSvmPaymentPayload (Solana)
  • Coinbase x402 tooling and any conformant x402 v2 client

On this page