Checkout
The Checkout API enables AI agents to create, update, and complete checkout sessions on behalf of buyers. This merchant-implemented REST interface provides a stateful checkout flow with comprehensive cart management, fulfillment options, and payment processing.
Overview
The Checkout API is designed for ChatGPT-driven checkout processes and provides:
- Session management: Create and maintain checkout state across multiple interactions
- Cart operations: Add, remove, or update items with automatic price and tax calculations
- Fulfillment handling: Present shipping options with estimated delivery times
- Payment processing: Secure payment completion with Stripe integration
- State synchronization: Each API call returns the latest authoritative checkout state
All API endpoints use HTTPS and return JSON. The merchant maintains full control over inventory, pricing, tax calculations, and payment processing.
Authentication
All API requests must be authenticated using a bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY
The bearer token should be issued by the merchant and validated on each request to ensure authorized access to checkout operations.
Headers
Required headers
All API requests must include these headers:
| Header | Description |
|---|---|
Authorization | Bearer token for API authentication (e.g., Bearer sk_live_123) |
Content-Type | Must be application/json for requests with a body |
API-Version | API version date in format YYYY-MM-DD (e.g., 2025-12-11) |
Optional headers
These headers provide additional functionality:
| Header | Description |
|---|---|
Idempotency-Key | Unique key to safely retry requests without duplicate processing |
Request-Id | Unique identifier for request tracking and debugging |
Accept-Language | Preferred language for response messages (e.g., en-US) |
User-Agent | Client application identifier |
Signature | HMAC signature for webhook verification |
Timestamp | Unix timestamp for request timing validation |
Response headers
The API returns these headers with responses:
| Header | Description |
|---|---|
Idempotency-Key | Echo of the request's idempotency key if provided |
Request-Id | Unique identifier for the request |
Endpoints
Create checkout session
Creates a new checkout session with items and optional buyer information.
This endpoint initializes a new checkout session from a list of items. The response includes the complete checkout state with line items, pricing calculations, available fulfillment options, and any validation messages.
buyerBuyerBuyer information including first name, last name, email, and optional phone number.
itemsItem[]Array of items to add to the checkout. Must include at least 1 item. Each item contains an id and quantity.
fulfillment_addressAddressShipping address for the order. Required for physical goods.
POST /checkout_sessions
{
"buyer": {
"first_name": "Ada",
"last_name": "Lovelace",
"email": "ada@example.com"
},
"items": [
{ "id": "prod_123", "quantity": 2 }
],
"fulfillment_address": {
"name": "Ada Lovelace",
"line_one": "123 Market St",
"city": "San Francisco",
"state": "CA",
"country": "US",
"postal_code": "94103"
}
}
Status Codes:
201 Created- Checkout session successfully created400 Bad Request- Invalid request parameters or malformed data401 Unauthorized- Missing or invalid authentication credentials422 Unprocessable Entity- Valid request but business logic prevents processing (e.g., out of stock)
Retrieve checkout session
Retrieves the current state of an existing checkout session.
This endpoint returns the latest authoritative state for a specific checkout session. Use this to verify current pricing, fulfillment options, or session status.
checkout_session_idstringThe unique identifier for the checkout session.
GET /checkout_sessions/cs_123
Status Codes:
200 OK- Checkout session successfully retrieved401 Unauthorized- Missing or invalid authentication credentials404 Not Found- Checkout session does not exist
Update checkout session
Updates an existing checkout session with new items, fulfillment address, or fulfillment option selection.
This endpoint applies changes to the checkout session and returns the updated state. You can update items, select a fulfillment option, modify the shipping address, or update buyer information. All parameters are optional; only include the fields you want to change.
checkout_session_idstringThe unique identifier for the checkout session.
buyerBuyerUpdated buyer information.
itemsItem[]Updated array of items. This replaces the entire items list.
fulfillment_addressAddressUpdated shipping address.
fulfillment_option_idstringID of the selected fulfillment option from the available options.
POST /checkout_sessions/cs_123
{
"items": [
{ "id": "prod_123", "quantity": 3 }
],
"fulfillment_option_id": "ship_std"
}
Status Codes:
200 OK- Checkout session successfully updated400 Bad Request- Invalid request parameters401 Unauthorized- Missing or invalid authentication credentials404 Not Found- Checkout session does not exist422 Unprocessable Entity- Valid request but business logic prevents update
Complete checkout session
Finalizes the checkout by processing payment and creating an order.
This endpoint completes the checkout session by processing the payment method provided. The merchant must create an order and return it in the response. For Stripe integration, use the Shared Payment Token (SPT) to create and confirm a PaymentIntent.
checkout_session_idstringThe unique identifier for the checkout session.
buyerBuyerUpdated buyer information if needed.
payment_dataPaymentDataPayment method information including token, provider, and optional billing address.
POST /checkout_sessions/cs_123/complete
{
"payment_data": {
"token": "spt_1234567890abcdef",
"provider": "stripe"
}
}
Status Codes:
200 OK- Checkout successfully completed and order created400 Bad Request- Invalid request parameters401 Unauthorized- Missing or invalid authentication credentials402 Payment Required- Payment processing failed404 Not Found- Checkout session does not exist409 Conflict- Checkout session already completed or canceled422 Unprocessable Entity- Valid request but payment cannot be processed (see messages array for details)
Cancel checkout session
Cancels an active checkout session.
This endpoint cancels a checkout session that has not been completed. Use this to release inventory and clean up resources when a buyer exits the checkout process. Sessions that are already completed or canceled cannot be canceled.
checkout_session_idstringThe unique identifier for the checkout session to cancel.
POST /checkout_sessions/cs_123/cancel
Status Codes:
200 OK- Checkout session successfully canceled401 Unauthorized- Missing or invalid authentication credentials404 Not Found- Checkout session does not exist405 Method Not Allowed- Checkout session is already completed or canceled
Schema objects
Below are the canonical JSON Schemas for Checkout objects, rendered object-by-object from the schema bundle.
Address
namestringFull name of the recipient.
line_onestringPrimary street address line.
line_twostringApartment, suite, or unit.
citystringCity or locality.
statestringState, province, or region.
countrystringCountry or region.
postal_codestringZIP or postal code.
{
"name": "Ada Lovelace",
"line_one": "123 Market St",
"line_two": "Apt 4B",
"city": "San Francisco",
"state": "CA",
"country": "US",
"postal_code": "94103"
}
Buyer
first_namestringlast_namestringemailstringphone_numberstring{
"first_name": "Ada",
"last_name": "Lovelace",
"email": "ada@example.com",
"phone_number": "+1-555-555-5555"
}
Item
idstringquantityinteger{
"id": "prod_123",
"quantity": 2
}
PaymentProvider
providerstringsupported_payment_methodsstring[]{
"provider": "stripe",
"supported_payment_methods": ["card"]
}
LineItem
idstringitemItembase_amountintegerdiscountintegersubtotalintegertaxintegertotalinteger{
"id": "li_123",
"item": { "id": "prod_123", "quantity": 1 },
"base_amount": 2000,
"discount": 0,
"subtotal": 2000,
"tax": 160,
"total": 2160
}
Total
typestringdisplay_textstringamountinteger{
"type": "subtotal",
"display_text": "Subtotal",
"amount": 2000
}
FulfillmentOptionShipping
typestringidstringtitlestringsubtitlestringcarrierstringearliest_delivery_timestringlatest_delivery_timestringsubtotalintegertaxintegertotalinteger{
"type": "shipping",
"id": "ship_std",
"title": "Standard Shipping",
"subtitle": "3-5 business days",
"carrier": "UPS",
"earliest_delivery_time": "2025-10-26T00:00:00Z",
"latest_delivery_time": "2025-10-28T00:00:00Z",
"subtotal": 500,
"tax": 40,
"total": 540
}
FulfillmentOptionDigital
typestringidstringtitlestringsubtitlestringsubtotalintegertaxintegertotalinteger{
"type": "digital",
"id": "digital_instant",
"title": "Instant Delivery",
"subtitle": "Delivered via email",
"subtotal": 0,
"tax": 0,
"total": 0
}
MessageInfo
typestringparamstringcontent_typestringcontentstring{
"type": "info",
"param": "$.buyer.email",
"content_type": "plain",
"content": "We use your email for receipts only."
}
MessageError
typestringcodestringparamstringcontent_typestringcontentstring{
"type": "error",
"code": "invalid",
"param": "$.items[0].quantity",
"content_type": "plain",
"content": "Quantity must be at least 1."
}
Link
typestringurlstring{
"type": "terms_of_use",
"url": "https://example.com/terms"
}
PaymentData
tokenstringproviderstringbilling_addressAddress{
"token": "tok_visa_123",
"provider": "stripe",
"billing_address": {
"name": "Ada Lovelace",
"line_one": "123 Market St",
"city": "San Francisco",
"state": "CA",
"country": "US",
"postal_code": "94103"
}
}
Order
idstringcheckout_session_idstringpermalink_urlstring{
"id": "order_123",
"checkout_session_id": "cs_123",
"permalink_url": "https://example.com/orders/order_123"
}
Refund
typestringamountinteger{
"type": "original_payment",
"amount": 500
}
CheckoutSessionBase
idstringbuyerBuyerpayment_providerPaymentProviderstatusstringcurrencystringline_itemsLineItem[]fulfillment_addressAddressfulfillment_options(FulfillmentOptionShipping|FulfillmentOptionDigital)[]fulfillment_option_idstringtotalsTotal[]messages(MessageInfo|MessageError)[]linksLink[]{
"id": "cs_123",
"buyer": {
"first_name": "Ada",
"last_name": "Lovelace",
"email": "ada@example.com"
},
"payment_provider": {
"provider": "stripe",
"supported_payment_methods": ["card"]
},
"status": "ready_for_payment",
"currency": "usd",
"line_items": [
{
"id": "li_123",
"item": { "id": "prod_123", "quantity": 1 },
"base_amount": 2000,
"discount": 0,
"subtotal": 2000,
"tax": 160,
"total": 2160
}
],
"fulfillment_address": {
"name": "Ada Lovelace",
"line_one": "123 Market St",
"city": "San Francisco",
"state": "CA",
"country": "US",
"postal_code": "94103"
},
"fulfillment_options": [
{
"type": "shipping",
"id": "ship_std",
"title": "Standard Shipping",
"subtotal": 500,
"tax": 40,
"total": 540
},
{
"type": "digital",
"id": "digital_instant",
"title": "Instant Delivery",
"subtotal": 0,
"tax": 0,
"total": 0
}
],
"fulfillment_option_id": "ship_std",
"totals": [
{ "type": "subtotal", "display_text": "Subtotal", "amount": 2000 },
{ "type": "tax", "display_text": "Tax", "amount": 160 },
{ "type": "fulfillment", "display_text": "Shipping", "amount": 540 },
{ "type": "total", "display_text": "Total", "amount": 2700 }
],
"messages": [],
"links": [
{ "type": "terms_of_use", "url": "https://example.com/terms" },
{ "type": "privacy_policy", "url": "https://example.com/privacy" }
]
}
CheckoutSession
CheckoutSessionCheckoutSessionBase{
"id": "cs_123",
"status": "ready_for_payment",
"currency": "usd",
"line_items": [],
"totals": [],
"fulfillment_options": [],
"messages": [],
"links": []
}
CheckoutSessionWithOrder
idstringstatusstringcurrencystringline_itemsLineItem[]totalsTotal[]fulfillment_options(FulfillmentOptionShipping|FulfillmentOptionDigital)[]messages(MessageInfo|MessageError)[]linksLink[]orderOrder{
"id": "cs_123",
"status": "completed",
"currency": "usd",
"line_items": [],
"totals": [],
"fulfillment_options": [],
"messages": [],
"links": [],
"order": {
"id": "order_123",
"checkout_session_id": "cs_123",
"permalink_url": "https://example.com/orders/order_123"
}
}
CheckoutSessionCreateRequest
buyerBuyeritemsItem[]fulfillment_addressAddress{
"buyer": {
"first_name": "Ada",
"last_name": "Lovelace",
"email": "ada@example.com"
},
"items": [
{ "id": "prod_123", "quantity": 1 }
],
"fulfillment_address": {
"name": "Ada Lovelace",
"line_one": "123 Market St",
"city": "San Francisco",
"state": "CA",
"country": "US",
"postal_code": "94103"
}
}
CheckoutSessionUpdateRequest
buyerBuyeritemsItem[]fulfillment_addressAddressfulfillment_option_idstring{
"items": [
{ "id": "prod_123", "quantity": 3 }
],
"fulfillment_option_id": "ship_std"
}
CheckoutSessionCompleteRequest
buyerBuyerpayment_dataPaymentData{
"payment_data": {
"token": "tok_visa_123",
"provider": "stripe"
}
}
Error
typestringcodestringmessagestringparamstring{
"type": "invalid_request",
"code": "invalid_email",
"message": "Email address is invalid",
"param": "$.buyer.email"
}