# How to create a default index pattern via kibana api

**URL:** <https://discuss.elastic.co/t/how-to-create-a-default-index-pattern-via-kibana-api/238905>\
**Category:** Kibana\
**Created:** [June 26, 2020, 6:58pm UTC](https://discuss.elastic.co/t/how-to-create-a-default-index-pattern-via-kibana-api/238905 "2020-06-26T18:58:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![damasu](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@damasu](https://discuss.elastic.co/u/damasu)\
**Post date:** [June 26, 2020, 6:58pm UTC](https://discuss.elastic.co/t/how-to-create-a-default-index-pattern-via-kibana-api/238905/1 "2020-06-26T18:58:47Z")

</div>

Using the experimental Kibana 7.8 API, how can i create a **DEFAULT** index pattern.

I am calling the api as such:

```auto
http://kibana:5601/s/<some space>/api/saved_objects/index-pattern/dummy_index_pattern

```

```auto
{
  "attributes": {
     "title": "logstash-*",
    "timeFieldName": "@timestamp"
  }
}

```

However, only an index pattern is made, but default is not set. Any information would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [June 29, 2020, 2:55pm UTC](https://discuss.elastic.co/t/how-to-create-a-default-index-pattern-via-kibana-api/238905/2 "2020-06-29T14:55:26Z")

</div>

The default index pattern is part of the `config` saved object. To programmatically create a new index pattern and make it default, you have to create the index pattern saved object first, then write a `config` object in which the default index pattern is set to the id from the response of the first request.

The key in the `config` object holding the id of the index pattern is called `defaultIndex`

---

<div class="post-metadata">

**Author:** ![damasu](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@damasu](https://discuss.elastic.co/u/damasu)\
**Post date:** [June 29, 2020, 7:19pm UTC](https://discuss.elastic.co/t/how-to-create-a-default-index-pattern-via-kibana-api/238905/3 "2020-06-29T19:19:10Z")

</div>

i did the following:

```auto
/s/<some space>/api/saved_objects/config/dummy_index_pattern_config

```

```auto
{
  "attributes": {
    "defaultIndex": "dummy_index_pattern"
  } 
}

```

however, the result remains the same. the index is not set as default.

Under Saved Objects in Kibana i see two advance settings now

```auto
[Advanced Settings [dummy_index_pattern_config]]
[Advanced Settings [7.8.0]]

```

may be i need to directly update 7.8.0 rather than create a new `CONFIG`?

Solution: use 7.8.0 config do not use custom config.

```auto
/s/<some space>/api/saved_objects/config/7.8.0

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 27, 2020, 7:19pm UTC](https://discuss.elastic.co/t/how-to-create-a-default-index-pattern-via-kibana-api/238905/4 "2020-07-27T19:19:12Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
