[[data-views-api-update]]
=== Update data view API
++++
<titleabbrev>Update data view</titleabbrev>
++++

experimental[] Update part of an data view. Only the specified fields are updated in the
data view. Unspecified fields stay as they are persisted.


[[data-views-api-update-request]]
==== Request

`POST <kibana host>:<port>/api/data_views/data_view/<id>`

`POST <kibana host>:<port>/s/<space_id>/api/data_views/data_view/<id>`


[[data-views-api-update-path-params]]
==== Path parameters

`space_id`::
  (Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used.

`id`::
  (Required, string) The ID of the data view you want to update.


[[data-views-api-update-request-body]]
==== Request body

`refresh_fields`:: (Optional, boolean) Reloads the data view fields after
the data view is updated. The default is `false`.

`data_view`::
  (Required, object) The data view fields you want to update.
+

You can partially update the following fields:

* `title`
* `name`
* `timeFieldName`
* `fields`
* `sourceFilters`
* `fieldFormatMap`
* `type`
* `typeMeta`


[[data-views-api-update-errors-codes]]
==== Response code

`200`::
    Indicates a successful call.


[[data-views-api-update-example]]
==== Examples

Update a title of the `<my-view>` data view:

[source,sh]
--------------------------------------------------
$ curl -X POST api/data_views/data_view/my-view
{
  "data_view": {
    "title": "some-other-view-*"
  }
}
--------------------------------------------------
// KIBANA

Customize the update behavior:

[source,sh]
--------------------------------------------------
$ curl -X POST api/data_views/data_view/my-view
{
  "refresh_fields": true,
  "data_view": {
    "fields": {}
  }
}
--------------------------------------------------
// KIBANA


All update fields are optional, but you can specify the following fields:

[source,sh]
--------------------------------------------------
$ curl -X POST api/data_views/data_view/my-view
{
  "data_view": {
    "title": "...",
    "name": "...",
    "timeFieldName": "...",
    "sourceFilters": [],
    "fieldFormats": {},
    "type": "...",
    "typeMeta": {},
    "fields": {},
    "runtimeFieldMap": {}
  }
}
--------------------------------------------------
// KIBANA

The API returns the updated data view object:

[source,sh]
--------------------------------------------------
{
    "data_view": {

    }
}
--------------------------------------------------

