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

# Get legacy index templates


deprecated

## Paths

- `GET` `/_template/{name}`
- `GET` `/_template`

#### Path parameters

- `name` (union string | string[]) — optional, leave it out to use `/_template`
  Comma-separated list of index template names used to limit the request.
Wildcard (`*`) expressions are supported.
To return all index templates, omit this parameter or use a value of `_all` or `*`.

## Description

Get information about one or more index templates.

IMPORTANT: This documentation is about legacy index templates, which are deprecated and will be replaced by the composable templates introduced in Elasticsearch 7.8.

[Read the reference documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.19/index-templates.html)

## 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/guide/en/elasticsearch/reference/current/token-authentication-services.html)

## Query string parameters

- `flat_settings` (boolean · default: false) — optional
  If `true`, returns settings in flat format.
- `local` (boolean · default: false) — optional — deprecated
  If `true`, the request retrieves information from the local node only.
- `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.

## Response

`application/json`

- `<string>` (object)
  - `aliases` (map string to object)
    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/v8/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.
  - `index_patterns` (string[])
  - `mappings` (object)
    - `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)
      - `compress` (boolean)
      - `compress_threshold` (string)
      - `enabled` (boolean)
      - `excludes` (string[])
      - `includes` (string[])
      - `mode` (enum)
        

Supported values include:
  - `disabled`
  - `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`, `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)
  - `order` (number)
  - `settings` (map string to object)
  - `version` (number)
## Code examples

#### Console

```console
GET /_template/.monitoring-*
```

#### JavaScript

```javascript
const response = await client.indices.getTemplate({
  name: ".monitoring-*",
});
```

#### Python

```python
resp = client.indices.get_template(
    name=".monitoring-*",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_template/.monitoring-*" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

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

#### C#

```c#
var response = await client.Indices
    .GetTemplateAsync(d1 => d1
        .Name(new[] { ".monitoring-*" })
    );
```

#### PHP

```php
$resp = $client->indices()->getTemplate([
    "name" => ".monitoring-*",
]);
```

#### Ruby

```ruby
response = client.indices.get_template(
  name: ".monitoring-*"
)
```

