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

# Upsert query stream settings

Availability: 9.4+

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

## Paths

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

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

#### Path Parameters

- `name` (string · max: 200)
  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<br/><br/>[Required authorization] Route required privileges: manage_stream.

## Request Body

`application/json`

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

## Response

The query stream settings were updated successfully.

## Code Examples

#### Console

```console
PUT /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 "https://{kibana_url}/api/streams/{name}/_query" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{
  "query": {
    "esql": "FROM logs* | WHERE log.level == \u0022error\u0022 | KEEP @timestamp, message, host.name, log.level"
  }
}'
```

