---
title: "Search an index"
---

> Documentation Index
> Fetch the complete documentation index at: https://sandrinodm.github.io/logbrook/llms.txt
> Use this file to discover all available pages before exploring further.

# Search an index

Path: Logbrook API › Logs

`GET /indexes/{index}/logs`

Returns matching events, newest first by event time. `next_cursor` is bound to this index and query.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `index` (`searchLogs.path.index`; string, required) — Index name: lowercase letters, digits, underscores and hyphens. The token's index scope applies as well as its source scope.
  - minLength 1; maxLength 63; pattern `^[a-z0-9][a-z0-9_-]*$`

## Query parameters

- `from` (`searchLogs.query.from`; integer, required) — Inclusive Unix milliseconds
- `to` (`searchLogs.query.to`; integer, required) — Exclusive Unix milliseconds
- `source` (`searchLogs.query.source`; string, optional) — Comma-separated sources. Defaults to every source the token can read.
- `service` (`searchLogs.query.service`; string, optional) — Exact service
- `logger` (`searchLogs.query.logger`; string, optional) — Exact logger
- `host` (`searchLogs.query.host`; string, optional) — Exact host
- `message` (`searchLogs.query.message`; string, optional) — Literal message substring
- `min_level` (`searchLogs.query.min_level`; integer, optional) — Minimum numeric severity
- `limit` (`searchLogs.query.limit`; integer, optional) — Page size, 1 to configured maximum
- `cursor` (`searchLogs.query.cursor`; string, optional) — `next_cursor` from the previous page, at most 1024 bytes. Send it with the same index, range, filters and limit; anything else returns `400`.
  - maxLength 1024
- `filter` (`searchLogs.query.filter`; unknown, optional) — URL-encoded JSON, at most 4096 bytes decoded. Exact, typed matches on top-level attributes; every condition must match, along with the other filters. Missing and null values never match. Duplicate or unknown members and conflicting conditions return `400`. The request path and query together are limited to 32768 bytes.

## Code samples

### cURL

```bash
curl --request GET \
  --url '<base-url>/indexes/payments/logs?from=1794297360000&to=1794297480000' \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = '<base-url>/indexes/payments/logs?from=1794297360000&to=1794297480000';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/indexes/payments/logs?from=1794297360000&to=1794297480000"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
```

## Responses

### 200

Successful response

#### Example

```json
{
  "events": [
    {
      "id": "4",
      "source": "checkout",
      "event_time": 1794297423000,
      "received_at": 1794297537909,
      "level": 30,
      "service": "checkout-api",
      "logger": "refunds",
      "host": "web-2",
      "pid": 3920,
      "message": "refund issued",
      "attributes": {
        "orderId": "ord_8f3k4"
      }
    },
    {
      "id": "3",
      "source": "checkout",
      "event_time": 1794297421200,
      "received_at": 1794297537874,
      "level": 50,
      "service": "checkout-api",
      "logger": "payments",
      "host": "web-2",
      "pid": 3920,
      "message": "payment declined",
      "attributes": {
        "orderId": "ord_8f3k4",
        "reason": "insufficient_funds"
      }
    }
  ],
  "next_cursor": "payments:v1.eyJ2IjoxLCJraW5kIjoic2VhcmNoIiwicXVlcnkiOiI2YjcwZTkxZWY2MjRjMWRlZmI2NWZhZjI2MGUxODRkODgyM2I1ZWExZTc5Zjg4MGVkZWVjY2I3ZTIyNTJjMTU2IiwiaGlnaCI6IjUiLCJ0aW1lIjoiMTc5NDI5NzQyMTIwMCIsImlkIjoiMyJ9"
}
```

- `events` (`searchLogs.response.200.events`; array<object>, required)
  - `id` (`searchLogs.response.200.events.id`; string, required)
  - `source` (`searchLogs.response.200.events.source`; string, required)
  - `event_time` (`searchLogs.response.200.events.event_time`; integer, required)
  - `received_at` (`searchLogs.response.200.events.received_at`; integer, required)
  - `level` (`searchLogs.response.200.events.level`; integer, required)
  - `message` (`searchLogs.response.200.events.message`; string, required)
  - `attributes` (`searchLogs.response.200.events.attributes`; object, required)
  - `service` (`searchLogs.response.200.events.service`; string | null, optional)
  - `logger` (`searchLogs.response.200.events.logger`; string | null, optional)
  - `host` (`searchLogs.response.200.events.host`; string | null, optional)
  - `pid` (`searchLogs.response.200.events.pid`; integer | null, optional)
- `next_cursor` (`searchLogs.response.200.next_cursor`; string | null, required)

### 400

Invalid input

#### Example

```json
{
  "error": "invalid or excessive half-open time range"
}
```

- `error` (`searchLogs.response.400.error`; string, required)

### 401

Missing or invalid token

#### Example

```json
{
  "error": "Bearer token required"
}
```

- `error` (`searchLogs.response.401.error`; string, required)

### 403

Source outside read scope

#### Example

```json
{
  "error": "source outside read scope"
}
```

- `error` (`searchLogs.response.403.error`; string, required)

### 404

Index not found

#### Example

```json
{
  "error": "unknown index"
}
```

- `error` (`searchLogs.response.404.error`; string, required)

### 413

Payload exceeds configured budget

#### Example

```json
{
  "error": "query response exceeds byte budget"
}
```

- `error` (`searchLogs.response.413.error`; string, required)

### 429

Capacity exhausted; Retry-After: 1

#### Example

```json
{
  "error": "HTTP capacity exhausted"
}
```

- `error` (`searchLogs.response.429.error`; string, required)

### 503

Storage unavailable

#### Example

```json
{
  "error": "storage unavailable"
}
```

- `error` (`searchLogs.response.503.error`; string, required)

### 504

Query deadline expired

#### Example

```json
{
  "error": "query deadline exceeded"
}
```

- `error` (`searchLogs.response.504.error`; string, required)


Source: https://sandrinodm.github.io/logbrook/api/logs/search/index.md
