CartAI's Checkout APIs power the full lifecycle of an AI-driven purchase — from placing an order across any supported merchant to monitoring its progress in real time and cancelling it if needed. The AI agent handles the entire checkout flow autonomously: adding items to cart, selecting shipping, filling addresses, and processing payment.
The Four Checkout Endpoints
| Endpoint | Method | What it does |
|---|---|---|
POST /checkout | POST | Create an asynchronous AI-powered checkout task |
GET /checkout/{taskId} | GET | Fetch the current state, derived details, and history of a checkout task |
POST /checkout/cancel | POST | Request cancellation of an in-progress checkout task |
GET /status-history/{taskId} | GET | Retrieve the full step-by-step audit trail for a checkout task |
How They Work Together
Checkout is asynchronous. You create a task, get a taskId back immediately, and then track the task as the AI agent executes in the background. The other three endpoints give you visibility and control over that running task.
POST /checkout
│ returns taskId (201)
│
├──▶ Webhooks (recommended)
│ push status events as the agent progresses
│
├──▶ GET /checkout/{taskId}
│ poll for current state, derivedDetails, and pricing
│
├──▶ POST /checkout/cancel
│ abort the task if the customer changes their mind
│
└──▶ GET /status-history/{taskId}
full step-by-step audit trail after execution
Step 1 — Create: POST /checkout
POST /checkoutThe entry point. Pass in the customer details, product URLs, and payment information — CartAI queues the task and returns a taskId within milliseconds. The actual checkout runs in the background.
Key inputs:
customer— contact info, shipping address, billing address, shipping strategy ("cheapest"or"fastest"), and payment providertasks[]— one or more product URLs with quantities and variant selections; CartAI automatically groups them by merchantoptions— setallowPartialCheckoutForMultiSku: trueto allow partial fulfillment when some items in a multi-SKU order fail
Key output to carry forward:
taskId— the UUID you will use in every subsequent call; store it immediately
{
"customer": {
"contact": { "firstName": "Carol", "lastName": "Sturka", "email": "[email protected]", "phone": "5555555555" },
"shippingAddress": { "addressLine1": "123 Main St", "city": "New York", "province": "NY", "postalCode": "10001", "country": "US" },
"shippingMethod": { "strategy": "cheapest" },
"payment": { "provider": "test", "data": { "cardNumber": "4242424242424242", "expiryMonth": "12", "expiryYear": "2034", "cvv": "444" } }
},
"tasks": [
{ "url": "https://www.natori.com/products/feathers-plunge-t-shirt-bra-black", "quantity": 1, "selectedVariant": { "color": "Black", "size": "32C" } }
]
}A
201response confirms the task was accepted — not that checkout succeeded. Never resubmit the same payload on a201; it creates a duplicate order.
Step 2 — Track: GET /checkout/{taskId}
GET /checkout/{taskId}Use this to check what the task is doing right now. It returns the current status, the customer data echoed back, and derivedDetails — the live pricing and shipping data the AI agent discovers as it moves through checkout.
Key outputs:
status— current lifecycle state (e.g.IN_PROGRESS,COMPLETED,FAILED)derivedDetails.pricing— actual subtotal, shipping, and tax as seen by the agent at the merchant's checkout — the source of truth for what the customer will be chargedderivedDetails.selectedShippingOption— the exact shipping option the agent pickediterations[]— all execution attempts if the task was retried; useexecutionIdfrom the latest iteration when calling cancel
| Approach | When to use |
|---|---|
| Webhooks | Production — lower latency, no polling overhead, push on every state change |
| Polling | Fallback when webhooks are unavailable; poll every 5–10 seconds, not faster |
| On demand | Fetch once to display an order summary or to retrieve executionId for cancel |
derivedDetailsis the most valuable part of this response for customer-facing UIs. It contains the real total the customer will be charged — which may differ from the listed price due to merchant-applied tax and shipping.
Step 3 — Cancel: POST /checkout/cancel
POST /checkout/cancelSends a cancellation signal to the AI agent. This is asynchronous — a 200 OK means the request was accepted, not that the task has already stopped. The agent winds down in the background; confirmation arrives via the CANCELLED webhook event.
Required inputs:
taskId— from Step 1executionId— from the latestGET /checkout/{taskId}response or from the most recent webhook payload; identifies the specific execution attempt to stop
{
"taskId": "019bd5c5-2824-76d1-aa7a-01db5c4d7065",
"executionId": "019bd5d7-aba0-7080-95e0-8b183f4eca0b"
}Key behaviours:
- Cancellation is irreversible — a cancelled task cannot be resumed. To retry the same order, create a new task via
POST /checkout. - You cannot cancel a task already in a terminal state (
COMPLETED,FAILED, orCANCELLED) — those will return a400. - For multi-merchant orders, each merchant task has its own
taskIdandexecutionId. Cancel each one individually — there is no group-level cancel. - If the agent had already reached the payment step before cancellation was processed, any charge must be refunded through your payment provider.
Step 4 — Audit: GET /status-history/{taskId}
GET /status-history/{taskId}Returns a flat, reverse-chronological list of every step the AI agent recorded — including granular step labels, timestamps, credit consumption per step, and failure flags. This is your primary debugging and reconciliation tool.
Key output fields per step:
status— fine-grained agent action (e.g.ADD_TO_CART,SHIPPING_SELECTED,CREDIT_CARD_INPUT,ORDER_CONFIRMED)systemStatus— coarse lifecycle phase matching what webhooks emit (e.g.IN_PROGRESS,COMPLETED,FAILED)creditsConsumed— credits used at this step; sum across all steps to calculate total task costisFailed— whether this specific step was a failure point, even if the overall task eventually recoverednote— optional system note whenisFailed: true, giving context on what went wrong
| Use this endpoint for | Do not use this endpoint for |
|---|---|
| Debugging a failed task | Checking current task state — use GET /checkout/{taskId} instead |
| Credit reconciliation | Real-time polling — this is an audit log, not a live feed |
| Support escalation | |
| Internal analytics and reporting |
End-to-End Example
A user purchases a bra from Natori. Here is how the four endpoints serve that journey:
| Step | Endpoint | What you send | What you get back |
|---|---|---|---|
| 1 | POST /checkout | Customer, product URL, payment | taskId — checkout queued, agent starts |
| 2 | GET /checkout/{taskId} | taskId in path | status: IN_PROGRESS, derivedDetails populating |
| 2b | Webhook event | — | COMPLETED push with final derivedDetails.pricing |
| 3 | POST /checkout/cancel (if needed) | taskId + executionId | 200 accepted — await CANCELLED webhook |
| 4 | GET /status-history/{taskId} | taskId in path | All steps from QUEUED → ADD_TO_CART → ORDER_CONFIRMED |
Checkout Task Lifecycle
The AI agent progresses through these system-level states from creation to completion:
QUEUED → STARTED → IN_PROGRESS → COMPLETED
↘ FAILED
↘ CANCELLED