Looking for the React checkout component? See Checkout. This page covers the REST API for server-driven flows.
Base URL
All checkout session endpoints live on the AnySpend service:Flow
1
Create a session on your server
POST https://api.anyspend.com/checkout-sessions returns { id, status: "open" }2
User picks a payment method
POST https://api.anyspend.com/orders with checkoutSessionId returns { id, globalAddress, oneClickBuyUrl }3
User pays
Crypto: send to
globalAddress | Fiat onramp: redirect to oneClickBuyUrl4
Poll for completion
GET https://api.anyspend.com/checkout-sessions/:id returns { status: "complete", order_id }Why decouple sessions from orders?
- The payment method doesn’t need to be known at session creation.
- A hosted checkout page can let users choose how to pay.
- Session creation is a local DB write, so it never fails due to third-party API errors.
Session status lifecycle
API reference
Create session
Create order linked to a session
checkoutSessionId in the standard order body to link the order to a session.
- Session must exist (
400if not found) - Session must be
open(400if expired/processing/complete) - Session must not already have an order (
409 Conflict)
Retrieve session
Expire a session
open.
Redirect URL templates
Use template variables insuccess_url and cancel_url:
If no template variable is present,
?sessionId=<uuid> is appended automatically.
SDK integration
Service methods
React hooks
useCreateCheckoutSession
Mutation hook for creating sessions.
useCheckoutSession
Query hook with auto-polling. Stops polling when status reaches complete or expired.
Component prop
The<AnySpend>, <AnySpendCustom>, and <AnySpendCustomExactIn> components accept an optional checkoutSession prop:
checkoutSession is set, the component creates a session before the order, and uses the session’s success_url for redirects. Without the prop, existing flows work the same as before.
HypeDuel