Create a hosted checkout session
const url = 'https://api.sevigram.com/storefront/v1/checkouts';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"return_url":"https://example.com","lines":[{"type":"product","variant_id":"example","quantity":1,"fulfillment":{"method":"pickup","pickup_location_id":"example"},"expected_unit_price":1}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.sevigram.com/storefront/v1/checkouts \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "return_url": "https://example.com", "lines": [ { "type": "product", "variant_id": "example", "quantity": 1, "fulfillment": { "method": "pickup", "pickup_location_id": "example" }, "expected_unit_price": 1 } ] }'Prices the lines on the server and returns a session with a hosted checkout_url. The storefront never supplies prices; expected_unit_price is only a guard and a mismatch answers 409 checkout_conflict with reason price_changed. Sessions expire 30 minutes after creation and reserve no stock. Without Idempotency-Key every call creates a session (201). A repeat with the same key and body returns the original session (200); the same key with a different body answers 409 idempotency_key_reused. A session holds 1 to 50 product lines or exactly one service line; mixing them is 400 validation_error. A service line without package_id books the service’s first package. Service checkout supports time-slot services only: a rate-priced or date-booked service answers 409 checkout_conflict with reason slot_unavailable. Services that require configured resources are not supported through checkout sessions. Rate limited per shopper IP (10 per minute by default); the read-only check runs before the limit. Never cached. With a private token, an optional X-Sevigram-Customer-Session attributes the checkout to the signed-in customer and prefills the hosted page; a public token with the header answers 403 private_token_required, and an invalid or expired session answers 401 customer_session_invalid (never a silent guest checkout). Read-only shops stay 403 demo_shop_read_only.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”8 to 160 printable ASCII characters, unique per storefront.
Optional on createCheckout: the customer session token from verifyCustomerCode (private token only). A credential: never logged or echoed.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Absolute, no userinfo, no fragment. Its origin must equal one of the storefront’s allowed origins.
object
object
One booking of a time-slot service. Rate-priced and date-booked services are not bookable here (slot_unavailable), and services that require configured resources are not supported through checkout sessions.
object
Package to book. When omitted, the service’s first package is used; a service with no packages answers 409 checkout_conflict with reason not_found.
Responses
Section titled “Responses”The original session, replayed for a repeated Idempotency-Key.
object
object
Set once the session is completed.
object
Example
{ "data": { "status": "open", "lines": [ { "type": "product" } ] }}Headers
Section titled “Headers”Request correlation id, echoed or generated.
Never cached.
The request’s Idempotency-Key, echoed when one was sent.
Session created.
object
object
Set once the session is completed.
object
Example
{ "data": { "status": "open", "lines": [ { "type": "product" } ] }}Headers
Section titled “Headers”Request correlation id, echoed or generated.
Never cached.
The request’s Idempotency-Key, echoed when one was sent.
Invalid request. Codes validation_error, invalid_cursor, invalid_buyer_ip.
object
object
Optional structured detail (for example per-field validation messages). Omitted when there is none.
Example
{ "error": { "code": "validation_error" }}Headers
Section titled “Headers”Request correlation id, echoed or generated.
Never cached.
Code invalid_token, customer_session_invalid (missing, malformed, expired or another business’s session) or customer_code_invalid (wrong or expired sign-in code on verify).
object
object
Optional structured detail (for example per-field validation messages). Omitted when there is none.
Example
{ "error": { "code": "invalid_token" }}Headers
Section titled “Headers”Request correlation id, echoed or generated.
Never cached.
Codes origin_not_allowed, storefront_disabled, demo_shop_read_only, private_token_required.
object
object
Optional structured detail (for example per-field validation messages). Omitted when there is none.
Example
{ "error": { "code": "origin_not_allowed" }}Headers
Section titled “Headers”Request correlation id, echoed or generated.
Never cached.
Code checkout_conflict (details.lines lists each failing line) or idempotency_key_reused.
object
object
Optional structured detail (for example per-field validation messages). Omitted when there is none.
object
object
Example
{ "error": { "code": "checkout_conflict", "details": { "lines": [ { "reason": "not_found" } ] } }}Headers
Section titled “Headers”Request correlation id, echoed or generated.
Never cached.
The return URL’s origin is not one of the storefront’s allowed origins. Code return_url_not_allowed.
object
object
Optional structured detail (for example per-field validation messages). Omitted when there is none.
Example
{ "error": { "code": "return_url_not_allowed" }}Headers
Section titled “Headers”Request correlation id, echoed or generated.
Never cached.
Too many requests. Code rate_limited.
object
object
Optional structured detail (for example per-field validation messages). Omitted when there is none.
Example
{ "error": { "code": "rate_limited" }}Headers
Section titled “Headers”Request correlation id, echoed or generated.
Never cached.
Whole seconds to wait, rounded up.
An upstream is unavailable. Code service_unavailable.
object
object
Optional structured detail (for example per-field validation messages). Omitted when there is none.
Example
{ "error": { "code": "service_unavailable" }}Headers
Section titled “Headers”Request correlation id, echoed or generated.
Never cached.
Always 5.