logoAccess

Create checkout session

POST
/api/v1/checkout/sessions/

Create a hosted checkout session. Redirect your customer to the returned URL to collect payment.

Authorization

apiKeyHeader
headerx-api-key<token>

API key for authentication. Generate from the dashboard or via POST /v1/api-keys.

Header Parameters

x-api-key*string

API key for authentication

Length1 <= length

Request Body

  1. body
mode*string
Value in"payment""subscription"
line_items*array<>

List of items the customer is purchasing (1–20 items)

Items1 <= items <= 20
currency?string

ISO 4217 currency code

Default"ETB"
success_url*string

URL to redirect the customer to after a successful payment. May include {CHECKOUT_SESSION_ID}, which is replaced with the session id.

Match^(?:[a-zA-Z][a-zA-Z0-9+\-.]*:)(?:\/?\/(?:(?:[a-zA-Z0-9\-._~!$&'()*+,;=:]|%[0-9a-fA-F]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-fA-F]{1,4}:){6}|::(?:[0-9a-fA-F]{1,4}:){5}|(?:[0-9a-fA-F]{1,4})?::(?:[0-9a-fA-F]{1,4}:){4}|(?:(?:[0-9a-fA-F]{1,4}:){0,1}[0-9a-fA-F]{1,4})?::(?:[0-9a-fA-F]{1,4}:){3}|(?:(?:[0-9a-fA-F]{1,4}:){0,2}[0-9a-fA-F]{1,4})?::(?:[0-9a-fA-F]{1,4}:){2}|(?:(?:[0-9a-fA-F]{1,4}:){0,3}[0-9a-fA-F]{1,4})?::[0-9a-fA-F]{1,4}:|(?:(?:[0-9a-fA-F]{1,4}:){0,4}[0-9a-fA-F]{1,4})?::)(?:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-fA-F]{1,4}:){0,5}[0-9a-fA-F]{1,4})?::[0-9a-fA-F]{1,4}|(?:(?:[0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})?::)|[Vv][0-9a-fA-F]+\.[a-zA-Z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-zA-Z0-9\-._~!$&'()*+,;=]|%[0-9a-fA-F]{2})*)(?::\d*)?(?:\/(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@{}]|%[0-9a-fA-F]{2})*)*|\/(?:(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@{}]|%[0-9a-fA-F]{2})+(?:\/(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@{}]|%[0-9a-fA-F]{2})*)*)?|(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@{}]|%[0-9a-fA-F]{2})+(?:\/(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@{}]|%[0-9a-fA-F]{2})*)*)(?:\?(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@/?{}]|%[0-9a-fA-F]{2})*)?(?:#(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@/?{}]|%[0-9a-fA-F]{2})*)?$
Lengthlength <= 2048
cancel_url*string

URL to redirect the customer to if they cancel the checkout. May include {CHECKOUT_SESSION_ID}, which is replaced with the session id.

Match^(?:[a-zA-Z][a-zA-Z0-9+\-.]*:)(?:\/?\/(?:(?:[a-zA-Z0-9\-._~!$&'()*+,;=:]|%[0-9a-fA-F]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-fA-F]{1,4}:){6}|::(?:[0-9a-fA-F]{1,4}:){5}|(?:[0-9a-fA-F]{1,4})?::(?:[0-9a-fA-F]{1,4}:){4}|(?:(?:[0-9a-fA-F]{1,4}:){0,1}[0-9a-fA-F]{1,4})?::(?:[0-9a-fA-F]{1,4}:){3}|(?:(?:[0-9a-fA-F]{1,4}:){0,2}[0-9a-fA-F]{1,4})?::(?:[0-9a-fA-F]{1,4}:){2}|(?:(?:[0-9a-fA-F]{1,4}:){0,3}[0-9a-fA-F]{1,4})?::[0-9a-fA-F]{1,4}:|(?:(?:[0-9a-fA-F]{1,4}:){0,4}[0-9a-fA-F]{1,4})?::)(?:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-fA-F]{1,4}:){0,5}[0-9a-fA-F]{1,4})?::[0-9a-fA-F]{1,4}|(?:(?:[0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})?::)|[Vv][0-9a-fA-F]+\.[a-zA-Z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-zA-Z0-9\-._~!$&'()*+,;=]|%[0-9a-fA-F]{2})*)(?::\d*)?(?:\/(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@{}]|%[0-9a-fA-F]{2})*)*|\/(?:(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@{}]|%[0-9a-fA-F]{2})+(?:\/(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@{}]|%[0-9a-fA-F]{2})*)*)?|(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@{}]|%[0-9a-fA-F]{2})+(?:\/(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@{}]|%[0-9a-fA-F]{2})*)*)(?:\?(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@/?{}]|%[0-9a-fA-F]{2})*)?(?:#(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@/?{}]|%[0-9a-fA-F]{2})*)?$
Lengthlength <= 2048
metadata?

Arbitrary key-value metadata to attach to the session

customer*string

ID of an existing customer to associate with this session

expires_at?number

Session expiry duration in seconds. Min 300 (5 min), max 86400 (24 h). Defaults to 1800 (30 min)

Range300 <= value <= 86400
Default1800
subscription_data?

Response Body

Response for status 201

application/json
  1. response
id*string

Unique identifier of the created checkout session.

url*string

Hosted checkout URL where the customer can complete the payment.

status*string

Current status of the checkout session.

expires_at*number

Unix timestamp indicating when the checkout session expires.

curl -X POST 'https://api.tryaccess.xyz/api/v1/checkout/sessions/' \  -H 'x-api-key: string' \  -H 'Content-Type: application/json' \  -d '{  "mode": "payment",  "line_items": [    {      "price": 9900,      "quantity": 1,      "product_data": {        "name": "Pro Plan"      }    }  ],  "success_url": "https://example.com/success?session_id={CHECKOUT_SESSION_ID}",  "cancel_url": "https://example.com/cart?session_id={CHECKOUT_SESSION_ID}",  "customer": "cus_01J9Z8K2P3Q4R5S6T7U8V9W0X1"}'
{  "id": "cs_live_01M3XGD3CEQYQ7G4XF6MAAFY6M",  "url": "https://checkout.tryaccess.xyz/c/pay/cs_live_01M3XGD3CEQYQ7G4XF6MAAFY6M",  "status": "open",  "expires_at": "1791135161"}

How is this guide?