# Set default index automatically in new spaces

**URL:** https://discuss.elastic.co/t/set-default-index-automatically-in-new-spaces/178152
**Category:** Kibana
**Created:** [April 24, 2019, 5:13am UTC](https://discuss.elastic.co/t/set-default-index-automatically-in-new-spaces/178152 "2019-04-24T05:13:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Steven\_Ensslen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steven_ensslen/32/26984_2.png) [@Steven\_Ensslen](https://discuss.elastic.co/u/Steven_Ensslen)
#### Post date: [April 24, 2019, 5:13am UTC](https://discuss.elastic.co/t/set-default-index-automatically-in-new-spaces/178152/1 "2019-04-24T05:13:05Z")

</div>

I'm using the [Rest API](https://www.elastic.co/guide/en/kibana/6.7/spaces-api-post.html) to create spaces for all of my different user groups in my Kibana 6.7.1 hosted in Elastic Cloud.

How do I set the default index in all of the spaces without having to use the web interface? I've not found anything in the current documentation, and the `api/kibana/settings/defaultIndex` API merrily replies 200 to my `{"value": "space:index-pattern:indexPatternName"}` POST body but doesn't seem to do anything. It particularly does not seem to have updated the `index-pattern` or the space's `config` documents in the index pointed to by the`.kibana` alias. Nor does the UI respond as if the index-pattern has been set. [This behaviour appears to have been happening since 6.1](https://discuss.elastic.co/t/how-to-create-and-set-default-index-in-kibana-6-1-using-python/119175/7).

---

<div class="post-metadata">

### Author: ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)
#### Post date: [April 24, 2019, 1:45pm UTC](https://discuss.elastic.co/t/set-default-index-automatically-in-new-spaces/178152/2 "2019-04-24T13:45:09Z")

</div>

Hey @Steven_Ensslen,

To set the default index pattern for a new space, you can prefix the API call with the space identifier. For example, if you are setting this for the "Marketing" space with a Space Identifier of `marketing`, then your API call would look something like:

`POST /s/marketing/api/kibana/settings/defaultIndex`

```auto
{
   "value": "indexPatternGUID"
}

```

If you were to inspect your `.kibana` index, this would set the default index pattern for the `marketing` space to the index pattern with the document id `marketing:index-pattern:indexPatternGUID`.

A couple of notes:

- This will not create the index pattern; it only tells Kibana which index pattern should be the default for that particular space.
- The API endpoint to set the default index pattern is not a publicly documented API, so it can potentially change unexpectedly between versions.
- We recognize the docs for calling APIs within a particular space are lacking. We have a few open issues to improve the documentation, including [https://github.com/elastic/kibana/issues/29646](https://github.com/elastic/kibana/issues/29646)

---

<div class="post-metadata">

### Author: ![Steven\_Ensslen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steven_ensslen/32/26984_2.png) [@Steven\_Ensslen](https://discuss.elastic.co/u/Steven_Ensslen)
#### Post date: [April 24, 2019, 9:53pm UTC](https://discuss.elastic.co/t/set-default-index-automatically-in-new-spaces/178152/3 "2019-04-24T21:53:39Z")

</div>

Thanks @Larry_Gregory!

For future reference, the mistake that I was making was the value I provided in `value`. The indexPatternGUID is the only thing to be entered there.

---

<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: [May 22, 2019, 9:53pm UTC](https://discuss.elastic.co/t/set-default-index-automatically-in-new-spaces/178152/4 "2019-05-22T21:53:52Z")

</div>

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