Skip to content
Coursey CreativeSign in

POST /checkout

/api/store/[slug]/checkout

Creates a Stripe Checkout session for the cart (one-time or subscription products), with optional coupon, gift card, service charges, and sale-price handling, then returns the hosted payment URL.

Public; optional customer bearer token links the order to the customer and prefills checkoutRate limit 20 requests per 60 seconds per client IP + slugHow authentication works

Path parameters

slugstringrequired

Business (store) slug used to resolve the tenant

Body parameters

itemsarrayrequired

Cart lines; array of objects { variant_id: UUID string, quantity: positive integer }. At least 1 item required.

shipping_optionenumoptional

Shipping choice; only applied when the cart contains physical products. flat_rate adds the business's flat shipping fee as a line item.

One of pickup, flat_rate

success_urlstringrequired

Valid http(s) URL Stripe redirects to after successful payment (normalized/truncated if over 1800 chars).

cancel_urlstringrequired

Valid http(s) URL Stripe redirects to if the customer cancels.

service_chargesarrayoptional

Optional add-on charges; array of objects { service_charge_id: UUID, variant_id: UUID, quantity: positive integer }. Each charge must belong to the business and be associated with the variant's product.

pickup_datestringoptional

Pickup date in YYYY-MM-DD format. Only valid when shipping_option is 'pickup' (schema refine rejects otherwise).

coupon_codestringoptional

Coupon code, 1-20 chars, pattern ^[a-zA-Z0-9-]+$ (dashes allowed for generated codes). Re-validated server-side; cannot be combined with gift_card_code.

gift_card_codestringoptional

Gift card code, 1-32 chars, pattern ^[a-zA-Z0-9\s-]+$ (16 alphanumeric chars, dashes/spaces allowed). Not combinable with coupon_code or subscription products; at least $0.50 stays payable.

customer_emailstringoptional

Guest email capture (valid email, max 254 chars). Used to prefill Stripe checkout and enable abandoned-checkout recovery; ignored when a customer is authenticated.

Responses

200

The request succeeded.

400

A field failed validation. The response names the fields that failed, not just the first.

404

No such store, or no such record inside it.

429

Too many requests. Back off and retry after the window in the response.

500

Something failed on our side. The response carries no detail; retry is safe on a GET.

503

A service this endpoint depends on is unavailable, usually Stripe.

What comes back

200 with { session_url, session_id } (Stripe hosted checkout URL and session ID). Errors return { error, details? } with 400/404/500/502/503. The 429 body differs from the rest: { success: false, error, retryAfter }. CORS-enabled (Access-Control-Allow-Origin: *); OPTIONS preflight supported.