Deletes an existing payment session. Once deleted, the hosted payment URL stops working and payment credentials can no longer be retrieved for the session.
| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
When to Use This Endpoint
Use this endpoint to invalidate a payment session before it expires on its own. Common scenarios:
| Scenario | Description |
|---|---|
| Order cancelled | The customer abandons or cancels the purchase. Delete the session so the payment URL can no longer be used. |
| Amount or purpose changed | The cart total or purpose changed after the session was created. Delete the old session and create a new one. |
| Duplicate session | Your system created more than one session for the same order. Delete the extras. |
| Security or compliance | You need to revoke access to a session immediately (e.g. suspected fraud or a leaked URL). |
This action is irreversible. A deleted session cannot be restored. To collect payment again, create a new session via Create Payment Session.
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 --request DELETE 'https://api.cartai.ai/payment/session/01a1eeb2-7eda-7612-a3d1-b9e09c03f3e6' \
--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 deleted successfully"
}Response Fields
| Field | Type | Description |
|---|---|---|
status | string | "success" when the session was deleted. |
code | integer | HTTP status code, echoed in the body. |
message | string | Human-readable description of the result. |
Key Behaviours to Understand
The payment URL stops working immediately. If the customer opens the hosted url after the session is deleted, they will not be able to complete payment.
Credentials can no longer be retrieved. Calls to Get Payment Credentials with a deleted sessionId will fail.
Deleting does not refund a completed payment. If the customer already authorized and the credentials were used to place an order, deleting the session does not reverse that charge. Handle refunds through the merchant or your payment provider.
Error Reference
| HTTP Status | Cause | What to do |
|---|---|---|
200 | Session deleted successfully | No further action needed |
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 or already deleted | 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