Utopia PaymentsDocs
Checkout sessions

Create a checkout session

Returns a `checkout_url` to redirect the customer to. A cart with one recurring product starts a subscription; otherwise it takes a one-time payment. Sessions expire after 24 hours.

POST
/checkout_sessions

Returns a checkout_url to redirect the customer to. A cart with one recurring product starts a subscription; otherwise it takes a one-time payment. Sessions expire after 24 hours.

Authorization

secretKey
AuthorizationBearer <token>

Your secret key: sk_live_… or sk_test_….

In: header

Header Parameters

Idempotency-Key?string

Retrying with the same key returns the first response instead of creating a duplicate.

Lengthlength <= 255

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X POST "https://example.com/checkout_sessions" \  -H "Content-Type: application/json" \  -d '{    "product_cart": [      {        "product_id": "pdt_3f2b8c1e9a4d4e7b8c2a1d5e6f7a8b9c"      }    ]  }'
{  "object": "checkout_session",  "session_id": "cks_3f2b8c1e9a4d4e7b8c2a1d5e6f7a8b9c",  "kind": "payment",  "status": "open",  "checkout_url": "http://example.com",  "total_amount": 0,  "currency": "AED",  "product_cart": [    {      "product_id": "pdt_3f2b8c1e9a4d4e7b8c2a1d5e6f7a8b9c",      "name": "string",      "quantity": 0,      "unit_amount": 0    }  ],  "customer": {    "name": "string",    "email": "string",    "phone_number": "string"  },  "return_url": "string",  "payment_id": "pay_3f2b8c1e9a4d4e7b8c2a1d5e6f7a8b9c",  "subscription_id": "sub_3f2b8c1e9a4d4e7b8c2a1d5e6f7a8b9c",  "metadata": {    "property1": "string",    "property2": "string"  },  "livemode": true,  "created_at": "2019-08-24T14:15:22Z",  "expires_at": "2019-08-24T14:15:22Z",  "completed_at": "2019-08-24T14:15:22Z"}