# Open a ticket

`POST https://evohub.io/api/v1/support/tickets`

Part of the [Support API](https://docs.evohub.io/support.md) reference · operationId `createTicket`.

Opens a ticket. `body` becomes the first message of the
conversation. A new ticket's `status` is `open`.

- `subject` and `body` are required (surrounding spaces are trimmed);
  `subject` is at most 200 characters.
- `type` is `support` (the default), `bug`, `feature` or `question`.
- `priority` is `low`, `normal` (the default), `high` or `urgent`.
- `reporter_email`, `reporter_name`, `org_name` and `url` are stored
  as sent, to tell the support team who to answer and where the
  problem was seen. They are optional.

Requires no scope.

## Authorization

Any one of:

- `bearerKey`
- `headerKey`

Where:

- `bearerKey`: HTTP Bearer — An EvoHub API key (`evohub_…`) as a bearer token.
- `headerKey`: API key in the header `X-API-Key` — An EvoHub API key (`evohub_…`).

## Request body (required)

Content type: `application/json`

Type: `CreateTicketRequest`

- `subject` (string, required, max length 200)
- `body` (string, required): The first message of the conversation.
- `type` (string, one of `support`, `bug`, `feature`, `question`, default `support`)
- `priority` (string, one of `low`, `normal`, `high`, `urgent`, default `normal`)
- `reporter_email` (string)
- `reporter_name` (string)
- `org_name` (string)
- `url` (string): The page or resource the ticket is about.

## Responses

### 201 — The ticket was opened.

Content type: `application/json`

Type: `object`

- `success` (boolean, value `true`)
- `data` (Ticket)
  - `id` (string, example `tkt_3f9a1c2e7b5d4a60`)
  - `org_id` (string)
  - `user_id` (string): Who opened the ticket — the person behind a personal key, or the organization key's own id.
  - `subject` (string)
  - `type` (string, one of `support`, `bug`, `feature`, `question`)
  - `status` (string, one of `open`, `pending`, `resolved`, `closed`): `open` when new or after the caller replies. EvoHub support moves it to `pending`, `resolved` or `closed`.
  - `priority` (string, one of `low`, `normal`, `high`, `urgent`)
  - `reporter_email` (string): As sent when the ticket was opened; `""` when it was not.
  - `reporter_name` (string)
  - `org_name` (string)
  - `url` (string)
  - `created_at` (string (date-time))
  - `updated_at` (string (date-time))

### 400 — The body is not JSON (`INVALID_JSON`), or a field breaks a rule (`VALIDATION_ERROR`; the message names it): `subject` or `body` is missing or blank, `type` or `priority` is not one of the allowed values, or `subject` is longer than 200 characters (this one also carries `details` naming the field).

Content type: `application/json`

Type: `Error | ValidationFailed`

- One of:
  - Error
    - `success` (boolean, value `false`): Sent by Support; the gateway's own refusals leave it out.
    - `error` (object, required)
      - `code` (string, required, example `NOT_FOUND`)
      - `message` (string, required, example `ticket not found`)
      - `request_id` (string)
  - ValidationFailed
    - `success` (boolean, value `false`)
    - `error` (object, required)
      - `code` (string, required, value `VALIDATION_ERROR`)
      - `message` (string, required)
      - `details` (array of object, required)
        - `field` (string)
        - `message` (string)
      - `request_id` (string)

### 401 — No API key was sent, or it is unknown, revoked or expired (`UNAUTHORIZED`).

Content type: `application/json`

Type: `Error`

- `success` (boolean, value `false`): Sent by Support; the gateway's own refusals leave it out.
- `error` (object, required)
  - `code` (string, required, example `NOT_FOUND`)
  - `message` (string, required, example `ticket not found`)
  - `request_id` (string)

### 429 — Too many requests (`RATE_LIMITED`). Wait for `Retry-After` seconds.

Headers:

- `Retry-After` (integer): Seconds to wait before retrying.

Content type: `application/json`

Type: `Error`

- `success` (boolean, value `false`): Sent by Support; the gateway's own refusals leave it out.
- `error` (object, required)
  - `code` (string, required, example `NOT_FOUND`)
  - `message` (string, required, example `ticket not found`)
  - `request_id` (string)

### 500 — Something went wrong on EvoHub's side (`INTERNAL_ERROR`). Retry later.

Content type: `application/json`

Type: `Error`

- `success` (boolean, value `false`): Sent by Support; the gateway's own refusals leave it out.
- `error` (object, required)
  - `code` (string, required, example `NOT_FOUND`)
  - `message` (string, required, example `ticket not found`)
  - `request_id` (string)

## Example request

```bash
curl -X POST 'https://evohub.io/api/v1/support/tickets' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <TOKEN>' \
  -d '{
  "url": "https://evohub.io/oncall/integrations",
  "body": "Alerts from our Prometheus integration arrive 5–10 minutes late\nsince about 07:30 UTC. Request id of one late delivery:\nreq_9a8b7c6d5e4f3a2b.\n",
  "type": "bug",
  "subject": "Webhook deliveries delayed since this morning",
  "org_name": "Acme",
  "priority": "high",
  "reporter_name": "Dana Ops",
  "reporter_email": "ops@acme.example"
}'
```
