Get Payment Session Status

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.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

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:

ScenarioDescription
Polling instead of webhooksYour system can't receive webhooks yet. Poll this endpoint until the session reaches approved.
Missed or delayed webhookA webhook didn't arrive or your handler failed. Fetch the current status to reconcile your records.
Before retrieving credentialsConfirm the session is approved before calling Get Payment Credentials.
Showing status to the customerDisplay 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.

ParameterLocationTypeRequiredDescription
sessionIdPathstring (UUID)✅ YesThe sessionId returned when the session was created via POST /payment/session.
x-api-keyHeaderstring✅ YesYour 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
  }
}
📌

Two status fields. The top-level status ("success") describes the API call. data.status is the payment session's own status — that's the one to act on.

Response Fields

FieldTypeDescription
statusstring"success" when the request succeeded.
codeintegerHTTP status code, echoed in the body.
messagestringHuman-readable description of the result.
data.urlstringThe hosted payment URL for the session.
data.sessionIdstringUnique identifier of the payment session.
data.corporateIdintegerID of the CartAI account that owns the session.
data.modestring"production" or "test" — the environment the session was created in.
data.created_atstringISO 8601 timestamp of when the session was created.
data.merchantNamestring | nullName of the merchant the session is associated with, or null.
data.merchantUrlstring | nullWebsite URL of the merchant the session is associated with, or null.
data.authorization.pricestringThe authorized payment amount.
data.authorization.currencystringCurrency code (always "USD").
data.authorization.purposestringThe purpose string provided when the session was created.
data.authorization.expirystringISO 8601 timestamp after which the session can no longer be used.
data.statusstringCurrent status of the payment session. See Session Statuses.
data.lockedbooleanWhether the session is locked.

Session Statuses

data.status uses the same values as the payment session webhooks.

StatusDescriptionWhat to do
createdThe 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.
approvedThe customer completed the hosted payment flow and authorized the payment.Call Get Payment Credentials to retrieve the credentials.
utilisedThe session's payment credentials have been used.Mark the session as used in your records.
expiredThe session passed its authorization.expiry before it was used.Create a new payment session if the customer still needs to pay.
purgedThe 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

Call 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 past authorization.expiry — the session can't be approved after that.

Step 3 — Use the sessionId in the Checkout API

Once 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 a provider. When paying with a payment session, customer.payment contains only data.sessionId. Don't include provider or 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 the approved event 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 StatusCauseWhat to do
200Status retrieved successfullyRead data.status to decide the next step
400Invalid sessionIdCheck that the sessionId is a valid UUID returned by Create Payment Session
401Missing or invalid x-api-keyVerify the header name and that you are using the correct environment key
404sessionId not foundVerify the ID is correct and matches the environment (QA vs production)
429Rate limitedBack off and retry after a delay
5xxCartAI server errorRetry with exponential backoff; contact support if it persists
Path Params
string
required

The sessionId returned by Create Payment Session

Headers
string
required
Responses

400

Bad Request

404

Payment session not found

Language
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json