Create checkout session
Create a hosted checkout session. Redirect your customer to the returned URL to collect payment.
apiKeyHeaderx-api-key<token>API key for authentication. Generate from the dashboard or via POST /v1/api-keys.
x-api-key*stringAPI key for authentication
1 <= length- body
mode*string"payment""subscription"line_items*array<>List of items the customer is purchasing (1–20 items)
1 <= items <= 20currency?stringISO 4217 currency code
"ETB"success_url*stringURL to redirect the customer to after a successful payment. May include {CHECKOUT_SESSION_ID}, which is replaced with the session id.
^(?:[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})*)?$length <= 2048cancel_url*stringURL to redirect the customer to if they cancel the checkout. May include {CHECKOUT_SESSION_ID}, which is replaced with the session id.
^(?:[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})*)?$length <= 2048metadata?Arbitrary key-value metadata to attach to the session
customer*stringID of an existing customer to associate with this session
expires_at?numberSession expiry duration in seconds. Min 300 (5 min), max 86400 (24 h). Defaults to 1800 (30 min)
300 <= value <= 864001800subscription_data?Response for status 201
application/json- response
id*stringUnique identifier of the created checkout session.
url*stringHosted checkout URL where the customer can complete the payment.
status*stringCurrent status of the checkout session.
expires_at*numberUnix 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?