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.
| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
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:
- Your backend calls this endpoint with the customer's email, the amount, and the purpose.
- CartAI returns a
sessionIdand a hostedurl. - You embed or redirect the customer to that URL.
- CartAI detects the customer's card network and launches the appropriate agentic payment flow — Visa Intelligent Commerce or Mastercard Agent Pay.
- The session expires automatically after 7 days (or at the
expirytimestamp 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_HERETo 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
| Field | Type | Required | Description |
|---|---|---|---|
email | string (email format) | ✅ Yes | The customer's email address. Used to identify the customer and look up their card. |
price | string | ✅ Yes | Payment amount in USD (e.g. "700"). Passed as a string — do not include currency symbols. |
purpose | string | ✅ Yes | A 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
| Field | Type | Description |
|---|---|---|
data.url | string | The hosted payment URL. Embed this in your web app or redirect the customer to it to start the payment flow. |
data.sessionId | string | Unique identifier for this payment session. Store this to correlate payment events. |
data.mode | string | "production" or "test" — reflects the environment the session was created in. |
data.created_at | string | ISO 8601 timestamp of when the session was created. |
data.authorization.price | string | The authorized payment amount. |
data.authorization.currency | string | Currency code (always "USD"). |
data.authorization.purpose | string | The purpose string you provided in the request, echoed back. |
data.authorization.expiry | string | ISO 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 thesessionIdbefore 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 Network | Payment Flow |
|---|---|
| Visa | Visa Intelligent Commerce |
| Mastercard | Mastercard 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:
| Field | Value |
|---|---|
| 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 Status | Cause | What to do |
|---|---|---|
200 | Session created successfully | Use the returned url to initiate the payment flow |
400 | Missing or invalid fields in the request body | Check that email, price, and purpose are all present and well-formed |
401 | Missing or invalid x-api-key | Verify the header name and that you are using the correct environment key |
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