---
title: "Save a log search for a project."
method: POST
path: "/projects/{project_id}/logs/saved-searches"
tags: ["Logs"]
---

# Save a log search for a project.

`POST /projects/{project_id}/logs/saved-searches`

## Request

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

## Path parameters

- `project_id` integer, required

## Request body

- CreateSavedSearchRequest
  - `description` string, nullable
  - `name` string, required: Unique within the project.
  - `pinned` boolean: Pinned searches sort first. Default false.
  - `query` SavedSearchQuery: The filter set. An empty query is allowed: "everything in this project" is a legitimate thing to pin.
    - `attrs` string[]: Attribute predicates in the wire form the search endpoints take: `<key><op><value>` with `op` one of `=`, `!=`, `^=`, `>`, `<`, or `<key>?` for "exists".
    - `container_ids` string[]
    - `deploy_id` integer, nullable
    - `envs` string[]: Environment identifiers as the store holds them.
    - `external_service_ids` integer[]: Narrow to these of the project's external services (databases, imported services). Empty means every source allowed by `source`.
    - `levels` LogLevel[]
    - `node_ids` integer[]
    - `services` string[]: Container service labels (`web`, `worker`).
    - `source` 'collected' | 'application' | 'service': Which family of sources to search: everything the project has (`collected`), its application containers, or its databases.
    - `text` string, nullable: Case-insensitive substring match over the message.
  - `time_range` string, nullable: One of `15m`, `1h`, `6h`, `24h`, `7d`, `30d`. Default `1h`.

## Response `201`

Saved search created

- SavedSearchResponse
  - `alert_count` integer, required: Log alert rules counting this search. A search with alerts cannot be deleted until they are detached, so the console can say so before offering the button.
  - `created_at` string, date-time, required
  - `created_by` integer, nullable
  - `description` string, nullable
  - `id` integer, required
  - `name` string, required
  - `pinned` boolean, required
  - `project_id` integer, required
  - `query` SavedSearchQuery, required: The stored filter set of a saved search. Mirrors `GlobalLogSearchRequest` without `start_time`/`end_time`, `cursor`, `page_size` and the project selector: the window is the caller's and the project is the row's. External services are held as ids rather than names so counting a saved search needs no control-plane name resolution.
    - `attrs` string[]: Attribute predicates in the wire form the search endpoints take: `<key><op><value>` with `op` one of `=`, `!=`, `^=`, `>`, `<`, or `<key>?` for "exists".
    - `container_ids` string[]
    - `deploy_id` integer, nullable
    - `envs` string[]: Environment identifiers as the store holds them.
    - `external_service_ids` integer[]: Narrow to these of the project's external services (databases, imported services). Empty means every source allowed by `source`.
    - `levels` LogLevel[]
    - `node_ids` integer[]
    - `services` string[]: Container service labels (`web`, `worker`).
    - `source` 'collected' | 'application' | 'service': Which family of sources to search: everything the project has (`collected`), its application containers, or its databases.
    - `text` string, nullable: Case-insensitive substring match over the message.
  - `time_range` string, required
  - `updated_at` string, date-time, required

## Other responses

- `400`: Validation error
- `401`: Unauthorized
- `403`: Insufficient permissions
- `409`: Name taken or limit reached
- `500`: Internal server error

## Changes

- **2026-11-21** `d57a37c13a27`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/projects/:project_id/logs/saved-searches/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)
