---
title: "Update a saved query"
method: PUT
path: "/api/osquery/saved_queries/{id}"
tags: ["Security Osquery API"]
---

# Update a saved query

`PUT /api/osquery/saved_queries/{id}`

**Spaces method and path for this operation:**

<div><span class="operation-verb put">put</span>&nbsp;<span class="operation-path">/s/{space_id}/api/osquery/saved_queries/{id}</span></div>

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

Update a saved query using the query ID.
> info
> You cannot update a prebuilt saved query.

## Path parameters

- `id` string, required — The ID of a saved query.

## Request body

- SecurityOsqueryAPIUpdateSavedQueryRequestBody
  - `description` string — The saved query description.
  - `ecs_mapping` SecurityOsqueryAPIECSMapping — Map osquery results columns or static values to Elastic Common Schema (ECS) fields
  - `id` string — The ID of a saved query.
  - `interval` string — An interval, in seconds, on which to run the query.
  - `platform` string — Restricts the query to a specified platform. The default is all platforms. To specify multiple platforms, use commas. For example, `linux,darwin`.
  - `query` string — The SQL query you want to run.
  - `removed` boolean — Indicates whether the query is removed.
  - `snapshot` boolean — Indicates whether the query is a snapshot.
  - `version` string — Uses the Osquery versions greater than or equal to the specified version string.

## Response `200`

Indicates a successful call.

- SecurityOsqueryAPIUpdateSavedQueryResponse — The response for updating a saved query.
  - `data` object, required
    - `created_at` string, date-time
    - `created_by` string, nullable
    - `created_by_profile_uid` string
    - `description` string — The saved query description.
    - `ecs_mapping` SecurityOsqueryAPIECSMapping — Map osquery results columns or static values to Elastic Common Schema (ECS) fields
    - `id` string, required — The ID of a saved query.
    - `interval` union
      - integer
      - string
    - `platform` string — Restricts the query to a specified platform. The default is all platforms. To specify multiple platforms, use commas. For example, `linux,darwin`.
    - `prebuilt` boolean
    - `query` string — The SQL query you want to run.
    - `removed` boolean — Indicates whether the query is removed.
    - `saved_object_id` string, required
    - `snapshot` boolean — Indicates whether the query is a snapshot.
    - `timeout` integer
    - `updated_at` string, date-time
    - `updated_by` string, nullable
    - `updated_by_profile_uid` string
    - `version` string — The saved query version.

---

[API](https://skmtc.net/elastic/apis/kibana-apis.md) · [All operations](https://skmtc.net/elastic/apis/kibana-apis/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/elastic/kibana-apis/versions/531c9e2a7d23/schema)
