---
type: api
title: Upsert query stream settings
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/operation/operation-put-streams-name-query
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/operation/operation-put-streams-name-query
products:
  - Kibana
---

# Upsert query stream settings

Availability: Experimental since 9.4

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

## Paths

- `PUT` `/api/streams/{name}/_query`
- `PUT` `/s/{space_id}/api/streams/{name}/_query`

#### Path parameters

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

## Description

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

Upserts the query settings of a query stream definition

## 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`

- `field_descriptions` (map string to string) — optional
  Map values (string · max length: 1000)
- `query` (object) — required
  - `esql` (string · max length: 65535) — required

## Response

The query stream settings were updated successfully.

## Code examples

#### Console

```console
PUT kbn:/api/streams/NAME/_query
{
  "query": {
    "esql": "FROM logs* | WHERE log.level == \u0022error\u0022 | KEEP @timestamp, message, host.name, log.level"
  }
}
```

#### curl

```curl
curl -X PUT "${KIBANA_URL}/api/streams/${NAME}/_query" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "query": {
      "esql": "FROM logs* | WHERE log.level == \u0022error\u0022 | KEEP @timestamp, message, host.name, log.level"
    }
  }'
```

