Putting it all together
Typical end‑to‑end flow:
- Call a third‑party API. If it responds with HTTP 402 / X‑402 metadata, extract amount, host, resource URL, etc.
- Look up the
jwtfor the calling user/agent. - Call
POST /api/payment/x402V1Paymentwith the correct body andAuthorizationheader. - On success, attach the returned
xPaymentB64asX-Paymentand retry the original API call. - For withdrawals or revenue splits, call
POST /api/payoutsand track withGET /api/payouts/{payoutId}until terminal.
