Retrieves the current status and details of a payment session. Use it to poll a session's status instead of, or in addition to, listening for payment session webhooks.
| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
When to Use This Endpoint
Payment session webhooks are the recommended way to learn about status changes. Use this endpoint when you need the current state on demand:
| Scenario | Description |
|---|---|
| Polling instead of webhooks | Your system can't receive webhooks yet. Poll this endpoint until the session reaches approved. |
| Missed or delayed webhook | A webhook didn't arrive or your handler failed. Fetch the current status to reconcile your records. |
| Before retrieving credentials | Confirm the session is approved before calling Get Payment Credentials. |
| Showing status to the customer | Display whether the payment is still pending, approved or expired in your UI. |
Authentication
Every request must include your API key in the request header.
x-api-key: YOUR_API_KEY_HERE- Always call this endpoint from your backend — never expose your API key in client-side code.
Request
No request body is required. Pass the sessionId as a path parameter.
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
sessionId | Path | string (UUID) | ✅ Yes | The sessionId returned when the session was created via POST /payment/session. |
x-api-key | Header | string | ✅ Yes | Your CartAI API key. |
Full Request Example
curl --location 'https://api.cartai.ai/payment/session/01a1fa10-1a2c-7f53-8cdd-7d7d3810db1b/status' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR_API_KEY_HERE'Response
A successful request returns HTTP 200 with the following body.
{
"status": "success",
"code": 200,
"message": "Payment session status retrieved successfully",
"data": {
"url": "https://wallet.cartai.ai?token=<jwt_token>&type=bt&mode=t&w=t&mpr=f",
"sessionId": "01a206f9-228a-7262-aa21-3f6eb5c6ab03",
"corporateId": 3,
"mode": "test",
"created_at": "2026-11-23T05:55:20.343172",
"merchantName": null,
"merchantUrl": null,
"authorization": {
"price": "0.6",
"currency": "USD",
"purpose": "MMM Test",
"expiry": "2026-11-27T18:24:43.940375+00:00"
},
"status": "created",
"locked": true
}
}
Twostatusfields. The top-levelstatus("success") describes the API call.data.statusis the payment session's own status — that's the one to act on.
Response Fields
| Field | Type | Description |
|---|---|---|
status | string | "success" when the request succeeded. |
code | integer | HTTP status code, echoed in the body. |
message | string | Human-readable description of the result. |
data.url | string | The hosted payment URL for the session. |
data.sessionId | string | Unique identifier of the payment session. |
data.corporateId | integer | ID of the CartAI account that owns the session. |
data.mode | string | "production" or "test" — the environment the session was created in. |
data.created_at | string | ISO 8601 timestamp of when the session was created. |
data.merchantName | string | null | Name of the merchant the session is associated with, or null. |
data.merchantUrl | string | null | Website URL of the merchant the session is associated with, or null. |
data.authorization.price | string | The authorized payment amount. |
data.authorization.currency | string | Currency code (always "USD"). |
data.authorization.purpose | string | The purpose string provided when the session was created. |
data.authorization.expiry | string | ISO 8601 timestamp after which the session can no longer be used. |
data.status | string | Current status of the payment session. See Session Statuses. |
data.locked | boolean | Whether the session is locked. |
Session Statuses
data.status uses the same values as the payment session webhooks.
| Status | Description | What to do |
|---|---|---|
created | The session has been created and the hosted url is ready. The customer hasn't completed the payment flow yet. | Show the customer the hosted url, if you haven't already. |
approved | The customer completed the hosted payment flow and authorized the payment. | Call Get Payment Credentials to retrieve the credentials. |
utilised | The session's payment credentials have been used. | Mark the session as used in your records. |
expired | The session passed its authorization.expiry before it was used. | Create a new payment session if the customer still needs to pay. |
purged | The session's data has been permanently removed from CartAI. Terminal state. | Remove any remaining references to the session. |
Guide: Poll for Approval, Then Check Out
The typical flow is to create a payment session, wait for the customer to approve it, and then pass the sessionId to the Checkout API so the agent pays with the customer's approved card.
POST /payment/session → returns sessionId + hosted url
Customer opens url and approves
GET /payment/session/{id}/status → poll until data.status = "approved"
POST /checkout → customer.payment.data.sessionId = sessionId
Step 1 — Create the payment session
Call Create Payment Session, store the returned sessionId against your order, and send the customer to the hosted url.
Step 2 — Poll until the status is approved
approvedCall this endpoint repeatedly until data.status is approved. Stop polling and handle the failure if the session ends up expired or purged, or utilised (its credentials have already been used, so it can't pay for this checkout).
const API = "https://api.cartai.ai";
async function waitForApproval(sessionId, apiKey, { intervalMs = 5000, timeoutMs = 15 * 60 * 1000 } = {}) {
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
const res = await fetch(`${API}/payment/session/${sessionId}/status`, {
headers: { "x-api-key": apiKey }
});
if (!res.ok) throw new Error(`Status check failed: HTTP ${res.status}`);
const { data } = await res.json();
if (data.status === "approved") return data; // ✅ ready for checkout
if (["expired", "purged", "utilised"].includes(data.status)) {
throw new Error(`Payment session is ${data.status}; create a new one`);
}
// Still "created": the customer hasn't finished the payment flow yet
await new Promise((r) => setTimeout(r, intervalMs));
}
throw new Error("Timed out waiting for the customer to approve the payment");
}
Polling tips: Poll every few seconds (for example every 5 seconds) and set an overall timeout that suits your checkout experience. Never poll pastauthorization.expiry— the session can't be approved after that.
Step 3 — Use the sessionId in the Checkout API
sessionId in the Checkout APIOnce the session is approved, create the checkout task with Create Checkout Task (POST /checkout) (or Create Search Checkout Task) and pass the sessionId in customer.payment.data.sessionId.
Do not send aprovider. When paying with a payment session,customer.paymentcontains onlydata.sessionId. Don't includeprovideror any card fields.
"customer": {
"contact": { ... },
"shippingAddress": { ... },
"billingAddress": { ... },
"shippingMethod": { "strategy": "cheapest" },
"payment": {
"data": {
"sessionId": "01a206f9-228a-7262-aa21-3f6eb5c6ab03"
}
}
}Putting it together:
async function checkoutWithPaymentSession(sessionId, order, apiKey) {
// Step 2 — wait for the customer to approve the payment
await waitForApproval(sessionId, apiKey);
// Step 3 — create the checkout task, paying with the approved session
const res = await fetch(`${API}/checkout`, {
method: "POST",
headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
body: JSON.stringify({
customer: {
...order.customer, // contact, addresses, shippingMethod
payment: { data: { sessionId } } // no provider
},
tasks: order.tasks
})
});
return res.json(); // { status, message, groupId, tasks: [...] }
}
Prefer webhooks in production. Instead of polling, you can listen for theapprovedevent from payment session webhooks and create the checkout task when it arrives. Polling is a good fallback if a webhook is missed.
Error Reference
| HTTP Status | Cause | What to do |
|---|---|---|
200 | Status retrieved successfully | Read data.status to decide the next step |
400 | Invalid sessionId | Check that the sessionId is a valid UUID returned by Create Payment Session |
401 | Missing or invalid x-api-key | Verify the header name and that you are using the correct environment key |
404 | sessionId not found | Verify the ID is correct and matches the environment (QA vs production) |
429 | Rate limited | Back off and retry after a delay |
5xx | CartAI server error | Retry with exponential backoff; contact support if it persists |
400Bad Request
404Payment session not found