# Codes

> Promo codes (discounts) and access codes (unlock hidden items)

Source: https://rcms-tickets-test.web.app/docs/reference/codes

Every operation below is also in [the OpenAPI document](https://rcms-tickets-test.web.app/v1/openapi.yaml). One that names an MCP tool can be called through [the MCP server](https://rcms-tickets-test.web.app/docs/mcp.md); one that names none cannot.

## List codes

`GET /v1/codes`

Operation id `listCodes`. MCP tool `list_codes`. SDK `tickets.codes.list`.

Promo codes (discounts) and access codes (unlock hidden items), with how many times each was used. The text of a code is null for a read key or a viewer. Finding a code by its text is `POST /v1/codes/search`, so a code never goes in a URL. `origin=explicit` lists the codes made one at a time, and `origin=batch` those a batch made: a batch can be thousands of codes, so read it by page.

**Who may call it.** Any one of: An API key with scope `full`, `read`. Any other scope answers `insufficient_scope`; A signed-in dashboard member whose role has `read` (owner, admin, staff, viewer).

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `limit` | query | integer | How many to return, 1 to 100 (default 20). |
| `starting_after` | query | string | An id from the page before: the page after it. |
| `ending_before` | query | string | An id from the page after: the page before it. A list read from the database offers it as the list comes and filtered by event alone, in the default order, and answers parameter_invalid to any other… |
| `event` | query | string | An id starting with evt_. |
| `partner` | query | string | An id starting with ptr_. |
| `active` | query | "true" \| "false" |  |
| `origin` | query | "explicit" \| "batch" | explicit: codes made one at a time. batch: codes made by a code batch. Goes with event and no other filter. |

**Answers 200.** A page of codes with their use counts. The text of a code is null for a read key or a viewer. To find a code by its text use POST /v1/codes/search: a code in a URL is kept in logs.

**Fields**

| Field | Type | Description |
| --- | --- | --- |
| `object` * | "list" |  |
| `data` * | array of CodeAsRead | This page, newest first. |
| `has_more` * | boolean | True when there is another page: pass the last id as starting_after. |
| `url` * | "/v1/codes" | The path this list came from (/v1/codes). |

\* required

## Make a promo or access code

`POST /v1/codes`

Operation id `createCode`. MCP tool `create_code`. SDK `tickets.codes.create`.

Makes a promo code (a discount), an access code (`unlocks` hidden ticket types or add-ons), or both. The same text cannot be used twice in an event, ignoring case (`code_already_exists`). The code text goes in the body, never a URL. For thousands of single-use codes, use `POST /v1/events/{id}/code_batches`.

**Who may call it.** Any one of: An API key with scope `full`. Any other scope answers `insufficient_scope`; A signed-in dashboard member whose role has `catalog.write` (owner, admin, staff).

**Request body** (`CreateCodeInput`)

| Field | Type | Description |
| --- | --- | --- |
| `event` * | string | An id starting with evt_. |
| `code` * | string | A promo or access code as typed; case does not matter. |
| `description` | string |  |
| `discount` | Discount \| null |  |
| `applies_to` | "all" \| array of string | What the discount applies to: "all" is every ticket type; an add-on is discounted only when named here. Refund protection (a pass_through add-on) cannot be named: a code never reduces it. |
| `unlocks` | array of string | Hidden types and add-ons it makes visible and holdable. |
| `max_uses` | integer \| null | Orders that may use it in all, or null. |
| `max_quantity_per_order` | integer \| null | Units discounted in one order, or null for all of them. A bundle is one unit. Left out when a code is made: 1 for a single-use code, no limit otherwise. Changing max_uses moves a limit that was the default to the new de… |
| `starts_at` | string (date-time) | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `ends_at` | string (date-time) | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `partner` | string | An id starting with ptr_. |
| `active` | boolean |  |
| `metadata` | object | Your own key-value pairs (up to 50; keys up to 40 characters, values up to 500). We store and return them and never act on them. |

\* required

```json
{
  "event": "evt_yrd2027",
  "code": "CABANA",
  "unlocks": [
    "tt_cabana"
  ]
}
```

**Answers 201.** The code.

**Fields** (`Code`)

| Field | Type | Description |
| --- | --- | --- |
| `object` * | "code" |  |
| `id` * | string | An id starting with code_. |
| `mode` * | Mode | test or live, decided by the key (rt_test_… or rt_live_…). Test and live data never mix. |
| `event` * | string | An id starting with evt_. |
| `code` * | string | A promo or access code as typed; case does not matter. |
| `description` * | string \| null |  |
| `discount` * | Discount \| null | What it takes off, or null for an access code that only unlocks. |
| `applies_to` * | "all" \| array of string | What the discount applies to: "all" is every ticket type; an add-on is discounted only when named here. Refund protection (a pass_through add-on) cannot be named: a code never reduces it. |
| `unlocks` * | array of string | Hidden types and add-ons it makes visible and holdable. |
| `max_uses` * | integer \| null | Orders that may use it in all, or null. |
| `max_quantity_per_order` * | integer \| null | Units discounted in one order, or null for all of them. A bundle is one unit. Left out when a code is made: 1 for a single-use code, no limit otherwise. Changing max_uses moves a limit that was the default to the new de… |
| `starts_at` * | string \| null | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `ends_at` * | string \| null | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `partner` * | string \| null | The partner or influencer it belongs to. |
| `active` * | boolean |  |
| `metadata` * | Metadata | Your own key-value pairs (up to 50; keys up to 40 characters, values up to 500). We store and return them and never act on them. |
| `uses` * | integer | Orders made with it (its holds consumed). Comps credited to it are counted in reports, never here. |
| `reserved` * | integer | Uses held by open holds right now: counted against max_uses until the hold expires, is released or becomes an order. |
| `created_at` * | string (date-time) | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `updated_at` * | string (date-time) | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |

\* required

**Errors of its own.** [`currency_mismatch`](https://rcms-tickets-test.web.app/docs/errors.md#currency_mismatch), [`code_already_exists`](https://rcms-tickets-test.web.app/docs/errors.md#code_already_exists), [`invalid_state_transition`](https://rcms-tickets-test.web.app/docs/errors.md#invalid_state_transition). The errors every operation can answer are on [the errors page](https://rcms-tickets-test.web.app/docs/errors.md).

## List and search codes, the code text in the body (never in a URL)

`POST /v1/codes/search`

Operation id `searchCodes`. MCP tool `search_codes`. SDK `tickets.codes.search`.

The same list and filters as `GET /v1/codes`, with `code` (the text to find, in any letter case) in the body so it never goes in a URL, where our logs and browser history would keep it. The text of a code is null for a read key or a viewer.

**Who may call it.** Any one of: An API key with scope `full`, `read`. Any other scope answers `insufficient_scope`; A signed-in dashboard member whose role has `read` (owner, admin, staff, viewer).

**Request body**

| Field | Type | Description |
| --- | --- | --- |
| `limit` | integer | How many to return, 1 to 100 (default 20). |
| `starting_after` | string | An id from the page before: the page after it. |
| `ending_before` | string | An id from the page after: the page before it. A list read from the database offers it as the list comes and filtered by event alone, in the default order, and answers parameter_invalid to any other filter or sort (page… |
| `event` | string | An id starting with evt_. |
| `partner` | string | An id starting with ptr_. |
| `active` | "true" \| "false" |  |
| `code` | string |  |
| `origin` | "explicit" \| "batch" | explicit: codes made one at a time. batch: codes made by a code batch. Goes with event and no other filter. |

```json
{
  "event": "evt_yrd2027",
  "code": "VISITDETROIT"
}
```

**Answers 200.** A page of codes: the same filters and answer as GET /v1/codes. Use this to find a code by its text. The text of a code is null for a read key or a viewer.

**Fields**

| Field | Type | Description |
| --- | --- | --- |
| `object` * | "list" |  |
| `data` * | array of CodeAsRead | This page, newest first. |
| `has_more` * | boolean | True when there is another page: pass the last id as starting_after. |
| `url` * | "/v1/codes/search" | The path this list came from (/v1/codes/search). |

\* required

## Retrieve a code

`GET /v1/codes/{id}`

Operation id `getCode`. MCP tool `get_code`. SDK `tickets.codes.retrieve`.

One code with its use count. The text of the code is null for a read key or a viewer.

**Who may call it.** Any one of: An API key with scope `full`, `read`. Any other scope answers `insufficient_scope`; A signed-in dashboard member whose role has `read` (owner, admin, staff, viewer).

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `id` * | path | string | An id starting with code_. |

**Answers 200.** The code. Its text is null for a read key or a viewer.

**Fields** (`CodeAsRead`)

| Field | Type | Description |
| --- | --- | --- |
| `object` * | "code" |  |
| `id` * | string | An id starting with code_. |
| `mode` * | Mode | test or live, decided by the key (rt_test_… or rt_live_…). Test and live data never mix. |
| `event` * | string | An id starting with evt_. |
| `code` * | string \| null | The text of the code. Null for a read key or a viewer: a code is a thing to spend, so reading one needs the right to change the catalog. |
| `description` * | string \| null |  |
| `discount` * | Discount \| null | What it takes off, or null for an access code that only unlocks. |
| `applies_to` * | "all" \| array of string | What the discount applies to: "all" is every ticket type; an add-on is discounted only when named here. Refund protection (a pass_through add-on) cannot be named: a code never reduces it. |
| `unlocks` * | array of string | Hidden types and add-ons it makes visible and holdable. |
| `max_uses` * | integer \| null | Orders that may use it in all, or null. |
| `max_quantity_per_order` * | integer \| null | Units discounted in one order, or null for all of them. A bundle is one unit. Left out when a code is made: 1 for a single-use code, no limit otherwise. Changing max_uses moves a limit that was the default to the new de… |
| `starts_at` * | string \| null | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `ends_at` * | string \| null | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `partner` * | string \| null | The partner or influencer it belongs to. |
| `active` * | boolean |  |
| `metadata` * | Metadata | Your own key-value pairs (up to 50; keys up to 40 characters, values up to 500). We store and return them and never act on them. |
| `uses` * | integer | Orders made with it (its holds consumed). Comps credited to it are counted in reports, never here. |
| `reserved` * | integer | Uses held by open holds right now: counted against max_uses until the hold expires, is released or becomes an order. |
| `created_at` * | string (date-time) | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `updated_at` * | string (date-time) | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |

\* required

## Change a code (not its text)

`PATCH /v1/codes/{id}`

Operation id `updateCode`. MCP tool `update_code`. SDK `tickets.codes.update`.

Changes a code's discount, what it applies to, limits, dates, partner or whether it is active. The text of a code never changes: make a new one.

**Who may call it.** Any one of: An API key with scope `full`. Any other scope answers `insufficient_scope`; A signed-in dashboard member whose role has `catalog.write` (owner, admin, staff).

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `id` * | path | string | An id starting with code_. |

**Request body** (`UpdateCodeInput`)

| Field | Type | Description |
| --- | --- | --- |
| `description` | string \| null |  |
| `discount` | Discount \| null |  |
| `applies_to` | "all" \| array of string | What the discount applies to: "all" is every ticket type; an add-on is discounted only when named here. Refund protection (a pass_through add-on) cannot be named: a code never reduces it. |
| `unlocks` | array of string | Hidden types and add-ons it makes visible and holdable. |
| `max_uses` | integer \| null | Never below the uses so far plus those open holds reserve (limit_below_committed); applied to its use pool in the same write. |
| `max_quantity_per_order` | integer \| null | Units discounted in one order, or null for all of them. A bundle is one unit. Left out when a code is made: 1 for a single-use code, no limit otherwise. Changing max_uses moves a limit that was the default to the new de… |
| `starts_at` | string \| null | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `ends_at` | string \| null | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `partner` | string \| null | An id starting with ptr_. |
| `active` | boolean |  |
| `metadata` | object | Your own key-value pairs (up to 50; keys up to 40 characters, values up to 500). We store and return them and never act on them. |

```json
{
  "active": false
}
```

**Answers 200.** Updated.

**Fields** (`Code`)

| Field | Type | Description |
| --- | --- | --- |
| `object` * | "code" |  |
| `id` * | string | An id starting with code_. |
| `mode` * | Mode | test or live, decided by the key (rt_test_… or rt_live_…). Test and live data never mix. |
| `event` * | string | An id starting with evt_. |
| `code` * | string | A promo or access code as typed; case does not matter. |
| `description` * | string \| null |  |
| `discount` * | Discount \| null | What it takes off, or null for an access code that only unlocks. |
| `applies_to` * | "all" \| array of string | What the discount applies to: "all" is every ticket type; an add-on is discounted only when named here. Refund protection (a pass_through add-on) cannot be named: a code never reduces it. |
| `unlocks` * | array of string | Hidden types and add-ons it makes visible and holdable. |
| `max_uses` * | integer \| null | Orders that may use it in all, or null. |
| `max_quantity_per_order` * | integer \| null | Units discounted in one order, or null for all of them. A bundle is one unit. Left out when a code is made: 1 for a single-use code, no limit otherwise. Changing max_uses moves a limit that was the default to the new de… |
| `starts_at` * | string \| null | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `ends_at` * | string \| null | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `partner` * | string \| null | The partner or influencer it belongs to. |
| `active` * | boolean |  |
| `metadata` * | Metadata | Your own key-value pairs (up to 50; keys up to 40 characters, values up to 500). We store and return them and never act on them. |
| `uses` * | integer | Orders made with it (its holds consumed). Comps credited to it are counted in reports, never here. |
| `reserved` * | integer | Uses held by open holds right now: counted against max_uses until the hold expires, is released or becomes an order. |
| `created_at` * | string (date-time) | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `updated_at` * | string (date-time) | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |

\* required

**Errors of its own.** [`currency_mismatch`](https://rcms-tickets-test.web.app/docs/errors.md#currency_mismatch), [`limit_below_committed`](https://rcms-tickets-test.web.app/docs/errors.md#limit_below_committed), [`invalid_state_transition`](https://rcms-tickets-test.web.app/docs/errors.md#invalid_state_transition). The errors every operation can answer are on [the errors page](https://rcms-tickets-test.web.app/docs/errors.md).
