# Quickstart

> Sell your first ticket in 10 minutes, in test mode: the kit for a site, then curl or the SDK

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

This page makes an event, puts it on sale, holds two tickets, pays with a test card and reads the tickets back. Nothing real moves: a test key only ever touches test data.

> **Where things stand.** RCMS Tickets is in development. A test key works today and is all you need here. Live mode is open only for an organization we have cleared: any other live key answers `live_mode_not_open`. See [what exists and what does not](https://rcms-tickets-test.web.app/docs/status.md).

## Adding a checkout to a site? Start with the kit

The fastest way to a working checkout on a site you already have is [the kit](https://rcms-tickets-test.web.app/docs/kit.md): code you copy in, with every step of the buyer's page and a small server of yours that holds the key. An agent or a person can do it in about five minutes:

1. Have a test key and an event id (`evt_...`). Step 2 below makes an event if you have none.
2. Fetch https://rcms-tickets-test.web.app/kit/manifest.json and follow its `steps`: run its install tool, apply the recipe for Next.js or Vite, put `RCMS_TICKETS_KEY` and `RCMS_TICKETS_EVENT` in `.env.local`.
3. Run the site, open `/tickets`, and buy a ticket. The kit reads the event's name, date, venue, tickets and add-ons from the API: you write none of them.
4. In test mode the payment step shows four test cards (Works, Declined, Not enough funds, Processor error). Press one, then Pay.

The rest of this page is the API underneath, with curl and then the SDK: use it to make the event, or when you build your own checkout.

## What you need

- A **test key**, which starts with `rt_test_`. A key is made by a person, never by another key: sign in to the dashboard, open Developers, then API keys, then Create API key, pick scope Full, and copy the secret. The dashboard makes a test key. It is shown once. [Authentication](https://rcms-tickets-test.web.app/docs/authentication.md) says why, and how an agent can sign in as the person instead of holding a key.
- The key in your server's environment as `RCMS_TICKETS_KEY`. A key never goes in a browser or a mobile app: there is no publishable key.
- For curl: `curl` and `jq`. Each step is shown with curl first, which needs nothing else, and then with the TypeScript SDK (Node 20.3 or later). **The SDK is not published yet**: [install it from this site](https://rcms-tickets-test.web.app/docs/sdk.md), or stay with curl.
- A list answers `{ object: 'list', data: [...] }`: the items are under `.data`.

Everything on this page is run against the real API handlers in a test, every time the docs are built, so a sample here that stops working fails the build.

## 1. Check the key

Ask the key what it is before you write anything. It answers its mode and scope.

**cURL**

```bash
export API=https://rcms-tickets-test.web.app/v1
rt() { curl -sS --fail-with-body "$@" -H "Authorization: Bearer $RCMS_TICKETS_KEY" -H "Content-Type: application/json"; }

rt "$API/keys/current" | jq '{mode, scope}'
```

**Node.js**

```ts
import { Tickets } from '@rcmstickets/sdk';

const tickets = new Tickets(process.env.RCMS_TICKETS_KEY);

const key = await tickets.keys.current();
console.log(key.mode, key.scope); // test full
```

Every SDK call is one HTTP call: the operation's id, its SDK name and its MCP tool, if it has one, are on its [reference](https://rcms-tickets-test.web.app/docs/reference/events.md) page.

## 2. Make an event

One call makes the event, its days, its ticket types, an add-on and a promo code, all or nothing. The `ref` names are yours: they let the items point at each other inside this one request, and come back next to the real ids.

The dates below are 45 days from today. Replace them with your event's real dates; a day's times are instants, and `timezone` is the venue's.

**cURL**

```bash
DAY=$(date -u -d '+45 days' +%F 2>/dev/null || date -u -v+45d +%F)

SETUP=$(rt "$API/events/setup" -H "Idempotency-Key: $(uuidgen)" -d @- <<JSON
{
  "event": {
    "name": "Riverfront Fest",
    "currency": "usd",
    "venue": {
      "name": "Riverfront Stage",
      "address": { "line1": "100 Example Ave", "line2": null, "city": "Detroit", "region": "MI", "postal_code": "48201", "country": "US" },
      "timezone": "America/Detroit",
      "location": null
    },
    "days": [{ "date": "$DAY", "name": "Friday", "doors_at": "${DAY}T20:00:00Z", "starts_at": "${DAY}T21:00:00Z", "ends_at": "${DAY}T23:30:00Z" }]
  },
  "ticket_types": [
    { "ref": "ga", "name": "General admission", "price": { "amount": 5000, "currency": "usd" }, "capacity": 100 },
    { "ref": "vip", "name": "VIP", "price": { "amount": 12000, "currency": "usd" }, "capacity": 20 }
  ],
  "add_ons": [
    { "ref": "parking", "name": "Parking", "price": { "amount": 2000, "currency": "usd" }, "per": "order", "capacity": 30 }
  ],
  "codes": [
    { "code": "WELCOME10", "discount": { "amount_off": null, "percent_off_bps": 1000 }, "applies_to": ["ga"] }
  ]
}
JSON
)

EVENT=$(echo "$SETUP" | jq -r .event.id)
GA=$(echo "$SETUP" | jq -r '.ticket_types[] | select(.ref == "ga") | .id')
PARKING=$(echo "$SETUP" | jq -r '.add_ons[] | select(.ref == "parking") | .id')
echo "$EVENT $GA $PARKING"
```

**Node.js**

```ts
const usd = (amount: number) => ({ amount, currency: 'usd' as const });

// Replace these with your event's dates. Here: 45 days from today.
const day = new Date(Date.now() + 45 * 24 * 3600 * 1000).toISOString().slice(0, 10);

const setup = await tickets.bulk.setup({
  event: {
    name: 'Riverfront Fest',
    currency: 'usd',
    venue: {
      name: 'Riverfront Stage',
      address: { line1: '100 Example Ave', line2: null, city: 'Detroit', region: 'MI', postal_code: '48201', country: 'US' },
      timezone: 'America/Detroit',
      location: null,
    },
    days: [{ date: day, name: 'Friday', doors_at: `${day}T20:00:00Z`, starts_at: `${day}T21:00:00Z`, ends_at: `${day}T23:30:00Z` }],
  },
  ticket_types: [
    { ref: 'ga', name: 'General admission', price: usd(5000), capacity: 100 },
    { ref: 'vip', name: 'VIP', price: usd(12000), capacity: 20 },
  ],
  add_ons: [{ ref: 'parking', name: 'Parking', price: usd(2000), per: 'order', capacity: 30 }],
  codes: [{ code: 'WELCOME10', discount: { amount_off: null, percent_off_bps: 1000 }, applies_to: ['ga'] }],
});

// The ids are null only on a dry run, which makes nothing.
const event = setup.event!.id;
const ga = setup.ticket_types.find((t) => t.ref === 'ga')!.id!;
const parking = setup.add_ons.find((a) => a.ref === 'parking')!.id!;
console.log(event, ga, parking);
```

Prices are integers in the currency's smallest unit: `5000` is $50.00. A float is refused.

### What you can leave out

- **A ticket type** needs only `ref`, `name` and `price`. Left out, it has no capacity of its own (only the day's and the event's apply), it is good for every day, a buyer may take 1 to 10 in an order, it is public, and it has no fees.
- **The venue's address** needs `line1`, `city`, `region`, `postal_code` and `country`. `line2` and `location` must be there, and may be `null`.
- **Times** are instants: write them in UTC (`…Z`) or with an offset. `2027-07-16T20:00:00Z` is 4 PM in Detroit. `timezone` is the venue's, and it decides what "today" is at the door.
- **`ref` is yours**, and only means something inside this one request (`applies_to: ['ga']`). The real ids come back beside it, and a hold takes the real ids and a code's text.
- **Add-ons and codes** are optional. A ticket type alone is a valid event.
- **A bundle** (a 5-pack) is one purchase that issues several tickets: add `tickets_per_unit: 5`. `price` is for the whole bundle, `capacity` counts tickets, and `per_order_min` and `per_order_max` count bundles. See [bundles](https://rcms-tickets-test.web.app/docs/concepts.md#bundles).
- A day's `date` is the local date of its `doors_at` at the venue, and `doors_at ≤ starts_at < ends_at`.

Before you commit to a big setup, add `dry_run: true`: the answer says what would be made, or why not, and nothing is written.

## 3. Put it on sale

An event starts as a draft. Nothing is for sale until you publish it.

**cURL**

```bash
rt -X POST "$API/events/$EVENT/publish" -H "Idempotency-Key: $(uuidgen)" | jq -r .status
```

**Node.js**

```ts
const published = await tickets.events.publish(event);
console.log(published.status); // on_sale
```

## 4. Hold two tickets

A hold reserves the tickets for 10 minutes and answers the one price you may show: lines, discount, fees, tax and total. Show exactly that. Never work out a price yourself.

**cURL**

```bash
HOLD=$(rt "$API/holds" -H "Idempotency-Key: $(uuidgen)" -d "{
  \"event\": \"$EVENT\",
  \"items\": [{ \"ticket_type\": \"$GA\", \"quantity\": 2 }, { \"add_on\": \"$PARKING\", \"quantity\": 1 }],
  \"code\": \"WELCOME10\"
}")

HOLD_ID=$(echo "$HOLD" | jq -r .id)
echo "$HOLD" | jq '{id, expires_at, total: .price.total}'
```

**Node.js**

```ts
const hold = await tickets.holds.create({
  event,
  items: [
    { ticket_type: ga, quantity: 2 },
    { add_on: parking, quantity: 1 },
  ],
  code: 'WELCOME10',
});

console.log(hold.id, hold.expires_at, hold.price.total); // { amount: 11000, currency: 'usd' }
```

Two GA tickets at $50.00 are $100.00, the code takes 10% off them ($10.00), and parking is $20.00: **$110.00**, which is `11000`.

## 5. Pay and make the order

In your own checkout you charge the card with your payment processor, then send the order with the amount you charged. In test mode you can skip the processor: the `test` provider takes a test token.

**cURL**

```bash
ORDER=$(rt "$API/orders" -H "Idempotency-Key: $(uuidgen)" -d "{
  \"hold\": \"$HOLD_ID\",
  \"buyer\": { \"name\": \"Maria Delgado\", \"email\": \"maria@example.com\" },
  \"payment\": { \"provider\": \"test\", \"token\": \"tok_success\" }
}")

ORDER_ID=$(echo "$ORDER" | jq -r .id)
echo "$ORDER" | jq '{id, number, status, tickets_status, paid: .amount_paid}'
```

**Node.js**

```ts
const order = await tickets.orders.create({
  hold: hold.id,
  buyer: { name: 'Maria Delgado', email: 'maria@example.com' },
  payment: { provider: 'test', token: 'tok_success' },
});

console.log(order.id, order.status, order.amount_paid); // ord_… paid { amount: 11000, currency: 'usd' }
```

The order is `paid`. Its `number` (like `7KQ2-M9XD`) is the one the buyer reads on a confirmation page and in the email, and the one a person at the door can search by. Its tickets are issued a moment after, by a background step, and the confirmation email goes to the buyer (`example.com` is a reserved name that delivers nowhere, and in test mode mail reaches only [members of your organization](https://rcms-tickets-test.web.app/docs/testing.md); send `notify: { email: false }` to send nothing). The answer waits up to three seconds for the tickets, so `order.tickets` is usually full. When `tickets_status` is still `pending`, wait a second and read the order again, or wait for the `order.tickets_issued` [webhook](https://rcms-tickets-test.web.app/docs/webhooks.md). A few reads is plenty. Tickets still pending after a minute is a fault: quote the order id to support.

## 6. Read the tickets

**cURL**

```bash
rt "$API/orders/$ORDER_ID" | jq '{tickets_status, tickets: [.tickets[] | {id, status}]}'
```

**Node.js**

```ts
const paid = await tickets.orders.retrieve(order.id);

for (const ticket of paid.tickets) {
  // ticket.url is the holder's private page. Wallet links are on the ticket itself: tickets.tickets.retrieve(ticket.id).wallet
  console.log(ticket.id, ticket.status, ticket.url);
}
```

To list an event's orders, `GET /v1/orders?event=evt_...` (`.data[]`; it also takes `status`). To read an order's tickets without the order, `GET /v1/tickets?order=ord_...` lists them (`.data[]`; the same filter takes `event`, `ticket_type` and `status`). Each ticket has its own private page, `ticket.url`, which a holder opens on a phone, and `ticket.wallet.apple_url` and `ticket.wallet.google_url` for [Wallet](https://rcms-tickets-test.web.app/docs/wallet.md). Treat these links as secrets: anyone who has one can use the ticket.

## Where next

- Build the real checkout, with your own payment processor: [the checkout recipe](https://rcms-tickets-test.web.app/docs/checkout.md), or copy [the checkout kit](https://rcms-tickets-test.web.app/docs/kit.md).
- Learn the vocabulary: [concepts](https://rcms-tickets-test.web.app/docs/concepts.md).
- Get told when something happens: [webhooks](https://rcms-tickets-test.web.app/docs/webhooks.md).
- Working with an AI agent: [for agents](https://rcms-tickets-test.web.app/docs/agents.md).
