[[indices-close]]
=== Close index API
++++
<titleabbrev>Close index</titleabbrev>
++++

Closes an index.

[source,console]
--------------------------------------------------
POST /my-index-000001/_close
--------------------------------------------------
// TEST[setup:my_index]
// TEST[warning:the default value for the ?wait_for_active_shards parameter will change from '0' to 'index-setting' in version 8; specify '?wait_for_active_shards=index-setting' to adopt the future default behaviour, or '?wait_for_active_shards=0' to preserve today's behaviour]


[[close-index-api-request]]
==== {api-request-title}

`POST /<index>/_close`

[[close-index-api-prereqs]]
==== {api-prereq-title}

* If the {es} {security-features} are enabled, you must have the `manage`
<<privileges-list-indices,index privilege>> for the target index or index alias.

[[close-index-api-desc]]
==== {api-description-title}

You use the close index API to close open indices.

include::{es-repo-dir}/indices/open-close.asciidoc[tag=closed-index]


[[close-index-api-path-params]]
==== {api-path-parms-title}

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index]
+
To close all indices, use `_all` or `*`.
To disallow the closing of indices with `_all` or wildcard expressions,
change the `action.destructive_requires_name` cluster setting to `true`.
You can update this setting in the `elasticsearch.yml` file
or using the <<cluster-update-settings,cluster update settings>> API.


[[close-index-api-query-params]]
==== {api-query-parms-title}

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
+
Defaults to `true`.

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
+
Defaults to `open`.

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]

`wait_for_active_shards`::
+
--
(Optional, string) The number of shard copies that must be active before
proceeding with the operation. Set to `all`, `index-setting`, or any positive
integer up to the total number of shards in the index (`number_of_replicas+1`).
The value `index-setting` means to wait according to the index setting
`index.write.wait_for_active_shards`. Default: `0`, meaning do not wait for any
shards to be ready.

See <<index-wait-for-active-shards>>.
--

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]


[[close-index-api-example]]
==== {api-examples-title}

The following example shows how to close an index:

[source,console]
--------------------------------------------------
POST /my-index-000001/_close
--------------------------------------------------
// TEST[setup:my_index]
// TEST[warning:the default value for the ?wait_for_active_shards parameter will change from '0' to 'index-setting' in version 8; specify '?wait_for_active_shards=index-setting' to adopt the future default behaviour, or '?wait_for_active_shards=0' to preserve today's behaviour]

The API returns following response:

[source,console-result]
--------------------------------------------------
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "indices": {
    "my-index-000001": {
      "closed": true
    }
  }
}
--------------------------------------------------
