# Export index template

**URL:** <https://discuss.elastic.co/t/export-index-template/359969>\
**Category:** Kibana\
**Created:** [May 22, 2024, 8:53am UTC](https://discuss.elastic.co/t/export-index-template/359969 "2024-05-22T08:53:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![alro](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@alro](https://discuss.elastic.co/u/alro)\
**Post date:** [May 22, 2024, 8:53am UTC](https://discuss.elastic.co/t/export-index-template/359969/1 "2024-05-22T08:53:48Z")

</div>

Hi Community

i like to export a changed index template from the "Index Management". The index is a clone of an existing Index and then edited. I now need to have an export of this edited index to replicate/import it on other servers.  
Is there a way how i can export such a index?

Thnks for any help here

Roberto

---

<div class="post-metadata">

**Author:** ![ashishtiwari1993](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashishtiwari1993/32/135241_2.png) [@ashishtiwari1993](https://discuss.elastic.co/u/ashishtiwari1993)\
**Post date:** [May 22, 2024, 10:49am UTC](https://discuss.elastic.co/t/export-index-template/359969/2 "2024-05-22T10:49:26Z")

</div>

You can do a `GET indexname/_mapping` and copy the response. Then perform `put indexname/_mapping` on other server by using/modifying same mapping response.

It is the easiest way to do it. Let me know if this helps.

---

<div class="post-metadata">

**Author:** ![alro](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@alro](https://discuss.elastic.co/u/alro)\
**Post date:** [May 22, 2024, 11:10am UTC](https://discuss.elastic.co/t/export-index-template/359969/3 "2024-05-22T11:10:43Z")

</div>

Hi Ashish

thanks for the answer. Unfortunately, this does not work. I did as you mentioned

`get [MY_INDEX_NAME]/_mapping`

But I get an error 404 and the result says

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "index_not_found_exception",
        "reason": "no such index [MY_INDEX_NAME]",
        "resource.type": "index_or_alias",
        "resource.id": "MY_INDEX_NAME",
        "index_uuid": "_na_",
        "index": "MY_INDEX_NAME"
      }
    ],
    "type": "index_not_found_exception",
    "reason": "no such index [MY_INDEX_NAME]",
    "resource.type": "index_or_alias",
    "resource.id": "MY_INDEX_NAME",
    "index_uuid": "_na_",
    "index": "MY_INDEX_NAME"
  },
  "status": 404
}

```

Did I understand your command right or do I need to get the info from

`get _index_template/MY_INDEX_NAME`

Is there also a possibility to have that in a file and import it with an installation?

thanks

---

<div class="post-metadata">

**Author:** ![ashishtiwari1993](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashishtiwari1993/32/135241_2.png) [@ashishtiwari1993](https://discuss.elastic.co/u/ashishtiwari1993)\
**Post date:** [May 22, 2024, 11:39am UTC](https://discuss.elastic.co/t/export-index-template/359969/4 "2024-05-22T11:39:28Z")

</div>

You need to replace `indexname` with your actual index name which is being used in your current cluster. Here is the full example -

Suppose on current cluster you have index `my-index-1`.

```auto
PUT /my-index-1
{
  "mappings": {
    "properties": {
      "age": { "type": "integer" },  
      "email": { "type": "keyword" }, 
      "name": { "type": "text" }     
    }
  }
}

```

Just GET the mapping of index

```auto
GET my-index-1/_mapping

```

On another cluster hit below mapping query again to create index `my-index-2` with same mapping

```auto
PUT /my-index-2
{
  "mappings": {
    "properties": {
      "age": {
        "type": "integer"
      },
      "email": {
        "type": "keyword"
      },
      "name": {
        "type": "text"
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![alro](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@alro](https://discuss.elastic.co/u/alro)\
**Post date:** [May 22, 2024, 11:55am UTC](https://discuss.elastic.co/t/export-index-template/359969/5 "2024-05-22T11:55:15Z")

</div>

As you described it works. But the index template was created/cloned under the Kibana GUI

![image](https://us1.discourse-cdn.com/elastic/original/3X/9/f/9f02a9b4daa2f46d46989499e6a07b61a46cca4b.png)

We are NOT talking about a "normal" index. We are talking about an **INDEX TEMPLATE.**  
I guess I was a little bit unprecise ☹

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [May 22, 2024, 12:44pm UTC](https://discuss.elastic.co/t/export-index-template/359969/6 "2024-05-22T12:44:48Z")

</div>

Kibana GUI uses the same API that you would use in dev tools.

In the GUI get the name of the template you want and use the API in dev tools.

```auto
GET _index_template/template-name

```

If it does not work, it may be a legacy template, so you need to use another endpoint

```auto
GET _template/template-name

```

---

<div class="post-metadata">

**Author:** ![alro](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@alro](https://discuss.elastic.co/u/alro)\
**Post date:** [May 22, 2024, 12:52pm UTC](https://discuss.elastic.co/t/export-index-template/359969/7 "2024-05-22T12:52:58Z")

</div>

Hi Leandro

Thats what i expected and what i have found on the documentation. 🙂  
Thanks.  
Maybe you can help me also how i can import that. That i did not found on the docu.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [May 22, 2024, 12:55pm UTC](https://discuss.elastic.co/t/export-index-template/359969/8 "2024-05-22T12:55:47Z")

</div>

This is also in the documentation, check it [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-template.html).
