[[index-patterns-api-default-set]]
=== Set default index pattern API
++++
<titleabbrev>Set default index pattern</titleabbrev>
++++

deprecated::[8.0.0,Use <<data-views-api-default-set>> instead.]

experimental[] Set a default index pattern ID. Kibana UI will use default index pattern unless user picks a different one. 
The API doesn't validate if given `index_pattern_id` is a valid id. 

[[index-patterns-api-default-set-request]]
==== Request

`POST <kibana host>:<port>/api/index_patterns/default`

`POST <kibana host>:<port>/s/<space_id>/api/index_patterns/default`

[[index-patterns-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.

[[index-patterns-api-default-set-body]]
==== Request body

`index_pattern_id`:: (Required, `string` or `null`) Sets a default index pattern id. Use `null` to unset a default index pattern.

`force`:: (Optional, boolean) Updates existing default index pattern id. The default is `false`.


[[index-patterns-api-default-set-codes]]
==== Response code

`200`::
Indicates a successful call.

[[index-patterns-api-default-set-example]]
==== Example

Set the default index pattern id if none is set:

[source,sh]
--------------------------------------------------
$ curl -X POST api/index_patterns/default
{
  "index_pattern_id": "..."
}
--------------------------------------------------
// KIBANA


Upsert the default index pattern:

[source,sh]
--------------------------------------------------
$ curl -X POST api/index_patterns/default
{
  "index_pattern_id": "...",
  "force": true
}
--------------------------------------------------
// KIBANA

Unset the default index pattern:

[source,sh]
--------------------------------------------------
$ curl -X POST api/index_patterns/default
{
  "index_pattern_id": null,
  "force": true
}
--------------------------------------------------
// KIBANA

The API returns:

[source,sh]
--------------------------------------------------
{
    "acknowledged": true
}
--------------------------------------------------

