# Tickets API

October 18, 2024

## Overview

The Tickets API allows you to interact with tickets associated with bookings on the AnyRoad platform. You can verify tickets to see if they are valid, and you can also scan a ticket (actually check-in a guest) using the endpoints provided below.

## Endpoints

- **Verify Tickets -** Verify the validity of a ticket using its QR code without recording a scan event. Useful for checking ticket validity before performing an action.
- **Scan Tickets -** Scan a ticket using its QR code. This action records a scan event for the ticket and returns the ticket information.

# Verify Tickets

### Endpoint
```
POST /tickets/verify
```

### Description

Verify the validity of a ticket using its QR code without recording a scan event. Useful for checking ticket validity before performing an action.

### Request Body Parameters
- **qr_code** (string, required): The QR code of the ticket to be verified.

### Request Body Example
```
{   "qr_code": "QR_CODE_STRING" }
```

### Responses

#### 200 OK

Returns the ticket information if the ticket is valid.

**Response Body Example:**
```
{   "url": "string",   "next_url": "string",   "previous_url": "string",   "first_url": "string",   "items": [     {       "type": "guest",       "qr_code": "string",       "experience": "string",       "booking": "string",       "guest": "string",       "time_slot": {         "local_datetime_start": "2019-08-24T14:15:22Z",         "local_datetime_end": "2019-08-24T14:15:22Z"       },       "scans": [         {           "device": "string",           "scanned_at": "2019-08-24T14:15:22Z"         }       ],       "id": "string",       "created": "2019-08-24T14:15:22Z",       "updated": "2019-08-24T14:15:22Z"     }   ] }
```

#### 400 Bad Request

The request was malformed or invalid.

Possible error responses include:

- **MalformedProblem**: Incorrect parameters provided.

**Error Response Example:**
```
{   "type": "https://example.com/error-type",   "title": "Incorrect parameters provided",   "status": 400,   "detail": "limit value 'abc' must be an integer",   "code": "limit_out_of_range",   "instance": "/path",   "request_id": "5f7e0797-7a42-4807-afaa-3efb80c8423a" }
```

- **TicketVerifyActionBookingCanceledError**: The booking associated with the ticket has been canceled.
- **TicketVerifyActionBookingInPastError**: The booking is in the past and the ticket is no longer valid.
- **TicketVerifyActionBookingInFutureError**: The booking is in the future and the ticket is not yet valid.

#### 401 Unauthorized

Invalid or missing authentication token.

#### 500 Internal Server Error

An unexpected error occurred on the server.

# Ticket Resource Structure

## TicketItemResource

Represents an individual ticket.

### **Properties:**
- **id** (string): Unique identifier of the ticket.
- **type** (string): The type of ticket. Possible values are guest or addon.
- **qr_code** (string): The QR code associated with the ticket.
- **experience** (string): URL to the associated experience.
- **booking** (string): URL to the associated booking.
- **guest** (string): URL to the guest associated with the ticket.
- **time_slot** (object): The time slot details.
  - **local_datetime_start** (string): Start date and time of the time slot in local timezone.
  - **local_datetime_end** (string): End date and time of the time slot in local timezone.
- **scans** (array): List of scan events associated with the ticket.
  - **device** (string): Identifier of the device that performed the scan.
  - **scanned_at** (string): The date and time when the scan occurred.
- **created** (string): The date and time when the ticket was created.
- **updated** (string): The date and time when the ticket was last updated.

# Scan Tickets

## Endpoint
```
POST /tickets/scan
```

## Description

Scan a ticket using its QR code. This action records a scan event for the ticket and returns the ticket information.

## Request Body Parameters
- **device** (string, required): The identifier of the device performing the scan.
- **qr_code** (string, required): The QR code of the ticket to be scanned.

## Request Body Example
```
{   "device": "string",   "qr_code": "string" }
```

## Responses

### 200 OK

Returns the ticket information after a successful scan.

### 400 Bad Request

The request was malformed or invalid.

### 401 Unauthorized

Invalid or missing authentication token.

### 500 Internal Server Error

An unexpected error occurred on the server.

# Authentication

All requests to the Tickets API require authentication using a valid bearer token in the Authorization header:
```
Authorization: Bearer YOUR_ACCESS_TOKEN
```

**Note:** Replace placeholder values like YOUR_ACCESS_TOKEN, QR_CODE_STRING, request_id, and URLs with actual values when making requests.

If you have any additional questions, you can contact our Customer Experience team via chat or at [support@anyroad.com](mailto:support@anyroad.com).
