---
type: api
title: Get component templates
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-cluster-get-component-template
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-cluster-get-component-template
products:
  - Elasticsearch Serverless
---

# Get component templates


Availability:

## Paths

- `GET` `/_component_template/{name}`
- `GET` `/_component_template`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/authentication#apikeyauth)

#### Path Parameters

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

## Description

Get information about component templates.

## Required authorization

* Cluster privileges: `manage_index_templates`

## Query String Parameters

- `flat_settings` (boolean · default: false)
  If `true`, returns settings in flat format.
- `settings_filter` (union string | [] string)
  Filter out results, for example to filter out sensitive information. Supports wildcards or full settings keys
  One of: `string` or `string[]`
- `include_defaults` (boolean · default: false)
  Return all default configurations for the component template
- `local` (boolean · default: false) — deprecated
  If `true`, the request retrieves information from the local node only.
If `false`, information is retrieved from the master node.
- `master_timeout` (string Duration · default: 30s)
  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`

- `component_templates` ([] ComponentTemplate)
  - `name` (string Name)
  - `component_template` ({} ComponentTemplateNodeWithRollover)
    - `template` ({} ComponentTemplateSummaryRes)
      - `lifecycle` ({} DataStreamLifecycleWithRollover)
        - `data_retention` (string Duration)
          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 Duration)
          The least amount of time data should be kept by elasticsearch.
        - `retention_determined_by` (enum RetentionSource)
          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` ([] DownsamplingRound)
          The list of downsampling rounds to execute as part of this downsampling configuration
          - `after` (string Duration)
            The duration since rollover when this downsampling round should execute
          - `fixed_interval` (string)
            The downsample interval.
        - `downsampling_method` (enum SamplingMethod)
          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.
        - `rollover` ({} DataStreamLifecycleRolloverConditions)
          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 Duration)
          - `max_age` (string)
          - `min_docs` (number)
          - `max_docs` (number)
          - `min_size` (number | string ByteSize)
          - `max_size` (number | string ByteSize)
          - `min_primary_shard_size` (number | string ByteSize)
          - `max_primary_shard_size` (number | string ByteSize)
          - `min_primary_shard_docs` (number)
          - `max_primary_shard_docs` (number)
      - `_meta` (Metadata)
      - `version` (number VersionNumber)
      - `settings` (map string to IndexSettings)
      - `mappings` ({} TypeMapping)
        - `all_field` ({} AllField)
          - `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 DynamicMapping)
          Values: `strict`, `runtime`, `true`, `false`
        - `dynamic_date_formats` ([] string)
        - `dynamic_templates` ([] string to DynamicTemplate)
        - `_field_names` ({} FieldNamesField)
          - `enabled` (boolean)
        - `index_field` ({} IndexField)
          - `enabled` (boolean)
        - `_meta` (Metadata)
        - `numeric_detection` (boolean)
        - `properties` (map string to Property)
        - `_routing` ({} RoutingField)
          - `required` (boolean)
        - `_size` ({} SizeField)
          - `enabled` (boolean)
        - `_source` ({} SourceField)
          - `enabled` (boolean)
          - `excludes` ([] string)
          - `includes` ([] string)
          - `mode` (enum SourceFieldMode)
            

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 RuntimeField)
          Map values ({} RuntimeField)
          - `fields` (map string to CompositeSubField)
            For type `composite`
            Map values ({} CompositeSubField)
            - `type` (enum RuntimeFieldType)
              Values: `boolean`, `composite`, `date`, `double`, `geo_point`, `geo_shape`, `ip`, `keyword`, `long`, `lookup`
          - `fetch_fields` ([] RuntimeFieldFetchFields)
            For type `lookup`
            - `field` (string Field)
            - `format` (string)
          - `format` (string)
            A custom format for `date` type runtime fields.
          - `input_field` (string Field)
            For type `lookup`
          - `target_field` (string Field)
            For type `lookup`
          - `target_index` (string IndexName)
            For type `lookup`
          - `script` (string Script)
            Painless script executed at query time.
          - `on_script_error` (enum OnScriptError)
            Values: `fail`, `continue`
          - `type` (enum RuntimeFieldType)
            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 Subobjects)
          Values: `true`, `false`
        - `_data_stream_timestamp` ({} DataStreamTimestamp)
          - `enabled` (boolean)
      - `aliases` (map string to AliasDefinition)
        Map values ({} AliasDefinition)
        - `filter` ({} QueryContainer)
          Query used to limit documents the alias can access.
          See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/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_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.
        - `is_hidden` (boolean · default: false)
          If `true`, the alias is hidden.
All indices for the alias must have the same `is_hidden` value.
      - `data_stream_options` ({} DataStreamOptions)
        - `failure_store` ({} DataStreamFailureStore)
          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` ({} FailureStoreLifecycle)
            If defined, it specifies the lifecycle configuration for the failure store of this data stream.
            - `data_retention` (string Duration)
              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.
    - `version` (number VersionNumber)
    - `_meta` (Metadata)
    - `deprecated` (boolean)
    - `created_date` (DateTime)
      Date and time when the component template was created. Only returned if the `human` query parameter is `true`.
    - `created_date_millis` (EpochTimeUnitMillis)
      Date and time when the component template was created, in milliseconds since the epoch.
    - `modified_date` (DateTime)
      Date and time when the component template was last modified. Only returned if the `human` query parameter is `true`.
    - `modified_date_millis` (EpochTimeUnitMillis)
      Date and time when the component template was last modified, in milliseconds since the epoch.
## Code Examples

#### Console

```console
GET /_component_template/template_1
```

#### JavaScript

```javascript
const response = await client.cluster.getComponentTemplate({
  name: "template_1",
});
```

#### Python

```python
resp = client.cluster.get_component_template(
    name="template_1",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_component_template/template_1" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.cluster().getComponentTemplate(g -> g
    .name("template_1")
);
```

#### C#

```c#
var response = await client.Cluster
    .GetComponentTemplateAsync(d1 => d1
        .Name("template_1")
    );
```

#### PHP

```php
$resp = $client->cluster()->getComponentTemplate([
    "name" => "template_1",
]);
```

#### Ruby

```ruby
response = client.cluster.get_component_template(
  name: "template_1"
)
```

## Response Examples

#### Get component template response example1

A successful response for retrieving information about a component template.

```json
{
  "component_templates" : [
    {
      "name" : "my-component-template",
      "component_template" : {
        "version" : 1,
        "_meta" : {
          "description" : "my custom component template"
        },
        "template" : {
          "settings" : {
            "index" : {
              "number_of_shards" : "1"
            }
          },
          "mappings" : {
            "properties" : {
              "@timestamp" : {
                "type" : "date"
              },
              "message" : {
                "type" : "text"
              }
            }
          }
        },
        "created_date" : "2024-01-01T12:00:00.000Z",
        "created_date_millis" : 1704110400000,
        "modified_date" : "2025-01-01T12:00:00.000Z",
        "modified_date_millis" : 1735732800000
      }
    }
  ]
}
```

