---
title: Query API reference
description: Reference for log search, context, histogram, facets and patterns on the regional query API, generated from the ZevSight OpenAPI file.
url: https://docs.zevsight.com/api/reference/query
---

# Query API reference

> Reference for log search, context, histogram, facets and patterns on the regional query API, generated from the ZevSight OpenAPI file.

Search events with an engine ticket, read key or agent key.

Read endpoints for logs. Use an API key (`zsr_…`) with `read` or `respond` permission. The `q` parameter uses the [search syntax](/explore/search-syntax).

Base URL: `https://eu.zevsight.com`. Machine-readable: [/openapi.yaml](/openapi.yaml).

## Search events

`GET https://eu.zevsight.com/v1/query/logs`

Search events, newest first, with cursor paging.

**Authentication:** `Authorization: Bearer <token>` with dashboard session, or API key (`zsr_…`), or legacy agent key (`zsa_…`).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `project` | query | string | yes | One or more project public ids, comma-separated, or `all` (every project the caller may read in this region). Each named project must be readable by the caller. |
| `from` | query | string (date-time) | yes |  |
| `to` | query | string (date-time) |  | Defaults to now. |
| `env` | query | string |  | Environments to include, comma-separated (the same as `env:` terms joined by OR). |
| `q` | query | string |  | Filter expression. Grammar (draft): `service:api env:production level:>=warn "connection reset" attrs.route:/v1/* -attrs.user_id:42 trace:4bf9…` Bare words and quoted phrases match the message as tokens. A comma inside a field term means OR: `service:auth,api`, `env:production,staging`, `level:error,fatal` (exact levels only, not with >= or <=), `type:log,heartbeat`, `attrs.route:/v1/pay,/v1/cart` (a value with `*` is a wildcard, OR'd with the rest). A leading `-` negates the whole list (`-service:auth,api` = neither). `\,` is a literal comma and `\\` a literal backslash. At most 50 values per term. Up to 2000 characters. |
| `limit` | query | integer |  | Default `200`. 1 to 1000. |
| `cursor` | query | string |  | Opaque; from `next_cursor` of the previous page. |

### Responses

| Status | Description |
|---|---|
| `200` | A page of events. |
| `400` | The request, or every event in it, is invalid. |
| `401` | Missing, unknown, expired or wrong-kind credential. |
| `404` | No such object, or not visible to this credential (never 403 across tenants). |
| `421` | The credential belongs to another data region. Nothing was stored or forwarded; `endpoint` names the right host. |
| `429` | Burst limit (`RATE_LIMITED`) or monthly quota (`QUOTA_EXCEEDED`). Headers: `Retry-After`. |
| `503` | The queue is unavailable or full. Nothing was stored; retry. Headers: `Retry-After`. |

Response fields (`200`):

| Field | Type | Required | Description |
|---|---|---|---|
| `events` | array of EventOut | yes |  |
| `events[].id` | string (uuid) | yes | UUIDv7. Omit to have one generated. |
| `events[].environment` | string | yes | Default `production`. Pattern `^[a-z0-9][a-z0-9._-]{0,63}$`. |
| `events[].service` | string | yes | Default `unknown`. Pattern `^[a-z0-9][a-z0-9._-]{0,63}$`. |
| `events[].type` | string | yes | One of `log`, `heartbeat`, `check_result`. |
| `events[].ts` | string (date-time) | yes |  |
| `events[].trace_id` | string |  | Pattern `^[0-9a-f]{32}$`. |
| `events[].span_id` | string |  | Pattern `^[0-9a-f]{16}$`. |
| `events[].severity` | string |  | One of `trace`, `debug`, `info`, `warn`, `error`, `fatal`. |
| `events[].attrs` | object |  | Up to 128 keys. Map of string to string (values up to 8192 characters). |
| `events[].resource` | object |  | Up to 128 keys. Map of string to string (values up to 8192 characters). |
| `events[].body` | one of LogBody, HeartbeatBody, CheckResultBody | yes |  |
| `events[].body.message` | string | yes | (LogBody) Truncated above 64 KiB. |
| `events[].body.fields` | object |  | (LogBody) |
| `events[].body.monitor_id` | string | yes | (HeartbeatBody) |
| `events[].body.status` | string | yes | (HeartbeatBody) One of `start`, `ok`, `fail`. |
| `events[].body.duration_ms` | integer |  | (HeartbeatBody) At least 0. |
| `events[].body.note` | string |  | (HeartbeatBody) Up to 8192 characters. |
| `events[].body.check_id` | string | yes | (CheckResultBody) |
| `events[].body.region` | string | yes | (CheckResultBody) |
| `events[].body.node_id` | string | yes | (CheckResultBody) |
| `events[].body.config_version` | integer | yes | (CheckResultBody) |
| `events[].body.status` | string | yes | (CheckResultBody) One of `up`, `down`, `degraded`. |
| `events[].body.latency_ms` | integer | yes | (CheckResultBody) At least 0. |
| `events[].body.detail` | object |  | (CheckResultBody) Map of string to string. |
| `events[].body.error` | string |  | (CheckResultBody) Short reason when not up; omitted when up. |
| `events[].body.signature` | string | yes | (CheckResultBody) |
| `events[].project` | string | yes | Project public id. |
| `events[].received_at` | string (date-time) | yes |  |
| `next_cursor` | string or null |  |  |
| `stats` | object | yes |  |
| `stats.rows_scanned` | integer |  |  |
| `stats.elapsed_ms` | integer |  |  |
| `stats.truncated` | boolean |  | True when the plan's scan limit stopped the query early. The UI says so. |

### Example

```bash
curl -G https://eu.zevsight.com/v1/query/logs \
  -H "Authorization: Bearer <API_KEY>" \
  --data-urlencode "project=all" \
  --data-urlencode "from=2026-11-29T09:00:00Z" \
  --data-urlencode "to=2026-11-29T10:00:00Z" \
  --data-urlencode "q=service:api level:>=error"
```

Example response (built from the schema; values are illustrative):

```json
{
  "events": [
    {
      "id": "01937a4e-8c2f-7d3a-9b1e-4f6a2c8d0e5b",
      "environment": "production",
      "service": "api",
      "type": "log",
      "ts": "2026-11-29T09:41:07.512Z",
      "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
      "span_id": "00f067aa0ba902b7",
      "severity": "trace",
      "attrs": {
        "key": "attrs.route"
      },
      "resource": {
        "key": "attrs.route"
      },
      "body": {
        "message": "payment provider timeout after 3 retries",
        "fields": {}
      },
      "project": "prj_8KdT3mQ2wXr7nB4cVhY9p",
      "received_at": "2026-11-29T09:41:07.512Z"
    }
  ],
  "next_cursor": null,
  "stats": {
    "rows_scanned": 12,
    "elapsed_ms": 182,
    "truncated": false
  }
}
```

## Lines around an event

`GET https://eu.zevsight.com/v1/query/logs/{event_id}/context`

The lines around one event (same service, ±30 s by default).

**Authentication:** `Authorization: Bearer <token>` with dashboard session, or API key (`zsr_…`), or legacy agent key (`zsa_…`).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `event_id` | path | string (uuid) | yes |  |
| `project` | query | string | yes |  |
| `before` | query | integer |  | Default `50`. 0 to 500. |
| `after` | query | integer |  | Default `50`. 0 to 500. |

### Responses

| Status | Description |
|---|---|
| `200` | The event and its neighbours, oldest first. |
| `404` | No such object, or not visible to this credential (never 403 across tenants). |

Response fields (`200`):

| Field | Type | Required | Description |
|---|---|---|---|
| `anchor` | object |  |  |
| `anchor.id` | string (uuid) | yes | UUIDv7. Omit to have one generated. |
| `anchor.environment` | string | yes | Default `production`. Pattern `^[a-z0-9][a-z0-9._-]{0,63}$`. |
| `anchor.service` | string | yes | Default `unknown`. Pattern `^[a-z0-9][a-z0-9._-]{0,63}$`. |
| `anchor.type` | string | yes | One of `log`, `heartbeat`, `check_result`. |
| `anchor.ts` | string (date-time) | yes |  |
| `anchor.trace_id` | string |  | Pattern `^[0-9a-f]{32}$`. |
| `anchor.span_id` | string |  | Pattern `^[0-9a-f]{16}$`. |
| `anchor.severity` | string |  | One of `trace`, `debug`, `info`, `warn`, `error`, `fatal`. |
| `anchor.attrs` | object |  | Up to 128 keys. Map of string to string (values up to 8192 characters). |
| `anchor.resource` | object |  | Up to 128 keys. Map of string to string (values up to 8192 characters). |
| `anchor.body` | one of LogBody, HeartbeatBody, CheckResultBody | yes |  |
| `anchor.body.message` | string | yes | (LogBody) Truncated above 64 KiB. |
| `anchor.body.fields` | object |  | (LogBody) |
| `anchor.body.monitor_id` | string | yes | (HeartbeatBody) |
| `anchor.body.status` | string | yes | (HeartbeatBody) One of `start`, `ok`, `fail`. |
| `anchor.body.duration_ms` | integer |  | (HeartbeatBody) At least 0. |
| `anchor.body.note` | string |  | (HeartbeatBody) Up to 8192 characters. |
| `anchor.body.check_id` | string | yes | (CheckResultBody) |
| `anchor.body.region` | string | yes | (CheckResultBody) |
| `anchor.body.node_id` | string | yes | (CheckResultBody) |
| `anchor.body.config_version` | integer | yes | (CheckResultBody) |
| `anchor.body.status` | string | yes | (CheckResultBody) One of `up`, `down`, `degraded`. |
| `anchor.body.latency_ms` | integer | yes | (CheckResultBody) At least 0. |
| `anchor.body.detail` | object |  | (CheckResultBody) Map of string to string. |
| `anchor.body.error` | string |  | (CheckResultBody) Short reason when not up; omitted when up. |
| `anchor.body.signature` | string | yes | (CheckResultBody) |
| `anchor.project` | string | yes | Project public id. |
| `anchor.received_at` | string (date-time) | yes |  |
| `events` | array of EventOut |  |  |
| `events[].id` | string (uuid) | yes | UUIDv7. Omit to have one generated. |
| `events[].environment` | string | yes | Default `production`. Pattern `^[a-z0-9][a-z0-9._-]{0,63}$`. |
| `events[].service` | string | yes | Default `unknown`. Pattern `^[a-z0-9][a-z0-9._-]{0,63}$`. |
| `events[].type` | string | yes | One of `log`, `heartbeat`, `check_result`. |
| `events[].ts` | string (date-time) | yes |  |
| `events[].trace_id` | string |  | Pattern `^[0-9a-f]{32}$`. |
| `events[].span_id` | string |  | Pattern `^[0-9a-f]{16}$`. |
| `events[].severity` | string |  | One of `trace`, `debug`, `info`, `warn`, `error`, `fatal`. |
| `events[].attrs` | object |  | Up to 128 keys. Map of string to string (values up to 8192 characters). |
| `events[].resource` | object |  | Up to 128 keys. Map of string to string (values up to 8192 characters). |
| `events[].body` | one of LogBody, HeartbeatBody, CheckResultBody | yes |  |
| `events[].body.message` | string | yes | (LogBody) Truncated above 64 KiB. |
| `events[].body.fields` | object |  | (LogBody) |
| `events[].body.monitor_id` | string | yes | (HeartbeatBody) |
| `events[].body.status` | string | yes | (HeartbeatBody) One of `start`, `ok`, `fail`. |
| `events[].body.duration_ms` | integer |  | (HeartbeatBody) At least 0. |
| `events[].body.note` | string |  | (HeartbeatBody) Up to 8192 characters. |
| `events[].body.check_id` | string | yes | (CheckResultBody) |
| `events[].body.region` | string | yes | (CheckResultBody) |
| `events[].body.node_id` | string | yes | (CheckResultBody) |
| `events[].body.config_version` | integer | yes | (CheckResultBody) |
| `events[].body.status` | string | yes | (CheckResultBody) One of `up`, `down`, `degraded`. |
| `events[].body.latency_ms` | integer | yes | (CheckResultBody) At least 0. |
| `events[].body.detail` | object |  | (CheckResultBody) Map of string to string. |
| `events[].body.error` | string |  | (CheckResultBody) Short reason when not up; omitted when up. |
| `events[].body.signature` | string | yes | (CheckResultBody) |
| `events[].project` | string | yes | Project public id. |
| `events[].received_at` | string (date-time) | yes |  |

### Example

```bash
curl -G https://eu.zevsight.com/v1/query/logs/<EVENT_ID>/context \
  -H "Authorization: Bearer <API_KEY>" \
  --data-urlencode "project=all"
```

Example response (built from the schema; values are illustrative):

```json
{
  "anchor": {
    "id": "01937a4e-8c2f-7d3a-9b1e-4f6a2c8d0e5b",
    "environment": "production",
    "service": "api",
    "type": "log",
    "ts": "2026-11-29T09:41:07.512Z",
    "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
    "span_id": "00f067aa0ba902b7",
    "severity": "trace",
    "attrs": {
      "key": "attrs.route"
    },
    "resource": {
      "key": "attrs.route"
    },
    "body": {
      "message": "payment provider timeout after 3 retries",
      "fields": {}
    },
    "project": "prj_8KdT3mQ2wXr7nB4cVhY9p",
    "received_at": "2026-11-29T09:41:07.512Z"
  },
  "events": [
    {
      "id": "01937a4e-8c2f-7d3a-9b1e-4f6a2c8d0e5b",
      "environment": "production",
      "service": "api",
      "type": "log",
      "ts": "2026-11-29T09:41:07.512Z",
      "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
      "span_id": "00f067aa0ba902b7",
      "severity": "trace",
      "attrs": {
        "key": "attrs.route"
      },
      "resource": {
        "key": "attrs.route"
      },
      "body": {
        "message": "payment provider timeout after 3 retries",
        "fields": {}
      },
      "project": "prj_8KdT3mQ2wXr7nB4cVhY9p",
      "received_at": "2026-11-29T09:41:07.512Z"
    }
  ]
}
```

## Histogram

`GET https://eu.zevsight.com/v1/query/histogram`

Event counts over time, by level, for the explorer's volume chart.

Buckets are dense from the bucket containing `from` to the one
containing `to`, aligned to the epoch. The bucket size is the
smallest of 1s, 5s, 15s, 30s, 1m, 5m, 15m, 30m, 1h, 3h, 6h, 12h, 1d
(then whole days) that fits the range in at most `buckets` buckets.
Level keys are trace, debug, info, warn, error, fatal and `none`
(heartbeats and check results carry no level); zero counts are left out.

**Authentication:** `Authorization: Bearer <token>` with dashboard session, or API key (`zsr_…`), or legacy agent key (`zsa_…`).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `project` | query | string | yes | Project public ids, comma-separated, or `all`: every project the caller may read in this region. |
| `from` | query | string (date-time) | yes |  |
| `to` | query | string (date-time) |  | Defaults to now. |
| `q` | query | string |  | Same grammar as /v1/query/logs. Up to 2000 characters. |
| `env` | query | string |  | Environments to include, comma-separated (the same as `env:` terms joined by OR). |
| `buckets` | query | integer |  | Default `60`. 1 to 200. |

### Responses

| Status | Description |
|---|---|
| `200` | The histogram. |
| `400` | The request, or every event in it, is invalid. |
| `401` | Missing, unknown, expired or wrong-kind credential. |
| `404` | No such object, or not visible to this credential (never 403 across tenants). |
| `503` | The queue is unavailable or full. Nothing was stored; retry. Headers: `Retry-After`. |

Response fields (`200`):

| Field | Type | Required | Description |
|---|---|---|---|
| `bucket_seconds` | integer | yes |  |
| `buckets` | array of object | yes |  |
| `buckets[].t` | string (date-time) | yes |  |
| `buckets[].counts` | object | yes | Counts by level key (trace…fatal, none). Zero counts omitted. Map of string to integer. |
| `total` | integer | yes |  |
| `truncated` | boolean | yes |  |
| `stats` | object |  |  |
| `stats.rows_scanned` | integer |  |  |
| `stats.elapsed_ms` | integer |  |  |

### Example

```bash
curl -G https://eu.zevsight.com/v1/query/histogram \
  -H "Authorization: Bearer <API_KEY>" \
  --data-urlencode "project=all" \
  --data-urlencode "from=2026-11-29T09:00:00Z" \
  --data-urlencode "to=2026-11-29T10:00:00Z" \
  --data-urlencode "q=service:api level:>=error"
```

Example response (built from the schema; values are illustrative):

```json
{
  "bucket_seconds": 12,
  "buckets": [
    {
      "t": "2026-11-29T09:41:07.512Z",
      "counts": {
        "error": null
      }
    }
  ],
  "total": 12,
  "truncated": false,
  "stats": {
    "rows_scanned": 12,
    "elapsed_ms": 182
  }
}
```

## Facets

`GET https://eu.zevsight.com/v1/query/facets`

Value counts per field, and the most common attribute keys.

Field counts are exact over the matching rows (within the plan's scan
limit). Attribute and resource keys are counted over the newest
100,000 matching rows: only the newest slice of the range that holds
them is read (found from per-minute counts), and that read is capped
at 2,000,000 rows. `sampled` is true when there were more matching
rows, or the cap was reached.

**Authentication:** `Authorization: Bearer <token>` with dashboard session, or API key (`zsr_…`), or legacy agent key (`zsa_…`).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `project` | query | string | yes | Project public ids, comma-separated, or `all`: every project the caller may read in this region. |
| `from` | query | string (date-time) | yes |  |
| `to` | query | string (date-time) |  | Defaults to now. |
| `q` | query | string |  | Same grammar as /v1/query/logs. Up to 2000 characters. |
| `env` | query | string |  | Environments to include, comma-separated (the same as `env:` terms joined by OR). |
| `fields` | query | string |  | Comma-separated subset of project, environment, service, severity, type. Default all five. |
| `keys` | query | integer |  | How many attribute/resource keys to return; 0 skips them. Default `10`. 0 to 100. |
| `values` | query | integer |  | Values per field. Default `10`. 1 to 100. |

### Responses

| Status | Description |
|---|---|
| `200` | The facets. |
| `400` | The request, or every event in it, is invalid. |
| `401` | Missing, unknown, expired or wrong-kind credential. |
| `404` | No such object, or not visible to this credential (never 403 across tenants). |
| `503` | The queue is unavailable or full. Nothing was stored; retry. Headers: `Retry-After`. |

Response fields (`200`):

| Field | Type | Required | Description |
|---|---|---|---|
| `fields` | object | yes | Map of string to array of FacetValue. |
| `keys` | array of object | yes |  |
| `keys[].key` | string |  |  |
| `keys[].count` | integer |  |  |
| `total` | integer | yes |  |
| `sampled` | boolean | yes |  |
| `truncated` | boolean | yes |  |
| `stats` | object |  |  |
| `stats.rows_scanned` | integer |  |  |
| `stats.elapsed_ms` | integer |  |  |

### Example

```bash
curl -G https://eu.zevsight.com/v1/query/facets \
  -H "Authorization: Bearer <API_KEY>" \
  --data-urlencode "project=all" \
  --data-urlencode "from=2026-11-29T09:00:00Z" \
  --data-urlencode "to=2026-11-29T10:00:00Z" \
  --data-urlencode "q=service:api level:>=error"
```

Example response (built from the schema; values are illustrative):

```json
{
  "fields": {
    "service": "api"
  },
  "keys": [
    {
      "key": "attrs.route",
      "count": 12
    }
  ],
  "total": 12,
  "sampled": false,
  "truncated": false,
  "stats": {
    "rows_scanned": 12,
    "elapsed_ms": 182
  }
}
```

## Facet values

`GET https://eu.zevsight.com/v1/query/facets/values`

Top values of one field or attribute, optionally by prefix (autocomplete, "show more").

**Authentication:** `Authorization: Bearer <token>` with dashboard session, or API key (`zsr_…`), or legacy agent key (`zsa_…`).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `project` | query | string | yes | Project public ids, comma-separated, or `all`: every project the caller may read in this region. |
| `from` | query | string (date-time) | yes |  |
| `to` | query | string (date-time) |  | Defaults to now. |
| `q` | query | string |  | Same grammar as /v1/query/logs. Up to 2000 characters. |
| `env` | query | string |  | Environments to include, comma-separated (the same as `env:` terms joined by OR). |
| `key` | query | string | yes | project, environment, service, severity, type, `attrs.<name>` or `resource.<name>`. |
| `prefix` | query | string |  | Up to 256 characters. |
| `limit` | query | integer |  | Default `20`. 1 to 200. |

### Responses

| Status | Description |
|---|---|
| `200` | The values. |
| `400` | The request, or every event in it, is invalid. |
| `401` | Missing, unknown, expired or wrong-kind credential. |
| `404` | No such object, or not visible to this credential (never 403 across tenants). |
| `503` | The queue is unavailable or full. Nothing was stored; retry. Headers: `Retry-After`. |

Response fields (`200`):

| Field | Type | Required | Description |
|---|---|---|---|
| `key` | string | yes |  |
| `values` | array of FacetValue | yes |  |
| `values[].value` | string | yes | For project, the public id; for severity, a level key. |
| `values[].count` | integer | yes |  |
| `truncated` | boolean | yes |  |
| `sampled` | boolean |  | For `attrs.<name>` and `resource.<name>`: values were counted over the newest 500,000 matching lines (capped at 10,000,000 rows read), not the whole range. Fields (project, environment, …) are exact and never sampled. |
| `stats` | object |  |  |
| `stats.rows_scanned` | integer |  |  |
| `stats.elapsed_ms` | integer |  |  |

### Example

```bash
curl -G https://eu.zevsight.com/v1/query/facets/values \
  -H "Authorization: Bearer <API_KEY>" \
  --data-urlencode "project=all" \
  --data-urlencode "from=2026-11-29T09:00:00Z" \
  --data-urlencode "to=2026-11-29T10:00:00Z" \
  --data-urlencode "q=service:api level:>=error" \
  --data-urlencode "key=attrs.route"
```

Example response (built from the schema; values are illustrative):

```json
{
  "key": "attrs.route",
  "values": [
    {
      "value": "api",
      "count": 12
    }
  ],
  "truncated": false,
  "sampled": false,
  "stats": {
    "rows_scanned": 12,
    "elapsed_ms": 182
  }
}
```

## Patterns

`GET https://eu.zevsight.com/v1/query/patterns`

Log lines grouped by message template.

Templates replace the parts of a message that vary with
placeholders: `<uuid>`, `<time>`, `<email>`, `<ip>`, `<str>` (quoted),
`<n>` (numbers, with an optional short unit such as `ms` or `%`) and
`<hex>` (hex runs of 8 or more). Only `log` events with a message are
grouped, over the newest 200,000 matching lines: only the newest slice
of the range that holds them is read (found from per-minute counts),
capped at 4,000,000 rows read. `sampled` when there were more lines,
or the cap was reached.

**Authentication:** `Authorization: Bearer <token>` with dashboard session, or API key (`zsr_…`), or legacy agent key (`zsa_…`).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `project` | query | string | yes | Project public ids, comma-separated, or `all`: every project the caller may read in this region. |
| `from` | query | string (date-time) | yes |  |
| `to` | query | string (date-time) |  | Defaults to now. |
| `q` | query | string |  | Same grammar as /v1/query/logs. Up to 2000 characters. |
| `env` | query | string |  | Environments to include, comma-separated (the same as `env:` terms joined by OR). |
| `limit` | query | integer |  | Default `50`. 1 to 500. |

### Responses

| Status | Description |
|---|---|
| `200` | The patterns, most frequent first. |
| `400` | The request, or every event in it, is invalid. |
| `401` | Missing, unknown, expired or wrong-kind credential. |
| `404` | No such object, or not visible to this credential (never 403 across tenants). |
| `503` | The queue is unavailable or full. Nothing was stored; retry. Headers: `Retry-After`. |

Response fields (`200`):

| Field | Type | Required | Description |
|---|---|---|---|
| `patterns` | array of object | yes |  |
| `patterns[].pattern` | string | yes |  |
| `patterns[].count` | integer | yes |  |
| `patterns[].levels` | object | yes | Map of string to integer. |
| `patterns[].first_seen` | string (date-time) | yes |  |
| `patterns[].last_seen` | string (date-time) | yes |  |
| `patterns[].sample_id` | string (uuid) | yes |  |
| `patterns[].sample` | string | yes | The newest line with this pattern. |
| `total` | integer | yes | Matching log lines in the range (lines with an empty message included, though they are not grouped). |
| `sampled` | boolean | yes |  |
| `truncated` | boolean | yes |  |
| `stats` | object |  |  |
| `stats.rows_scanned` | integer |  |  |
| `stats.elapsed_ms` | integer |  |  |

### Example

```bash
curl -G https://eu.zevsight.com/v1/query/patterns \
  -H "Authorization: Bearer <API_KEY>" \
  --data-urlencode "project=all" \
  --data-urlencode "from=2026-11-29T09:00:00Z" \
  --data-urlencode "to=2026-11-29T10:00:00Z" \
  --data-urlencode "q=service:api level:>=error"
```

Example response (built from the schema; values are illustrative):

```json
{
  "patterns": [
    {
      "pattern": "payment provider timeout after <n> retries",
      "count": 12,
      "levels": {
        "error": null
      },
      "first_seen": "2026-11-29T09:41:07.512Z",
      "last_seen": "2026-11-29T09:41:07.512Z",
      "sample_id": "01937a4e-8c2f-7d3a-9b1e-4f6a2c8d0e5b",
      "sample": "payment provider timeout after 3 retries"
    }
  ],
  "total": 12,
  "sampled": false,
  "truncated": false,
  "stats": {
    "rows_scanned": 12,
    "elapsed_ms": 182
  }
}
```
