Putting it all together
Pay for an x402 resource with a mandate (no per-payment approval):
- Register once; store
agent_id,token,jwt. Refresh thejwtwith/refreshwhen it expires. - Create a mandate and have the user open
authorizationUrlto link the agent and sign. Poll Get mandate by ID untilstatusissigned. - Call the third-party API. On HTTP 402, take the fields from
accepts[0]. - Call
GET /api/mandates/eligiblewithhost,amount,currencyto pick amandateId. - Call
POST /api/payment/x402V3Payment(orPOST /api/v2/payment/x402-paymentfor x402 v2 requirements). - Send the returned
xPaymentB64asX-Paymentand retry the original request.
Without a mandate, use POST /api/payment/x402V1Payment; if it returns need_approval, show approvalUrl and retry with approvalId.
Send funds out:
POST /api/payouts(withmandateIdfor automatic approval), then pollGET /api/payouts/{payoutId}untildisplayStatusiscompleted,failed,rejected, orexpired.
Receive funds:
- Create a link via
POST /api/payment-links(maxUses: 1per order,externalId= your order ID). - Share
url(agents, x402) orcheckoutUrl(people). - Poll
GET /api/payment-links/{linkId}/paymentsand fulfil only whensettlementStatusissettled. There are no webhooks. - Refund with
POST /api/payment-links/refunds/initiateand pay the returnedrefundUrl.
