---
title: "Search logs with structured filters and full text search"
method: POST
path: "/logs/search"
tags: ["Logs"]
---

# Search logs with structured filters and full text search

`POST /logs/search`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/logs/search`
- Auth: HTTP bearer

## Request body

- SearchLogsRequest
  - `container_ids` string[]: Filter to specific containers (Docker container IDs). Empty = all containers. Drives "filter by container / show all" in a project's history, which spans multiple deployments and containers.
  - `context_lines` integer, nullable: grep -C: number of raw context lines to include before and after each match (0 = none, default). Clamped to 50 server-side. The surrounding lines ignore the level/text filters — they are the actual adjacent log lines, merged across overlapping matches.
  - `cursor` string, nullable: Pagination cursor
  - `deploy_id` integer, nullable: Filter by deployment ID (deployments.id)
  - `end_time` string, nullable: End of time range (ISO 8601). Defaults to now.
  - `envs` string[]: Filter by environments
  - `external_service_id` integer, nullable: When set, search an imported/managed external service's logs instead of a project's. `project_id` is ignored in this mode.
  - `levels` string[]: Filter by log levels
  - `node_ids` integer[]: Filter to specific worker nodes (node_id). Empty = all nodes, including control-plane-local logs.
  - `page_size` integer, nullable: Page size (default: 100, max: 500)
  - `project_id` integer, required: Project ID (integer, as used by the rest of the platform)
  - `services` string[]: Filter by services
  - `start_time` string, nullable: Start of time range (ISO 8601). Defaults to 1 hour ago.
  - `text` string, nullable: Full text search query

## Response `200`

Search results

- SearchLogsResponse
  - `available_sources` LogSource[]: Distinct containers/nodes/services available in the queried scope, for the filter dropdowns. Populated on the first page (no cursor).
    - `container_id` string, required
    - `node_id` integer, nullable
    - `node_name` string, nullable
    - `service` string, required
  - `lines` LogSearchLine[], required
    - `container_id` string: Container this line came from — lets the UI tag/group lines by container in a combined ("show all") multi-container view, and is the second component of the line's identity.
    - `context` LineContext, nullable: Raw surrounding lines for a single match (grep -C style).
      - `after` ContextLine[], required: Lines immediately after the match, oldest-first.
        - `fields` unknown
        - `is_match` boolean, required: Whether this line matched the original search
        - `level` 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR', required: Normalized log level
        - `line_id` string, required: Decimal string form of this line's `line_id` — see [`LogSearchLine`].
        - `message` string, required
        - `timestamp` string, required
      - `before` ContextLine[], required: Lines immediately before the match, oldest-first.
        - `fields` unknown
        - `is_match` boolean, required: Whether this line matched the original search
        - `level` 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR', required: Normalized log level
        - `line_id` string, required: Decimal string form of this line's `line_id` — see [`LogSearchLine`].
        - `message` string, required
        - `timestamp` string, required
    - `deploy_id` integer, nullable
    - `fields` unknown
    - `level` 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR', required: Normalized log level
    - `line_id` string, required: Decimal string form of the line's `line_id`. See the type docs.
    - `message` string, required
    - `node_id` integer, nullable: Worker node the line came from (`None` = control-plane-local).
    - `node_name` string, nullable: Human-readable node name for display.
    - `service` string, required
    - `stream` 'stdout' | 'stderr', required: stdout or stderr.
    - `timestamp` string, required
  - `next_cursor` string, nullable: Opaque keyset cursor for the next (older) page. Stays populated on a partial page — that's the whole point: the user can press Next to keep searching.
  - `partial` boolean: `true` when the store's time/byte budget ran out before this page could be proven complete.
  - `scanned_back_to` string, nullable: Set when `partial` is `true`: every chunk ending after this timestamp has been searched, nothing older has yet.

## Other responses

- `400`: Invalid search parameters
- `401`: Unauthorized
- `500`: Internal server error

## Changes

- **2026-11-09** `12896146b193`: 3 breaking
  - removed the required property `extensions` from the response with the `400` status
  - removed the required property `extensions` from the response with the `401` status
  - removed the required property `extensions` from the response with the `500` status
- **2026-10-05** `4b228ebed583`: 6 breaking, 9 info
  - removed the required property `lines/items/chunk_id` from the response with the `200` status
  - removed the required property `lines/items/context/oneOf[#/components/schemas/LineContext]/after/items/line_offset` from the response with the `200` status
  - removed the required property `lines/items/context/oneOf[#/components/schemas/LineContext]/before/items/line_offset` from the response with the `200` status
  - removed the required property `lines/items/line_offset` from the response with the `200` status
  - …11 more
- **2026-10-05** `63a80791dc58`: 4 breaking, 5 warning, 6 info
  - removed the required property `lines/items/context/oneOf[#/components/schemas/LineContext]/after/items/line_id` from the response with the `200` status
  - removed the required property `lines/items/context/oneOf[#/components/schemas/LineContext]/before/items/line_id` from the response with the `200` status
  - removed the required property `lines/items/line_id` from the response with the `200` status
  - removed the required property `lines/items/stream` from the response with the `200` status
  - …11 more
- …earlier changes not shown

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/logs/search/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
