kibana/docs/api/data-views/default-set.asciidoc

93 lines
2.1 KiB
Text

[[data-views-api-default-set]]
=== Set default data view API
++++
<titleabbrev>Set default data view</titleabbrev>
++++
experimental[] Set a default data view ID. Kibana UI will use the default data view unless user picks a different one.
The API doesn't validate if given `data_view_id` is a valid id.
[NOTE]
====
For the most up-to-date API details, refer to the
{kib-repo}/tree/{branch}/src/plugins/data_views/docs/openapi[open API specification].
====
[[data-views-api-default-set-request]]
==== Request
`POST <kibana host>:<port>/api/data_views/default`
`POST <kibana host>:<port>/s/<space_id>/api/data_views/default`
[[data-views-api-default-set-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.
[[data-views-api-default-set-body]]
==== Request body
`data_view_id`:: (Required, `string` or `null`) Sets a default data view id. Use `null` to unset a default data view.
`force`:: (Optional, boolean) Updates existing default data view id. The default is `false`.
[[data-views-api-default-set-codes]]
==== Response code
`200`::
Indicates a successful call.
[[data-views-api-default-set-example]]
==== Example
Set the default data view id if none is set:
[source,sh]
--------------------------------------------------
$ curl -X POST api/data_views/default
{
"data_view_id": "..."
}
--------------------------------------------------
// KIBANA
Upsert the default data view:
[source,sh]
--------------------------------------------------
$ curl -X POST api/data_views/default
{
"data_view_id": "...",
"force": true
}
--------------------------------------------------
// KIBANA
Unset the default data view:
[source,sh]
--------------------------------------------------
$ curl -X POST api/data_views/default
{
"data_view_id": null,
"force": true
}
--------------------------------------------------
// KIBANA
The API returns:
[source,sh]
--------------------------------------------------
{
"acknowledged": true
}
--------------------------------------------------