Delete Payment Session

Deletes an existing payment session. Once deleted, the hosted payment URL stops working and payment credentials can no longer be retrieved for the session.

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

When to Use This Endpoint

Use this endpoint to invalidate a payment session before it expires on its own. Common scenarios:

ScenarioDescription
Order cancelledThe customer abandons or cancels the purchase. Delete the session so the payment URL can no longer be used.
Amount or purpose changedThe cart total or purpose changed after the session was created. Delete the old session and create a new one.
Duplicate sessionYour system created more than one session for the same order. Delete the extras.
Security or complianceYou 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.

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 --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

FieldTypeDescription
statusstring"success" when the session was deleted.
codeintegerHTTP status code, echoed in the body.
messagestringHuman-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 StatusCauseWhat to do
200Session deleted successfullyNo further action needed
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 found or already deletedVerify 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