> ## Documentation Index
> Fetch the complete documentation index at: https://crevio.co/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Checkouts

> Take payment with one-off checkouts and reusable checkout links — line items, customers, discount codes, and paying invoices.

**A checkout is a single pay-for-this session; a checkout link is a reusable, shareable URL that opens one.** Both turn your published price variants into money.

You can ask Crevio to "send Jane a checkout for the \$99 course with the LAUNCH20 code" and the agent builds it through the same API below. For programmatic flows — custom websites, "buy now" buttons, invoicing — you'll create checkouts directly.

## Creating a checkout

`POST /checkouts` takes one or more line items, each pointing at a price variant by id:

```bash theme={null}
curl -X POST https://api.crevio.co/v1/checkouts \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "jane@example.com",
    "line_items": [
      { "price_variant": "price_abc123", "quantity": 1 }
    ]
  }'
```

The response is a checkout (`"object": "checkout"`, id like `co_...`) with a URL the buyer visits to pay. When they complete it, an [order](/developer/guides/subscriptions-and-billing#orders-the-read-model) 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](/developer/guides/discounts).                 |
| `invoice`       | string | An invoice id (`inv_...`) to pay — an alternative to `line_items`. See below.                           |

### Multiple line items

```bash theme={null}
curl -X POST https://api.crevio.co/v1/checkouts \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": "cus_xyz789",
    "discount_code": "LAUNCH20",
    "line_items": [
      { "price_variant": "price_abc123", "quantity": 1 },
      { "price_variant": "price_def456", "quantity": 2 }
    ]
  }'
```

### Paying an invoice

Instead of line items, pass an `invoice` id to create a checkout that settles that invoice:

```bash theme={null}
curl -X POST https://api.crevio.co/v1/checkouts \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "invoice": "inv_abc123" }'
```

See [Subscriptions & billing](/developer/guides/subscriptions-and-billing#invoices) for creating and managing invoices.

## Worked example: sell to a customer end-to-end

```typescript theme={null}
import { Crevio } from "@crevio/sdk";

const crevio = new Crevio({ apiKeyAuth: "YOUR_API_TOKEN" });

// 1. Create (or look up) the customer.
const customer = await crevio.customers.create({
  email: "jane@example.com",
  name: "Jane Doe",
  customer_type: "lead",
});

// 2. Create a checkout for them, applying a launch discount.
const checkout = await crevio.checkouts.create({
  customer: customer.id,
  discount_code: "LAUNCH20",
  line_items: [{ price_variant: "price_abc123", quantity: 1 }],
});

// 3. Send the buyer to the checkout URL to pay.
console.log(checkout.url);
```

When the buyer pays, listen for the `order.paid` [webhook event](/developer/guides/webhooks) 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** with `POST /checkout_links`:

```bash theme={null}
curl -X POST https://api.crevio.co/v1/checkout_links \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Guitar course launch",
    "price_variants": ["price_abc123"],
    "discount": "disc_launch20",
    "allow_discount_codes": true,
    "success_url": "https://example.com/thanks",
    "metadata": { "campaign": "summer-launch" }
  }'
```

### 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](/developer/guides/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.          |

The response includes an id (`cl_...`) and the shareable URL. Checkout links support full CRUD — update, list, retrieve, and delete them like any other resource.

<Tip>
  Use a **checkout** for a one-off, often personalized sale (you know the buyer), and a **checkout link** for an evergreen, shareable offer (anyone can open it).
</Tip>

## Next steps

<CardGroup cols={2}>
  <Card title="Discounts" icon="percent" href="/developer/guides/discounts">
    Build the promo codes you apply via `discount_code` and `discount`.
  </Card>

  <Card title="Subscriptions & billing" icon="arrows-rotate" href="/developer/guides/subscriptions-and-billing">
    Orders, invoices, refunds, and managing recurring revenue after checkout.
  </Card>

  <Card title="Products & pricing" icon="tag" href="/developer/guides/products-and-pricing">
    Create the price variants your checkouts and links reference.
  </Card>

  <Card title="Webhooks" icon="bell" href="/developer/guides/webhooks">
    React to `checkout.created`, `order.paid`, and other events in real time.
  </Card>
</CardGroup>
