Create Payment Session

Creates a hosted payment session that generates a secure URL for embedding in your web application. The session initiates Visa Intelligent Commerce or Mastercard Agent Pay based on the customer's card. Share the returned URL with the customer to complete payment.

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

Creates a secure, hosted payment session and returns a URL you can embed in your web application. When the customer opens the URL, CartAI automatically starts Visa Intelligent Commerce or Mastercard Agent Pay based on the card on file — no additional integration required.

How it Works

Calling POST /payment/session provisions a time-limited payment session tied to a specific customer and amount. The flow is:

  1. Your backend calls this endpoint with the customer's email, the amount, and the purpose.
  2. CartAI returns a sessionId and a hosted url.
  3. You embed or redirect the customer to that URL.
  4. CartAI detects the customer's card network and launches the appropriate agentic payment flow — Visa Intelligent Commerce or Mastercard Agent Pay.
  5. The session expires automatically after 7 days (or at the expiry timestamp in the response).
⚠️

Never expose your API key in client-side code. Always call this endpoint from your backend and pass only the resulting URL to your frontend.


Authentication

Every request must include your API key in the request header.

x-api-key: YOUR_API_KEY_HERE

To get your API key, generate it from the CartAI Admin Portal after your account is provisioned. Contact the CartAI Account Management Team to request access.


Request Body

FieldTypeRequiredDescription
emailstring (email format)✅ YesThe customer's email address. Used to identify the customer and look up their card.
pricestring✅ YesPayment amount in USD (e.g. "700"). Passed as a string — do not include currency symbols.
purposestring✅ YesA short description of what the payment is for (e.g. "Manil's Purchase Agent"). Shown to the customer during the payment flow.

Full Request Example

curl --location 'https://api.cartai.ai/payment/session' \
  --header 'x-api-key: YOUR_API_KEY_HERE' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "email": "[email protected]",
      "price": "700",
      "purpose": "Carol'\''s Purchase Agent"
  }'

Response

A successful request returns HTTP 200 with the following body.

{
  "status": "success",
  "code": 200,
  "message": "Payment session created successfully",
  "data": {
    "url": "https://wallet.cartai.ai?token=<jwt_token>&type=bt&mode=p",
    "sessionId": "019ed477-7954-7d92-8884-d442d1f91549",
    "mode": "production",
    "created_at": "2026-06-17T07:24:20.497354",
    "authorization": {
      "price": "700",
      "currency": "USD",
      "purpose": "Carol's Purchase Agent",
      "expiry": "2026-06-24T07:20:32.875162+00:00"
    }
  }
}

Response Fields

FieldTypeDescription
data.urlstringThe hosted payment URL. Embed this in your web app or redirect the customer to it to start the payment flow.
data.sessionIdstringUnique identifier for this payment session. Store this to correlate payment events.
data.modestring"production" or "test" — reflects the environment the session was created in.
data.created_atstringISO 8601 timestamp of when the session was created.
data.authorization.pricestringThe authorized payment amount.
data.authorization.currencystringCurrency code (always "USD").
data.authorization.purposestringThe purpose string you provided in the request, echoed back.
data.authorization.expirystringISO 8601 timestamp after which the session URL is no longer valid.

Embedding the Payment URL

The url returned in the response is designed to be embedded directly in your web application. You can open it in a new tab, an iframe, or a modal.

<!-- Open in a new tab -->
<a href="SESSION_URL" target="_blank">Complete Payment</a>
// Redirect the current page
window.location.href = sessionData.data.url;

// Or open in a popup
window.open(sessionData.data.url, '_blank', 'width=480,height=640');
💡

Tip: Store the sessionId before redirecting so you can reconcile the completed payment against your order when you receive the webhook callback.


Agentic Payment Networks

CartAI automatically selects the payment network based on the card associated with the customer's email:

Card NetworkPayment Flow
VisaVisa Intelligent Commerce
MastercardMastercard Agent Pay

No additional configuration is needed — the hosted URL handles network detection transparently.


Testing

To test the payment flow end-to-end without using a real card, use the following test credentials:

FieldValue
Card Number(Add Test Card here)
Expiry(Add Test Card here)
CVV(Add Test Card here)
⚠️

Test sessions only work against the QA environment (https://qa.api.cartai.ai). Do not use test cards against the production endpoint.


Error Reference

HTTP StatusCauseWhat to do
200Session created successfullyUse the returned url to initiate the payment flow
400Missing or invalid fields in the request bodyCheck that email, price, and purpose are all present and well-formed
401Missing or invalid x-api-keyVerify the header name and that you are using the correct environment key
429Rate limitedBack off and retry after a delay
5xxCartAI server errorRetry with exponential backoff; contact support if it persists
Body Params
string
required

Customer's email address

string
required

Payment amount in USD

string
required

Description of what the payment is for (e.g. agent name or product)

Headers
string
required
Responses

400

Bad Request

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