---
type: api
title: Bulk update queries
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v9/operation/operation-post-streams-name-queries-bulk
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v9/operation/operation-post-streams-name-queries-bulk
products:
  - Kibana
---

# Bulk update queries

deprecated

Availability: Experimental since 9.1

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

## Paths

- `POST` `/api/streams/{name}/queries/_bulk`
- `POST` `/s/{space_id}/api/streams/{name}/queries/_bulk`

#### Path parameters

- `name` (string · max length: 255) — required
  The name of the stream.

## Description

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

Bulk update queries of a stream. Can add new queries and delete existing ones.

## Required authorization

- Privileges: `manage_stream`

## Authentication

- Api key: `Authorization: <value>`
  These APIs use key-based authentication. You must create an API key and use the encoded value in the request header. For example: `Authorization: ApiKey base64AccessApiKey`
- Basic: `Authorization: Basic <credentials>`

## Header parameters

- `kbn-xsrf` (string) — required
  A required header to protect against CSRF attacks

## Request body

`application/json`

- `operations` (union anyOf[]) — required
  - **{ index }**
    - `index` (object) — required
      - `description` (string · max length: 10000) — optional
      - `esql` (object) — required
        - `query` (string · max length: 10000) — required
      - `evidence` (string[]) — optional
      - `expires_at` (string · format: date-time · pattern: ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$) — optional
      - `id` (string · min length: 1) — required
        A non-empty string.
      - `severity_score` (number) — optional
      - `title` (string · min length: 1) — required
        A non-empty string.
  - **{ delete }**
    - `delete` (object) — required
      - `id` (string · max length: 255) — required

## Response

Bulk operation completed successfully.

## Code examples

#### Console

```console
POST kbn:/api/streams/NAME/queries/_bulk
{
  "operations": [
    {
      "index": {
        "description": "Count error-level log events grouped by host name",
        "esql": {
          "query": "FROM logs* | WHERE log.level == \u0022error\u0022 | STATS count = COUNT(*) BY host.name"
        },
        "id": "error-count-by-host",
        "title": "Error count by host"
      }
    },
    {
      "delete": {
        "id": "old-query-id"
      }
    }
  ]
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/streams/${NAME}/queries/_bulk" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "operations": [
      {
        "index": {
          "description": "Count error-level log events grouped by host name",
          "esql": {
            "query": "FROM logs* | WHERE log.level == \u0022error\u0022 | STATS count = COUNT(*) BY host.name"
          },
          "id": "error-count-by-host",
          "title": "Error count by host"
        }
      },
      {
        "delete": {
          "id": "old-query-id"
        }
      }
    ]
  }'
```

