Endpoints
POST /checkout/sessions
Create a hosted checkout session.
POST
/checkout/sessionssecret keyCreate a hosted checkout session. Redirect the customer to `redirect_url`. We handle PAN entry, KYC, retries, and provider cascade.
Body parameters
amountintegerrequiredAmount in the smallest currency unit. e.g. 4500 = $45.00 USD.currencystringrequiredISO-4217 currency. Must be supported by your account.countrystringISO-3166 alpha-3 country to bias the cascade. Default: customer IP.methodstringRestrict the cascade to one method (card, spei, pix, oxxo, …).customerobject{ email, firstName, lastName, country }metadataobjectUp to 50 key-value pairs persisted on the resulting payment.success_urlstringrequiredWhere to redirect after a successful payment.cancel_urlstringrequiredWhere to redirect if the customer abandons the flow.
Request
curl https://sandbox-api.key2pays.com/v1/checkout/sessions \
-H "Authorization: Bearer sk_test_51N8mP...exampleK3Y" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "amount": 4500, "currency": "USD", … }'Response
{ "id": "cs_3aB7K8…", "status": "open", "redirect_url": "…", "expires_at": 1714676490 }Try itPOST
/checkout/sessionssandboxRequest body
amountintegerRequiredcurrencyenumRequiredcountryenummethodenumcustomerjsonsuccess_urlstringRequiredcancel_urlstringRequiredmetadatajsonLive snippet
curl -X POST "https://sandbox-api.key2pays.com/v1/checkout/sessions" \
-H "Authorization: Bearer sk_test_…YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 4500,
"currency": "USD",
"country": "MEX",
"customer": {
"email": "carlos@example.com",
"firstName": "Carlos",
"lastName": "Pérez"
},
"success_url": "https://acme.com/orders/1234?paid=1",
"cancel_url": "https://acme.com/orders/1234",
"metadata": {
"order_id": "1234"
}
}'Snippet updates as you edit the form. Sandbox responses are deterministic.