# Hosted checkout links

> A page we host that sells one event's tickets, for a seller with no site and an agent that just wants a URL

Source: https://rcms-tickets-test.web.app/docs/hosted-links

A hosted link is a page at `https://rcms-tickets-test.web.app/c/chl_…` that sells one event's tickets. There is nothing to build: send the address in a text or a post, and a buyer holds, pays and gets their tickets there. For your own checkout on your own site, use [the kit](https://rcms-tickets-test.web.app/docs/kit.md) or [the recipe](https://rcms-tickets-test.web.app/docs/checkout.md).

> **Test links only, for now.** A live key can't make one (`feature_disabled`), and a link takes only the `test` provider. [What exists and what does not](https://rcms-tickets-test.web.app/docs/status.md).

## Turn it on

The org's `hosted_checkout_enabled` is off until someone turns it on. While it's off, making a link answers 403 `feature_disabled`, and a link's page, holds and orders answer the same.

- **An agent signed in as a member** calls `update_org` with `{ "settings": { "hosted_checkout_enabled": true } }`. It asks first. A key can't do this: [the MCP server](https://rcms-tickets-test.web.app/docs/mcp.md).
- **A person** turns it on under Settings.

## Make a link

The event must be published. An agent's tool is `create_checkout_link`.

```ts
const link = await tickets.checkoutLinks.create({
  event,
  ticket_types: [ga],
  limit: 50,
  utm: { source: 'instagram', medium: 'post', campaign: 'onsale' },
});

console.log(link.url.includes('/c/chl_')); // true
```

| Field | What it does |
| --- | --- |
| `ticket_types`, `add_ons` | What it offers: a list, or `all`. A `comp_only` type can't be sold; a `hidden` one needs `code`. With `ticket_types: []` it offers only add-ons bought for the order, like parking: `all` means all of those, and naming a per-ticket add-on or refund protection is refused. |
| `code` | Applied for everyone who opens it. A link takes no other. |
| `limit` | Orders it may take. |
| `expires_at` | When it closes. |
| `utm` | Goes on every order. It wins over the address's tags. |

An order made through a link says `channel: 'checkout_link'` and names the link. Find them with `tickets.orders.list({ event })`, as you find any order. The link's `orders` counts them.

## Its limits

Holds on a link are free, so caps bound abuse but can't end it.

- **A network may hold at most half of what's left of an item and of a link**, counted per network per event. A hold of up to 4 always fits while that many are left.
- A network may have 20 open holds on one link, and 40 tickets held per event, across its links. A link has at most 300 open holds.
- Past any of these a buyer reads "busy": 429 `rate_limited`, with `Retry-After`.

A few addresses can still tie up a small link for 10 minutes at a time at no cost. We accept that while only test links exist. Before live money on hosted links we'll measure it and decide on a challenge at hold time.

## Mail

**A test order through a link mails only the organization's members.** Anyone can type any address on a public page, so no one else gets mail or a text, and what was typed stays on the tickets. The same goes for a test order made with a key or the kit. Read what stayed behind with `GET /v1/test_helpers/mail`. See [test mode](https://rcms-tickets-test.web.app/docs/testing.md).

A free order may also mail at most 4 guests besides its buyer. One link may mail 600 addresses an hour, and one network 40. A buyer who paid real money always hears.

The order's answer says when its mail didn't go as usual, in the `Tickets-Mail` header:

| `Tickets-Mail` | What happened |
| --- | --- |
| `off` | None went: the buyer isn't a member of the organization, on a test link. |
| `later` | A cap was reached. It goes in the next window. |
| `buyer` | All the tickets went to the buyer. |

## Close it

Turn it off, and the page says it isn't taking orders. So does a link past its `limit` or `expires_at`. Holds and orders answer 410 `checkout_link_inactive`. A payment already under way finishes.

```ts
const closed = await tickets.checkoutLinks.update(link.id, { active: false });
console.log(closed.active); // false
```

A hold made on a link can become an order only through that link. A site running [the kit](https://rcms-tickets-test.web.app/docs/kit.md) is never told to mail about one.
