---
title: "Upsert a data view"
method: PUT
path: "/api/data_views/v2/{id}"
tags: ["data-views-v2"]
---

# Upsert a data view

`PUT /api/data_views/v2/{id}`

## Request

- Base URL: `https://localhost:5601`
- URL: `https://localhost:5601/api/data_views/v2/{id}`
- Auth: one of:
  - API key in header `Authorization`
  - HTTP basic

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

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

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

Creates the data view with the ID in the path, or replaces its definition if it already exists. Returns `201` when the request creates a data view and `200` when it replaces one. A replacement removes any optional property you omit, such as `time_field`.<br/><br/>[Required authorization] Route required privileges: indexPatterns:manage.

## Path parameters

- `id` string, required

## Headers

- `kbn-xsrf` string, required

## Request body

- object
  - `allow_hidden_indices` boolean: When `true`, allows the data view to match hidden indices.
  - `field_filters` string[]: Field filters can be used to exclude one or more fields when fetching a document. They may contain wildcards, such as `user*` which filters fields starting with 'user'.
  - `field_settings` object: Settings for individual fields, keyed by field name. To change how Kibana displays a field from the backing indices, set its label, description, format, or popularity. To define a runtime field, use the runtime field name and set `type`.
  - `index_pattern` string, required: The index pattern (Elasticsearch index expression) to use as the data source. Example: "my-index-*".
  - `name` string: The name of the data view. Example: "Sample data view".
  - `time_field` string: The name of the time field in the index. Used for time-based filtering. Example: "@timestamp".

## Response `200`

updated

- object
  - `data` KibanaHTTPAPIsKbnSavedDataViewSpecSchema, required: Defines an stored data source with a mandatory index pattern and optional settings like id, name, show hidden indices and field settings.
    - `allow_hidden_indices` boolean: When `true`, allows the data view to match hidden indices.
    - `field_filters` string[]: Field filters can be used to exclude one or more fields when fetching a document. They may contain wildcards, such as `user*` which filters fields starting with 'user'.
    - `field_settings` object: Settings for individual fields, keyed by field name. To change how Kibana displays a field from the backing indices, set its label, description, format, or popularity. To define a runtime field, use the runtime field name and set `type`.
    - `id` string: Kibana provides a unique identifier for each data view, or you can create your own.
    - `index_pattern` string, required: The index pattern (Elasticsearch index expression) to use as the data source. Example: "my-index-*".
    - `name` string: The name of the data view. Example: "Sample data view".
    - `time_field` string: The name of the time field in the index. Used for time-based filtering. Example: "@timestamp".
  - `id` string, required: The ID of the data view.
  - `meta` object, required: Metadata about the data view.
    - `created_at` string: Timestamp when the object was created (ISO 8601).
    - `created_by` string: User profile ID of the user who created the object.
    - `managed` boolean: When `true`, the object is managed by Kibana and cannot be edited by users.
    - `owner` string: Identifier of the plugin or team that owns this object.
    - `spaces` string[]: The IDs of the spaces where the data view is available.
    - `updated_at` string: Timestamp when the object was last updated (ISO 8601).
    - `updated_by` string: User profile ID of the user who last updated the object.
    - `version` string: Internal version identifier for optimistic concurrency control.

## Other responses

- `201`: created
- `400`: invalid request
- `403`: forbidden
- `409`: conflict

---

[API](https://skmtc.dev/elastic/apis/kibana-apis.md) - [All operations](https://skmtc.dev/elastic/apis/kibana-apis/llms.txt) - [OpenAPI document](https://skmtc.dev/elastic/apis/kibana-apis/revisions/b87131d80c52?raw)
