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

# Quickstart

> Go from API key to a fully populated, published event in 5 minutes.

## Prerequisites

* A Ticketnation organizer account
* Node.js 18+
* An organization with at least one API key

## Step 1: Get Your API Key

<Steps>
  <Step title="Log in">
    Log in to [Ticketnation](https://ticketnation.ph) as an organizer
  </Step>

  <Step title="Navigate to API Keys">
    Go to **Settings > API Keys** tab
  </Step>

  <Step title="Create a key">
    Click **+ Create Key** and fill in:

    * **Name** — a label for your integration (e.g., "Experia Integration")
    * **Description** — what this key is used for
    * **Scopes** — check the permissions you need:
      * **Read Events** — view events and details
      * **Write Events** — create, update, manage events, performers, schedules, brands
      * **Read Tickets** — view ticket types and inventory
      * **Write Tickets** — create and manage ticket types
      * **Manage Webhooks** — register and manage webhooks
    * **Callback URL** (optional) — receive webhook notifications
    * **IP Allowlist** (optional) — restrict access to specific IPs
  </Step>

  <Step title="Copy your key">
    Copy the key immediately — it is only shown once
  </Step>
</Steps>

<Warning>Store your API key securely. It cannot be retrieved after creation.</Warning>

## Step 2: Install the SDK

```bash theme={null}
npm install ticketnation-sdk
```

## Step 3: Create a Fully Populated Event

This example creates an event with tickets, performers, a schedule, and sponsor brands — then publishes it, all in one script.

```typescript theme={null}
import { Ticketnation, formatPeso } from 'ticketnation-sdk';

const tn = new Ticketnation({
  apiKey: process.env.TICKETNATION_API_KEY!,
});

async function main() {
  // 1. Verify your API key works
  const info = await tn.me();
  console.log(`Connected as: ${info.organization.name}`);

  // 2. Search for a venue
  const { data: venues } = await tn.venues.search({ query: 'MOA Arena' });
  const venueId = venues[0]?.id;

  // 3. Create and publish the event in one call
  const event = await tn.events.createAndPublish({
    name: 'Summer Music Fest 2025',
    dateTime: '2025-06-15T18:00:00.000Z',
    endDateTime: '2025-06-15T23:00:00.000Z',
    venueId,
    imageUrl: 'https://example.com/images/summer-fest-cover.jpg',
    galleryUrls: [
      'https://example.com/images/gallery-1.jpg',
      'https://example.com/images/gallery-2.jpg',
    ],
    absorbFees: true,
    tickets: [
      {
        name: 'General Admission',
        price: 1500,
        quantity: 500,
        published: true,
      },
      {
        name: 'VIP',
        price: 5000,
        quantity: 50,
        published: true,
      },
    ],
  });

  console.log(`Event live: ${event.name} (${event.status})`);
  console.log(`GA price: ${formatPeso(1500)}`);  // ₱1,500.00
  console.log(`VIP price: ${formatPeso(5000)}`); // ₱5,000.00

  // 4. Add performers to the lineup
  const headliner = await tn.performers.create(event.id, {
    name: 'SB19',
    type: 'ARTIST',
    imageUrl: 'https://example.com/images/sb19.jpg',
    description: 'P-pop icons',
  });

  const dj = await tn.performers.create(event.id, {
    name: 'DJ Nix',
    type: 'DJ',
  });

  console.log('Performers added:', headliner.name, dj.name);

  // 5. Build the event schedule
  await tn.schedules.create(event.id, {
    title: 'Doors Open',
    startTime: '2025-06-15T17:00:00.000Z',
    endTime: '2025-06-15T18:00:00.000Z',
    icon: 'door',
  });

  await tn.schedules.create(event.id, {
    title: 'DJ Nix Set',
    startTime: '2025-06-15T18:00:00.000Z',
    endTime: '2025-06-15T19:30:00.000Z',
    performerId: dj.id,
    color: '#FF6B35',
  });

  await tn.schedules.create(event.id, {
    title: 'SB19 Live',
    startTime: '2025-06-15T20:00:00.000Z',
    endTime: '2025-06-15T22:30:00.000Z',
    performerId: headliner.id,
    description: 'Main stage performance',
    color: '#1DB954',
  });

  console.log('Schedule built');

  // 6. Add sponsor brands
  await tn.brands.create(event.id, {
    name: 'Red Bull',
    url: 'https://redbull.com',
    imageUrl: 'https://example.com/images/redbull-logo.png',
    description: 'Energy drink partner',
  });

  await tn.brands.create(event.id, {
    name: 'Globe Telecom',
    url: 'https://globe.com.ph',
    imageUrl: 'https://example.com/images/globe-logo.png',
  });

  console.log('Brands attached');
  console.log(`\nDone! View your event at: https://ticketnation.ph/${event.slug}`);
}

