---
type: api
title: Get saved queries
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-osqueryfindsavedqueries
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-osqueryfindsavedqueries
products:
  - Kibana
---

# Get saved queries

- Server: `https://{kibana_url}`

## Paths

- `GET` `/api/osquery/saved_queries`
- `GET` `/s/{space_id}/api/osquery/saved_queries`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/kibana/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/kibana/authentication#basicauth)

## Description

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

Get a list of all saved queries.

## Query String Parameters

- `page` (integer)
  The page number to return.
- `pageSize` (integer)
  The number of results to return per page.
- `sort` (string · default: createdAt)
  The field to sort results by.
- `sortOrder` (enum)
  The sort order.
  Values: `asc`, `desc`

## Response

Indicates a successful call.

`application/json`

- `data` ([] object)
  An array of saved query objects.
  - `created_at` (string)
  - `created_by` (string) — nullable
  - `created_by_profile_uid` (string)
  - `description` (string)
    The saved query description.
  - `ecs_mapping` (object)
    Map osquery results columns or static values to Elastic Common Schema (ECS) fields
  - `id` (string)
    The ID of a saved query.
  - `interval` (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)
  - `snapshot` (boolean)
    Indicates whether the query is a snapshot.
  - `timeout` (integer)
  - `updated_at` (string)
  - `updated_by` (string) — nullable
  - `updated_by_profile_uid` (string)
  - `version` (integer | string)
- `page` (integer)
  The current page number.
- `per_page` (integer)
  The number of results per page.
- `total` (integer)
  The total number of saved queries.
## Code Examples

#### Console

```console
GET /api/osquery/saved_queries
```

#### curl

```curl
curl -X GET "https://{kibana_url}/api/osquery/saved_queries"
```

## Response Examples

#### A list of saved queries

```json
{
  "data": [
    {
      "created_at": "2025-02-26T13:37:30.452Z",
      "created_by": "elastic",
      "description": "Saved query description",
      "ecs_mapping": {
        "host.uptime": {
          "field": "total_seconds"
        }
      },
      "id": "my_saved_query",
      "interval": "60",
      "platform": "linux,darwin",
      "query": "select * from uptime;",
      "saved_object_id": "42ba1280-2172-11ee-8523-5765fca79a3c",
      "timeout": 120,
      "updated_at": "2025-02-26T13:37:30.452Z",
      "updated_by": "elastic"
    }
  ],
  "page": 1,
  "per_page": 20,
  "total": 1
}
```

