Creating a session
Create a payment session by specifying the amount, asset, and target:url field — a hosted payment page where the buyer can complete the payment.
Target types
The target determines where captured funds settle.
Account target (most common for PSPs):
x402Url in the response — a CDP-hosted URL that you can give to an x402-enabled agent. The agent makes a POST request to this URL, and CDP returns the x402 payment requirements in the PAYMENT-REQUIRED header, including the supported USDC payment options. After the agent completes the x402 payment flow, the session follows the normal lifecycle — you can capture, void, or refund it using the same APIs as other wallet-authorized sessions. See Pay with x402 for the full flow.
Expiries
Every session has three deadlines controlling when each action can be performed. If omitted, sensible defaults are applied:
Expiries must satisfy:
authorizationExpiresAt <= captureExpiresAt <= refundExpiresAt.
Expiry deadlines are guards, not automatic state transitions. When a deadline passes, the corresponding action is blocked, but the session stays in its current status. You must explicitly cancel (pre-auth) or void (post-auth) to move the session to a terminal state.
Balances
Thebalances object tracks running totals as funds move through the session:
Example: partial capture flow
- Authorization succeeds for $100 —
capturable: 100, captured: 0 - Capture $60 —
capturable: 40, captured: 60, refundable: 60 - Capture $30 —
capturable: 10, captured: 90, refundable: 90 - Void remaining —
capturable: 0, captured: 90, refundable: 90 - Refund $20 —
capturable: 0, captured: 90, refundable: 70, refunded: 20
Auto-capture
SetautoCapture: true to automatically capture the full authorized amount after a successful authorization:
authorization_succeeded. This is useful when you don’t need to delay capture for fulfillment.
When autoCapture is false (default), you must create captures manually via the captures endpoint.
Final capture
When capturing partially, setfinalCapture: true on the last capture to release remaining funds to the buyer:
finalCapture: true settles, any remaining capturable balance is released back to the buyer. If finalCapture is false, the remaining hold stays open for subsequent partial captures (subject to captureExpiresAt).
Has no effect when capturing the full capturable balance, since no remaining balance exists.
Customer display
UsecustomerDisplay to show merchant branding and local-currency amounts to the buyer during checkout:
customerDisplay is purely presentational. The authoritative settlement amount is always the session’s amount and asset.
Redirect URLs
For web-based payment flows, configure redirect URLs to send the buyer back to your site after payment:External reference ID
Attach your own identifier (order ID, invoice number) to the session for reconciliation:Metadata
Attach up to 10 key-value pairs to a session, capture, void, refund, or authorization:Reserved keys for settlement reporting
A few metadata keys are reserved — settlement reports read them out of the genericmetadata object and surface them as dedicated report columns. Pass these exact key names if you want the corresponding column populated. They don’t require any request field beyond the standard metadata object shown above.
merchantId and merchantReference are set per capture or refund, not once at session creation — unlike externalReferenceId, which applies to the whole session.
Authorization outcomes
Every authorization is asynchronous. It starts aspending and resolves to one of two outcomes. Only one authorization is allowed per session.
Common failure reasons:
Idempotency
Authorization, capture, void, and refund endpoints accept anX-Idempotency-Key header. Send a UUID v4 so you can retry safely:
429 or a 5xx status. Those responses aren’t stored, so a retry with the same key is processed as a new request. If a request gets a 429 or 5xx, retry it with the same key and exponential backoff. After 24 hours, the key expires and a retry with it is processed as a new request, which can create a duplicate. Check the resource’s status before retrying an older request.
Cancellation
Cancel a session before any funds are authorized:created status and no authorization is pending. Once canceled, no further actions can be performed. This is the only way to terminate a pre-authorization session — expiry deadlines block actions but don’t automatically move the session to a terminal state.
Related
Pay with Coinbase
Let Coinbase customers pay with their USDC balance
Pay with a Wallet
Let customers pay from a self-custody wallet
Pay with x402
Let AI agents pay with the x402 protocol
Hosted Checkout
Redirect flow and the embeddable web component
Disbursements
Send funds independent of a payment session
Webhooks
Get notified on every status change
API Reference
Full API specification