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

> ## Agent Instructions
> Laces is event registration software for every kind of event, not only races. Use the event's own wording.
> There is one environment, production: payments made through the API are real. Money is integer minor units; read the event's currency.
> Collecting payments with no Laces event uses POST /payments, then POST /orders/{orderId}/pay: start at /guides/collect-payments. Never call pay to test: there is no sandbox.
> Never put a client secret in browser code or an LLM chat. Branch on error_code, not on message.
> Overview of Laces: https://laces.run/llms.txt

# Create and publish events with the Laces API

> Create a Laces event as a draft with the Partner API, add paid ticket types, publish it, and optionally send buyers to your own registration site.

With the `events:write` permission, your server can create an event in your
organization, add paid ticket types, and publish it, without opening the Laces
app. You can also point the event at your own registration site.

> [!WARNING]
>
> **There is no sandbox.** Every event you create is a real event in your
> organization, on a public short code, and it counts against your daily limit.
> For tests, create the event with `visibility: "unlisted"` and remove or close
> it in the Laces app afterwards. See [Testing your integration](https://docs.laces.run/concepts/testing.md).

## Turn it on

`events:write` is **off by default** and is never available to a publishable
key. An owner or admin turns it on for one API key in the Laces app (see
[Getting your API keys](https://docs.laces.run/api-keys.md#create-events-and-registration-domains)). A
key that just gained the scope needs a **new token**: fetch one from the
[token endpoint](https://docs.laces.run/api-reference/v1/oauth/token.md). See [Scopes](https://docs.laces.run/concepts/scopes.md).

The write routes accept a **bearer token only**. A publishable key gets
`403 credential_not_permitted`.

## The flow

**1. Create the draft**

[`POST /events`](https://docs.laces.run/api-reference/v1/events/create) with an `Idempotency-Key`
header. The event is created as a **draft**: it cannot be bought yet.

```bash theme={null}
curl -s -X POST "$LACES_BASE/events" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Saturday Park Run",
    "timezone": "Africa/Kampala",
    "starts_at": "2027-03-27T07:00:00",
    "ends_at": "2027-03-27T10:00:00",
    "venue": "Kololo Airstrip",
    "visibility": "unlisted",
    "partner_reference": "run-2027-03-27"
  }'
```

The `201` response carries the new `event_id`, its `short_code`,
`status: "draft"` and `ticket_types: []`.

**2. Add ticket types**

[`POST /events/{eventId}/ticket-types`](https://docs.laces.run/api-reference/v1/events/create-ticket-type),
once per ticket, again with an `Idempotency-Key`. Tickets are **paid only**
(see [Paid tickets only](#paid-tickets-only)).

```bash theme={null}
curl -s -X POST "$LACES_BASE/events/$EVENT_ID/ticket-types" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "name": "5K", "price_minor": 50000, "capacity": 200, "distance_km": 5 }'
```

**3. Publish**

[`POST /events/{eventId}/publish`](https://docs.laces.run/api-reference/v1/events/publish) opens
registration. It needs no body and no `Idempotency-Key`: publishing an
event that is already `open` is a `200` that changes nothing.

`409 nothing_to_sell` means the event has no ticket type to sell yet.

Then sell it like any other event: [hosted checkout](https://docs.laces.run/guides/hosted-checkout.md),
[embedded checkout](https://docs.laces.run/guides/embedded-checkout.md), or a
[custom UI](https://docs.laces.run/guides/custom-ui.md), using the `event_id` from step 1. Orders are
refused with `403 payments_disabled` until your organization is cleared to take
payments; publishing does not check that, and the event response carries
`payments_enabled` so you can.

## Which events you can change

A key can add ticket types to, publish and update **only events it created**.
Any other event, including one created in the app or by another key, answers
`404 not_found`. Regenerating a key's secret keeps its ownership.

Selling is different: any active key in the organization with `orders:write` or
`checkout_sessions:write` can sell any of its events, as before.

## Dates and time zones

* **`timezone` is required** and must be an IANA zone name such as
  `Africa/Kampala` or `Europe/London`. Abbreviations (`EAT`) and bare offsets
  (`+03:00`) are refused with `400 invalid_timezone`. There is no default.
* `starts_at` and `ends_at` are **ISO 8601 strings**. A number (epoch time) is
  refused.
  * With an offset or `Z` (`2027-03-27T07:00:00+03:00`, `2027-03-27T04:00:00Z`)
    the value is that exact instant.
  * **Without an offset** (`2027-03-27T07:00:00`) the value is wall-clock time
    **in `timezone`**, correct across daylight-saving changes. A wall-clock time
    that does not exist or occurs twice on a clock-change night resolves the
    way the Laces app does; send an offset if you need to be exact.
* `starts_at` may be at most 5 minutes in the past and at most 3 years ahead
  (`400 invalid_starts_at`).
* `ends_at` may not be before `starts_at` and may be at most 31 days after it
  (`400 invalid_ends_at`).
* Timestamps in responses are ISO 8601 in UTC.

Registration closes at `starts_at` unless the organizer changes it in the app.
The event's currency is your organization's currency; you cannot set it.

## Paid tickets only

`price_minor` is a whole number of minor units of the organization's currency,
above zero.

* `price_minor: 0` is `400 free_ticket_not_supported`. Create free events in
  the Laces app.
* A price below the minimum Laces can collect is `422 price_below_minimum`,
  with `error_details.minimum_price_minor` and `error_details.currency`.
* Laces sets `visibility` to public, shows remaining places, and adds no kit.
  You cannot set those from the API.
* An event can hold at most **20 ticket types**, counting any the organizer
  added in the app (`409 ticket_type_limit_reached`).

## Idempotency and retries

`POST /events` and `POST /events/{eventId}/ticket-types` **require** an
`Idempotency-Key` header: 1 to 255 visible ASCII characters (a UUID is ideal).
Missing is `400 idempotency_key_required`; anything else is
`400 invalid_idempotency_key`.

* Keys are scoped to your API client **and** to the route, so the same string on
  create and on ticket types never collides.
* Same key and same body again: `200`, "Already created (idempotent replay)",
  and the stored response. Nothing is created twice. This holds even when the
  first request used up the last draft or ticket-type place: the retry gets the
  stored result, not `draft_limit_reached` or `ticket_type_limit_reached`.
* If the event was written but Laces failed to build the response, the retry
  with the same key also replays the stored event. It is never created a second
  time.
* A **new** key at a limit still gets `409 draft_limit_reached` or
  `409 ticket_type_limit_reached`.
* Same key with a different body: `422 idempotency_key_reuse`. On ticket types
  the `eventId` is part of the body, so the same key for a different event is
  also `422`.
* Same key while the first call is running: `409 idempotency_in_progress`.
  Retry shortly with the same key.
* A request that fails validation (`400`) does not use up its key: fix the body
  and send the same key again.

> [!WARNING]
>
> **The 2-minute takeover.** In the rare case that the Laces server handling
> your create dies before it records the event it wrote, the key stays "in
> progress". After **2 minutes** the next request with that key is processed
> again, which can create the event a second time even though the first attempt
> succeeded. So after a timeout longer than
> 2 minutes, **check for the first event before you retry**. The API cannot do
> this for you in v1: a new event is a draft, and [list events](https://docs.laces.run/api-reference/v1/events/list.md)
> never returns drafts and cannot filter by `partner_reference`. If the first
> response was lost you also have no `event_id` to read. So open your
> organization in the Laces app, look in its drafts for an event with the same
> name and start time, and use that one (or delete the duplicate there). Still
> set `partner_reference` on create (up to 128 characters, your own id for the
> event): it is returned to the key that created the event once you have its
> `event_id`. The daily and draft limits below keep the cost of a duplicate
> small.

## Limits

| Limit | Value | Over the limit |
| - | - | - |
| Write requests | About 60 per minute per API client | `429 rate_limited`, wait `Retry-After` |
| Events created through the API | **20 per organization per UTC day** | `429 event_limit_reached`; `Retry-After` is the seconds until 00:00 UTC |
| Unpublished API drafts | **25 per API client** | `409 draft_limit_reached`: publish some, or remove them in the app |
| Ticket types per event | **20** | `409 ticket_type_limit_reached` |
| Registration domains per key | **20** | `400 invalid_origin` |

Field limits: `name` 1 to 200 characters; `venue` up to 300 (blank counts as
not sent); `description` up to 10,000; `waiver_text` up to 20,000 (any text
turns the waiver on); `partner_reference` up to 128; ticket `name` 1 to 120;
ticket `description` up to 2,000.

## Bodies are strict

Every field is a top-level string, number or `null`. No nested objects or
arrays.

* A key Laces does not accept is `400 unknown_field`.
* A value of the wrong type is `400 validation_failed`. Nothing is coerced:
  `"price_minor": "5000"` is refused.

Both name the field in `error_details.field`. `null` clears
`registration_url`; for any other optional field, leave it out instead of
sending `null`.

## Cover images

`cover_url` is an **image link**, not an upload.

* Laces **does not copy, proxy or host** your image. Visitors' browsers load it
  from your server, so it must keep working.
* Use a **stable `https` URL you control**, with no credentials in it. About
  **1600 x 900, landscape**, as JPEG, PNG or WebP.
* A **new image needs a new URL.** Laces derives the event page's colours from
  the image once per URL; changing the file behind the same URL does not
  refresh them.
* If the link redirects, takes more than 3 seconds to answer, is over 5 MB or
  over 40 megapixels, or is not JPEG, PNG or WebP, the image can still display
  in a browser, but the event gets **no colour theme** and uses the standard
  Laces accent.
* Link shorteners and shared hosts are refused with `400 invalid_cover_url`
  (the same shorteners and shared sites listed under
  [registration domains](#registration-domains)). A Laces storage link is
  accepted.
* Social previews and share graphics for an API-created event use the Laces
  stock cover, not your image.

## Registration domains

By default buyers register on laces.run. You can send them to **your own
site** instead, for events you create through the API.

> [!TIP]
>
> `registration_url` only sends people to your site; it takes no money. If you
> want Laces to collect there, use [payments](https://docs.laces.run/guides/collect-payments.md).
> Not sure which you need? See [Which route do I need?](https://docs.laces.run/index.md#which-route-do-i-need).

1. An owner or admin lists your site's origin under **Registration domains**
   on the key in the Laces app, for example `https://tickets.example.com`.
2. You send `registration_url` on [`POST /events`](https://docs.laces.run/api-reference/v1/events/create),
   or later with [`PATCH /events/{eventId}`](https://docs.laces.run/api-reference/v1/events/update).

```bash theme={null}
curl -s -X PATCH "$LACES_BASE/events/$EVENT_ID" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "registration_url": "https://tickets.example.com/e/saturday-park-run" }'
```

The `registration_url` must be `https` and its **origin** (scheme, host and
port) must be exactly one of the key's registration domains, or the answer is
`400 invalid_registration_url`. The default port matches (`:443` is the same as
none); any other port must be listed with that port. A path, query and fragment
are kept as you send them. `PATCH` with `{ "registration_url": null }` returns
the event to Laces registration.

**Always refused**, even if listed: Laces hosts (`laces.run` and every
subdomain, `docs.laces.run`, Laces storage hosts), URL shorteners such as
`bit.ly`, and shared sites where the path rather than the host names the owner
(for example Google Sites and Forms, Linktree, WhatsApp and Telegram links,
Facebook, Instagram, X, GitHub). A leading `www.` does not get around it. The
check runs again every time you set a URL.

**What changes on laces.run** for an event with a `registration_url`:

* The event page shows `Register on {host}` instead of Laces checkout,
  with "You'll leave laces.run to register and pay."
* The event leaves Laces discovery (the events grid, listings and sitemap). It
  stays on your organization's page, and the link and short code keep working.
* Anonymous Laces checkout for it is refused with
  `409 registration_external`, whose `error_details.registration_url` is your
  URL.
* Owners and admins get a notification when a URL is set, changed or cleared
  by a `PATCH` on the event, and when it is cleared automatically. Sending a
  `registration_url` when you create the event sends no notification. The organizer
  can switch the event back to Laces registration in the app at any time. If an owner removes the origin from your key or revokes the
  key, the URLs it set are cleared automatically.

> [!NOTE]
>
> **This is routing, not security.** The `409 registration_external` refusal
> stops an anonymous buyer from competing with your site. It does not stop any
> other active key in the organization from selling the event through
> [orders](https://docs.laces.run/api-reference/v1/orders/create.md) or
> [checkout sessions](https://docs.laces.run/api-reference/v1/checkout-sessions/create.md), and a
> publishable key can still start a checkout session. Do not rely on it to keep
> buyers off Laces.

## Reading your own events

[`GET /events/{eventId}`](https://docs.laces.run/api-reference/v1/events/get) also returns your key's
own **draft** events, when the token holds both `events:read` and
`events:write`. [`GET /events`](https://docs.laces.run/api-reference/v1/events/list) never lists
drafts. Every event carries `registration_url`, `registration_mode`
(`laces` or `external`) and `created_via_api`.

> [!WARNING]
>
> A draft is not private. Anyone who has its short code can open it on
> laces.run. Keep drafts short-lived, and use `visibility: "unlisted"` for
> tests.

## Errors

The new error codes carry their detail in `error_details`, not `details`. See
[Errors](https://docs.laces.run/concepts/errors.md#create-and-publish-events).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.