
Create sessionPOST
OpenStock Docs
api/checkout-api/sessionscheckout_api100 requests / hourCreates a hosted checkout session and returns the URL to redirect your customer to. Pass either line_items (custom priced items) or product_ids (products from your store, delivered automatically) — not both.
Keys with no permissions at all are accepted by the Checkout API for backwards compatibility.
Authorization#
AuthorizationBearer <token>In: header. A store API key starting with sk_ that has the checkout_api permission.
Request body#
application/json
line_itemsobject[]Custom items with their own name and price. Required unless product_ids is set.
namerequiredstringItem name shown at checkout.
pricerequirednumberUnit price in the store currency.
quantityintegerPositive integer. Default: 1
descriptionstringOptional line description.
image_urlstringOptional image shown next to the item.
product_idsobject[]Products from your store. Stock is checked and delivery is handled for you. Required unless line_items is set.
idrequiredstringProduct ID.
quantityintegerPositive integer, limited by available stock. Default: 1
variant_idstringVariant ID for products with variants.
variant_name_or_idstringAlternative to variant_id: matches a variant by ID or case-insensitive name.
customer_emailstringPrefills the email field at checkout.
customer_namestringPrefills the customer name.
success_urlstringWhere the customer lands after paying.
cancel_urlstringWhere the customer lands if they abandon checkout.
expired_urlstringWhere the customer is sent if the session has expired.
webhook_urlstringReceives checkout.session.* events for this session.
expires_in_secondsnumberSession lifetime in seconds. Takes precedence over expires_in_hours.
expires_in_hoursnumberSession lifetime in hours. Default: 24
metadataobjectKey/value pairs echoed back in webhooks.
client_reference_idstringYour own identifier for this checkout, echoed back in webhooks.
hide_navbarbooleanHide the store navbar on the checkout page. Default: false
hide_footerbooleanHide the store footer on the checkout page. Default: false
disable_couponsbooleanPrevent coupon codes for this session. Default: false
disable_gift_cardsbooleanPrevent gift card redemption for this session. Default: false
Responses#
- 201Session created.
- 400Invalid body, unknown product, unavailable product or insufficient stock.
- 401Missing, malformed, disabled or expired API key.
- 429The hourly limit for this key was reached.