---
type: api
title: Get index templates
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-indices-get-index-template
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-indices-get-index-template
products:
  - Elasticsearch
---

# Get index templates


Availability: Generally available since 7.9

## Paths

- `GET` `/_index_template/{name}`
- `GET` `/_index_template`

#### Path parameters

- `name` (string) — optional, leave it out to use `/_index_template`
  Name of index template to retrieve. Wildcard (*) expressions are supported.

## Description

Get information about one or more index templates.

## Required authorization

- Cluster privileges: `manage_index_templates`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

## Query string parameters

- `local` (boolean · default: false) — optional — deprecated
  If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the master node.
- `flat_settings` (boolean · default: false) — optional
  If true, returns settings in flat format.
- `master_timeout` (string · default: 30s) — optional
  Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error.
- `include_defaults` (boolean · default: false) — optional
  If true, returns all relevant default configurations for the index template.

## Response

`application/json`

- `index_templates` (object[])
  - `name` (string)
  - `index_template` (object)
    - `template` (object)
      Template to be applied.
It may optionally include an `aliases`, `mappings`, or `settings` configuration.
      - `lifecycle` (object)
        - `data_retention` (string)
          If defined, every document added to this data stream will be stored at least for this time frame.
Any time after this duration the document could be deleted.
When empty, every document in this data stream will be stored indefinitely.
        - `effective_retention` (string)
          The least amount of time data should be kept by elasticsearch.
        - `retention_determined_by` (enum)
          Configuration source that can influence the retention of a data stream.
          Values: `data_stream_configuration`, `default_global_retention`, `max_global_retention`, `default_failures_retention`
        - `downsampling` (object[])
          The list of downsampling rounds to execute as part of this downsampling configuration
          - `after` (string)
            The duration since rollover when this downsampling round should execute
          - `fixed_interval` (string)
            The downsample interval.
        - `downsampling_method` (enum)
          The method used to downsample the data. There are two options `aggregate` and `last_value`. It requires
`downsampling` to be defined. Defaults to `aggregate`.
          Values: `aggregate`, `last_value`
        - `enabled` (boolean · default: true)
          If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle
that's disabled (enabled: `false`) will have no effect on the data stream.
        - `frozen_after` (string)
          The period after which data stream backing indices are automatically converted to partially mounted searchable snapshots.
This field is valid only on main data stream lifecycles and cannot be set on failure-store lifecycles.
        - `rollover` (object)
          The conditions which will trigger the rollover of a backing index as configured by the cluster setting `cluster.lifecycle.default.rollover`.
This property is an implementation detail and it will only be retrieved when the query param `include_defaults` is set to true.
The contents of this field are subject to change.
          - `min_age` (string)
          - `max_age` (string)
          - `min_docs` (number)
          - `max_docs` (number)
          - `min_size` (number | string)
          - `max_size` (number | string)
          - `min_primary_shard_size` (number | string)
          - `max_primary_shard_size` (number | string)
          - `min_primary_shard_docs` (number)
          - `max_primary_shard_docs` (number)
      - `aliases` (map string to object)
        Aliases to add.
If the index template includes a `data_stream` object, these are data stream aliases.
Otherwise, these are index aliases.
Data stream aliases ignore the `index_routing`, `routing`, and `search_routing` options.
        Map values (object)
        - `filter` ({} Query)
          Query used to limit documents the alias can access.
          See [Query](https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/types/_types-query_dsl-querycontainer)
        - `index_routing` (string)
          Value used to route indexing operations to a specific shard.
If specified, this overwrites the `routing` value for indexing operations.
        - `is_hidden` (boolean · default: false)
          If `true`, the alias is hidden.
All indices for the alias must have the same `is_hidden` value.
        - `is_write_index` (boolean · default: false)
          If `true`, the index is the write index for the alias.
        - `routing` (string)
          Value used to route indexing and search operations to a specific shard.
        - `search_routing` (string)
          Value used to route search operations to a specific shard.
If specified, this overwrites the `routing` value for search operations.
      - `mappings` (object)
        Mapping for fields in the index.
If specified, this mapping can include field names, field data types, and mapping parameters.
        - `all_field` (object)
          - `analyzer` (string)
          - `enabled` (boolean)
          - `omit_norms` (boolean)
          - `search_analyzer` (string)
          - `similarity` (string)
          - `store` (boolean)
          - `store_term_vector_offsets` (boolean)
          - `store_term_vector_payloads` (boolean)
          - `store_term_vector_positions` (boolean)
          - `store_term_vectors` (boolean)
        - `date_detection` (boolean)
        - `dynamic` (enum)
          Values: `strict`, `runtime`, `true`, `false`
        - `dynamic_date_formats` (string[])
        - `dynamic_templates` (string to object[])
        - `_field_names` (object)
          - `enabled` (boolean)
        - `index_field` (object)
          - `enabled` (boolean)
        - `_meta` (object)
        - `numeric_detection` (boolean)
        - `properties` (map string to oneOf)
        - `_routing` (object)
          - `required` (boolean)
        - `_size` (object)
          - `enabled` (boolean)
        - `_source` (object)
          - `enabled` (boolean)
          - `excludes` (string[])
          - `includes` (string[])
          - `mode` (enum)
            

