Create a checkout session
POST
/checkout-sessions
Creates a checkout session (DB only, no order, no external API calls). The order is created separately via POST /orders with checkoutSessionId.
Request Body required
application/jsonsuccess_url
string (uri)
URL to redirect to on successful payment. Supports {SESSION_ID} and {ORDER_ID} template variables.
cancel_url
string (uri)
URL to redirect to on cancellation. Supports {SESSION_ID} and {ORDER_ID} template variables.
metadata
object
Arbitrary key-value metadata returned unchanged on retrieval
client_reference_id
string
Optional merchant-side reference ID
expires_in
number
Session TTL in seconds (min 300, max 86400, default 1800)
Responses
200
Checkout session created successfully
application/jsonsuccess
boolean
REQUIRED
message
string
REQUIRED
data
object
REQUIRED
Response from creating a checkout session. No order_id, checkout_url, or deposit_address — those come after order creation.
id
string (uuid)
REQUIRED
Checkout session UUID
status
string
REQUIRED
Checkout session status
Enum:
open, processing, complete, expiredsuccess_url
string | null
REQUIRED
Success redirect URL (unresolved template)
cancel_url
string | null
REQUIRED
Cancel redirect URL (unresolved template)
metadata
object
REQUIRED
expires_at
string (date-time)
REQUIRED
ISO 8601 expiry timestamp
created_at
string (date-time)
REQUIRED
ISO 8601 creation timestamp
statusCode
number
REQUIRED
400
Bad request
curl -X POST 'https://mainnet.anyspend.com/checkout-sessions' \
-H 'Content-Type: application/json' \
-d '{
"success_url": "https://merchant.com/success?session_id={SESSION_ID}",
"cancel_url": "https://merchant.com/cancel",
"metadata": {
"sku": "widget-1",
"customer_id": "cust-123"
},
"client_reference_id": "string",
"expires_in": 1800
}'
const response = await fetch('https://mainnet.anyspend.com/checkout-sessions', {
method: 'POST',
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"success_url": "https://merchant.com/success?session_id={SESSION_ID}",
"cancel_url": "https://merchant.com/cancel",
"metadata": {
"sku": "widget-1",
"customer_id": "cust-123"
},
"client_reference_id": "string",
"expires_in": 1800
})
});
const data = await response.json();
console.log(data);
import requests
response = requests.post('https://mainnet.anyspend.com/checkout-sessions', json={
"success_url": "https://merchant.com/success?session_id={SESSION_ID}",
"cancel_url": "https://merchant.com/cancel",
"metadata": {
"sku": "widget-1",
"customer_id": "cust-123"
},
"client_reference_id": "string",
"expires_in": 1800
})
print(response.json())
200
Response
{
"success": true,
"message": "Checkout session created",
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "open",
"success_url": "<string>",
"cancel_url": "<string>",
"metadata": "<object>",
"expires_at": "2024-01-01T00:00:00Z",
"created_at": "2024-01-01T00:00:00Z"
},
"statusCode": 200
}
POST
/checkout-sessions