# Report tickets by field

```http
GET https://trydimmi.com/api/v1/reports/tickets/by-field
```

## Authorization

Send an API token as `Authorization: Bearer <token>`.
The token needs: `tickets:read`.

## Query parameters

- `type_id` (string, required): A type id from GET /ticket-types.
- `field` (string, required): The key of one of the type's fields.
- `from` (string): First day, 2006-01-02.
- `to` (string): Last day included, 2006-01-02.

## Response 200 (OK)

- `data` (object, required)
  - `data_type` (string, required): The reported field's type: short_text, long_text, number, decimal, currency, boolean, date, single_choice, multiple_choice, file, member or company.
  - `field` (string, required): Key of the reported field, such as order_number.
  - `label` (string, required): The reported field's name as people see it.
  - `type_id` (string, required): Id of the ticket type the field belongs to, such as tktt_....
  - `values` (object[] | null, required): One row per value the field holds, each with how many tickets hold it and how many of those are resolved.
    - `resolved` (integer, required): How many of the tickets holding this value are resolved.
    - `tickets` (integer, required): How many tickets hold this value.
    - `value` (string | null, required): The field value being counted, as text. Null for the tickets that have no value for the field.

## Response default (Error)

- `code` (string, required): Stable code for programs to tell errors apart, such as validation_failed or internal_error.
- `errors` (object): Each rejected field mapped to its messages. Only present when the input was invalid.
- `message` (string, required): What went wrong, in words safe to show a person.

## Example request

```bash
curl --request GET \
  --url 'https://trydimmi.com/api/v1/reports/tickets/by-field?type_id=<type_id>&field=<field>' \
  --header 'Authorization: Bearer <token>'
```

## Example response

```json
{
  "data": {
    "data_type": "<string>",
    "field": "<string>",
    "label": "<string>",
    "type_id": "<string>",
    "values": [
      {
        "resolved": 123,
        "tickets": 123,
        "value": "<string>"
      }
    ]
  }
}
```

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