main().catch(console.error);
```

<Tip>
  `createAndPublish()` creates the event and immediately publishes it. If you need to review before going live, use `create()` followed by `publish()` separately.
</Tip>

## Step 4: Check Orders

Once buyers purchase tickets, you can fetch orders:

```typescript theme={null}
import { formatPeso } from 'ticketnation-sdk';

const { data: orders, meta } = await tn.orders.list(event.id);
console.log(`${meta.total} orders for this event`);

for (const order of orders) {
  const name = `${order.user.firstName} ${order.user.lastName}`;
  const ticketCount = order.orderEventTickets.reduce(
    (sum, item) => sum + item.quantity,
    0,
  );
  console.log(`#${order.orderNumber}: ${name} — ${ticketCount} tickets — ${formatPeso(order.total)}`);
}
```

Or set up a webhook to be notified in real-time — see [Authentication](/developers/authentication) for webhook setup.

## Step 5: Set Up Webhooks (Optional)

Get notified instantly when someone buys a ticket:

```typescript theme={null}
const webhook = await tn.webhooks.create({
  url: 'https://api.yoursite.com/webhooks/ticketnation',
  events: ['order.completed', 'order.refunded', 'event.sold_out'],
});

// Store this secret securely — it is only shown once
console.log('Webhook secret:', webhook.secret);

// Send a test event to verify it works
const test = await tn.webhooks.test(webhook.id);
console.log('Test result:', test.success ? 'OK' : 'Failed');
```

## Using REST Directly

If you are not using TypeScript, you can call the API directly with any HTTP client:

```bash theme={null}
# Create event
curl -X POST https://api.ticketnation.ph/open-api/v1/events \
  -H "api-key: tn_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Summer Music Fest 2025",
    "dateTime": "2025-06-15T18:00:00.000Z",
    "imageUrl": "https://example.com/cover.jpg",
    "tickets": [
      {"name": "GA", "price": 1500, "quantity": 500, "published": true}
    ]
  }'

# Publish
curl -X POST https://api.ticketnation.ph/open-api/v1/events/{eventId}/publish \
  -H "api-key: tn_live_your_key"

# Add a performer
curl -X POST https://api.ticketnation.ph/open-api/v1/events/{eventId}/performers \
  -H "api-key: tn_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{"name": "SB19", "type": "ARTIST"}'

# Add a schedule entry
curl -X POST https://api.ticketnation.ph/open-api/v1/events/{eventId}/schedules \
  -H "api-key: tn_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "SB19 Live",
    "startTime": "2025-06-15T20:00:00.000Z",
    "endTime": "2025-06-15T22:30:00.000Z"
  }'
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Authentication" icon="key" href="/developers/authentication">
    Scopes, IP allowlists, and webhook security
  </Card>

  <Card title="SDK Reference" icon="book" href="/developers/sdk-reference">
    Full TypeScript SDK documentation with all methods and types
  </Card>

  <Card title="API Reference" icon="code" href="/developers/api-reference">
    Complete REST endpoint documentation with curl examples
  </Card>

  <Card title="Error Handling" icon="triangle-exclamation" href="/developers/errors">
    Error codes, troubleshooting, and the error hint system
  </Card>
</CardGroup>
