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

# Creating a Ticket

> Create a new ticket by adding a visitor to a queue line.

To create a ticket, send a POST request to `/tickets`:

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.qminder.com/tickets \
    -H "X-Qminder-REST-API-Key: YOUR_API_KEY" \
    -H "X-Qminder-API-Version: 2020-09-01" \
    -H "Content-Type: application/json" \
    -d '{
      "lineId": "12345",
      "firstName": "John",
      "lastName": "Doe",
      "phoneNumber": "+12125551234",
      "email": "john@example.com"
    }'
  ```

  ```typescript TypeScript theme={null}
  import { Qminder } from 'qminder-api';
  Qminder.setKey('YOUR_API_KEY');

  const ticket = await Qminder.Ticket.create({
    lineId: '12345',
    firstName: 'John',
    lastName: 'Doe',
    phoneNumber: '+12125551234',
    email: 'john@example.com',
  });
  console.log(ticket.id); // "226859"
  ```
</CodeGroup>

**Required fields:**

* `lineId` - ID of the line to create the ticket in
* `firstName` - Visitor's first name (2-50 characters)

**Optional fields:**

* `lastName` - Visitor's last name (max 50 characters)
* `phoneNumber` - Phone number with optional + prefix (5-20 digits)
* `email` - Visitor's email address (max 100 characters)
* `languageCode` - Language code, e.g. "en", "es" (2-5 characters, default: "en")
* `source` - MANUAL, NAME, or MICROSITE (default: MANUAL)
* `fields` - Array of custom input fields with `inputFieldId` (UUID) and `value` (max 500 characters) or `optionIds`
* `labels` - Array of labels with `value`

**Response (201 Created):**

```json theme={null}
{
  "id": "226859",
  "publicId": "A-42"
}
```

### Input Fields

To use the `fields` parameter, you first need to discover the available input field IDs for the location. See the [Input Fields query](/reference/queries/input-fields) for details.

### Error Responses

| Status | Description                               | Example                                                                   |
| ------ | ----------------------------------------- | ------------------------------------------------------------------------- |
| 400    | Validation failed                         | `{"statusCode": 400, "message": "First name must not be empty or blank"}` |
| 404    | Line, input fields, or language not found | `{"message": "Line with id 123456 not found"}`                            |
| 409    | Target line is disabled or archived       | `{"message": "Line with id 789 is disabled"}`                             |
