Creating a checkout
POST /checkouts takes one or more line items, each pointing at a price variant by id:
"object": "checkout", id like co_...) with a URL the buyer visits to pay. When they complete it, an order is created.
Checkout fields
| Field | Type | Notes |
|---|---|---|
line_items | array | Each item is { price_variant (required), quantity }. Add multiple to sell a bundle in one checkout. |
email | string | The buyer’s email. Use this for a brand-new buyer. |
customer | string | An existing customer id (cus_...). Use instead of email to attach the purchase to a known customer. |
discount_code | string | A discount code applied to this checkout. See Discounts. |
invoice | string | An invoice id (inv_...) to pay — an alternative to line_items. See below. |
Multiple line items
Paying an invoice
Instead of line items, pass aninvoice id to create a checkout that settles that invoice:
Worked example: sell to a customer end-to-end
order.paid webhook event to fulfill the purchase.
Reusable checkout links
When you want one durable URL to share — in a bio link, an email, a “buy now” button — create a checkout link withPOST /checkout_links:
Checkout link fields
| Field | Type | Notes |
|---|---|---|
name | string | Internal label for the link. |
price_variants | array | The price variant ids (price_...) the link sells. |
discount | string | A discount id (disc_...) applied automatically. See Discounts. |
allow_discount_codes | bool | Whether buyers can enter their own code at checkout. |
success_url | string | Where to send the buyer after a successful purchase. |
metadata | object | Arbitrary key/values that flow through to the resulting order — handy for attribution. |
cl_...) and the shareable URL. Checkout links support full CRUD — update, list, retrieve, and delete them like any other resource.
Next steps
Discounts
Build the promo codes you apply via
discount_code and discount.Subscriptions & billing
Orders, invoices, refunds, and managing recurring revenue after checkout.
Products & pricing
Create the price variants your checkouts and links reference.
Webhooks
React to
checkout.created, order.paid, and other events in real time.