Supported values include:
  - `disabled`
  - `stored`
  - `columnar_stored`
  - `synthetic`: Instead of storing source documents on disk exactly as you send them,
 Elasticsearch can reconstruct source content on the fly upon retrieval.
            Values: `disabled`, `stored`, `columnar_stored`, `synthetic`
        - `runtime` (map string to object)
          Map values (object)
          - `fields` (map string to object)
            For type `composite`
            Map values (object)
            - `type` (enum)
              Values: `boolean`, `composite`, `date`, `double`, `geo_point`, `geo_shape`, `ip`, `keyword`, `long`, `lookup`
          - `fetch_fields` (object[])
            For type `lookup`
            - `field` (string)
            - `format` (string)
          - `format` (string)
            A custom format for `date` type runtime fields.
          - `input_field` (string)
            For type `lookup`
          - `target_field` (string)
            For type `lookup`
          - `target_index` (string)
            For type `lookup`
          - `script` (string)
            Painless script executed at query time.
          - `on_script_error` (enum)
            Values: `fail`, `continue`
          - `type` (enum)
            Field type, which can be: `boolean`, `composite`, `date`, `double`, `geo_point`, `ip`,`keyword`, `long`, or `lookup`.
            Values: `boolean`, `composite`, `date`, `double`, `geo_point`, `geo_shape`, `ip`, `keyword`, `long`, `lookup`
        - `enabled` (boolean)
        - `subobjects` (enum)
          Values: `true`, `false`
        - `_data_stream_timestamp` (object)
          - `enabled` (boolean)
      - `settings` (object)
        Configuration options for the index.
      - `data_stream_options` (object)
        - `failure_store` (object)
          If defined, it specifies configuration for the failure store of this data stream.
          - `enabled` (boolean · default: true)
            If defined, it turns the failure store on/off (`true`/`false`) for this data stream. A data stream failure store
that's disabled (enabled: `false`) will redirect no new failed indices to the failure store; however, it will
not remove any existing data from the failure store.
          - `lifecycle` (object)
            If defined, it specifies the lifecycle configuration for the failure store of this data stream.
            - `data_retention` (string)
              If defined, every document added to this data stream will be stored at least for this time frame.
Any time after this duration the document could be deleted.
When empty, every document in this data stream will be stored indefinitely.
            - `enabled` (boolean · default: true)
              If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle
that's disabled (enabled: `false`) will have no effect on the data stream.
    - `index_patterns` (string)
      Array of wildcard (`*`) expressions used to match the names of data streams and indices during creation.
    - `composed_of` (string[])
      An ordered list of component template names.
Component templates are merged in the order specified, meaning that the last component template specified has the highest precedence.
    - `version` (number)
      Version number used to manage index templates externally.
This number is not automatically generated by Elasticsearch.
    - `priority` (number)
      Priority to determine index template precedence when a new data stream or index is created.
The index template with the highest priority is chosen.
If no priority is specified the template is treated as though it is of priority 0 (lowest priority).
This number is not automatically generated by Elasticsearch.
    - `_meta` (object)
      Optional user metadata about the index template. May have any contents.
This map is not automatically generated by Elasticsearch.
    - `allow_auto_create` (boolean)
    - `data_stream` (object)
      If this object is included, the template is used to create data streams and their backing indices.
Supports an empty object.
Data streams require a matching index template with a `data_stream` object.
      - `hidden` (boolean · default: false)
        If true, the data stream is hidden.
      - `allow_custom_routing` (boolean · default: false)
        If true, the data stream supports custom routing.
    - `deprecated` (boolean)
      Marks this index template as deprecated.
When creating or updating a non-deprecated index template that uses deprecated components,
Elasticsearch will emit a deprecation warning.
    - `ignore_missing_component_templates` (string)
      A list of component template names that are allowed to be absent.
    - `created_date` (union)
      Date and time when the index template was created. Only returned if the `human` query parameter is `true`.
    - `created_date_millis` (number)
      Date and time when the index template was created, in milliseconds since the epoch.
    - `modified_date` (union)
      Date and time when the index template was last modified. Only returned if the `human` query parameter is `true`.
    - `modified_date_millis` (number)
      Date and time when the index template was last modified, in milliseconds since the epoch.
## Code examples

#### Console

```console
GET _index_template/*?filter_path=index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream
```

#### JavaScript

```javascript
const response = await client.indices.getIndexTemplate({
  name: "*",
  filter_path:
    "index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream",
});
```

#### Python

```python
resp = client.indices.get_index_template(
    name="*",
    filter_path="index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_index_template/*?filter_path=index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.indices().getIndexTemplate(g -> g
    .name("*")
);
```

#### C#

```c#
var response = await client.Indices
    .GetIndexTemplateAsync(d1 => d1
        .Name("*")
    );
```

#### PHP

```php
$resp = $client->indices()->getIndexTemplate([
    "name" => "*",
    "filter_path" => "index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream",
]);
```

#### Ruby

```ruby
response = client.indices.get_index_template(
  name: "*",
  filter_path: "index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream"
)
```

## Response examples

#### Get index template response example1

A successful response for retrieving information about an index template.

```json
{
  "index_templates" : [
    {
      "name" : "my-index-template",
      "index_template" : {
        "index_patterns" : [ "logs-*" ],
        "template" : {
          "settings" : {
            "index" : {
              "number_of_shards" : "1",
              "number_of_replicas" : "1"
            }
          },
          "mappings" : {
            "properties" : {
              "@timestamp" : {
                "type" : "date"
              },
              "message" : {
                "type" : "text"
              }
            }
          }
        },
        "composed_of" : [ "my-component-template" ],
        "priority" : 200,
        "version" : 1,
        "_meta" : {
          "description" : "my custom index template"
        },
        "created_date" : "2024-01-01T12:00:00.000Z",
        "created_date_millis" : 1704110400000,
        "modified_date" : "2025-01-01T12:00:00.000Z",
        "modified_date_millis" : 1735732800000
      }
    }
  ]
}
```

