# REST API for setting default landing page and index pattern for a space

**URL:** <https://discuss.elastic.co/t/rest-api-for-setting-default-landing-page-and-index-pattern-for-a-space/266412>\
**Category:** Kibana\
**Created:** [March 5, 2021, 10:31pm UTC](https://discuss.elastic.co/t/rest-api-for-setting-default-landing-page-and-index-pattern-for-a-space/266412 "2021-03-05T22:31:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![umesh2020](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/umesh2020/32/126038_2.png) [@umesh2020](https://discuss.elastic.co/u/umesh2020)\
**Post date:** [March 5, 2021, 10:31pm UTC](https://discuss.elastic.co/t/rest-api-for-setting-default-landing-page-and-index-pattern-for-a-space/266412/1 "2021-03-05T22:31:43Z")

</div>

Hi  
Is there a REST API for setting the default landing page and index pattern for a space ? I want to programatically create a space and set these attributes.

Thanks  
Umesha

---

<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:** [March 8, 2021, 9:52am UTC](https://discuss.elastic.co/t/rest-api-for-setting-default-landing-page-and-index-pattern-for-a-space/266412/2 "2021-03-08T09:52:13Z")

</div>

Hey, both of these things are configured via "advanced settings". These are stored in a saved object as well (type `config`). Because of this you can use the [Saved objects APIs | Kibana Guide [master] | Elastic](https://www.elastic.co/guide/en/kibana/master/saved-objects-api.html) to write the advanced settings object per space with the `defaultRoute` and `defaultIndex` settings.

`defaultIndex` has to be a saved object id of the index pattern saved object, not the pattern itself (you have to create that first, but it's also possible via saved objects API)

---

<div class="post-metadata">

**Author:** ![umesh2020](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/umesh2020/32/126038_2.png) [@umesh2020](https://discuss.elastic.co/u/umesh2020)\
**Post date:** [March 8, 2021, 4:31pm UTC](https://discuss.elastic.co/t/rest-api-for-setting-default-landing-page-and-index-pattern-for-a-space/266412/3 "2021-03-08T16:31:14Z")

</div>

Thanks a lot. Will try it out.

---

<div class="post-metadata">

**Author:** ![umesh2020](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/umesh2020/32/126038_2.png) [@umesh2020](https://discuss.elastic.co/u/umesh2020)\
**Post date:** [March 9, 2021, 6:41pm UTC](https://discuss.elastic.co/t/rest-api-for-setting-default-landing-page-and-index-pattern-for-a-space/266412/4 "2021-03-09T18:41:41Z")

</div>

Hi  
Just want to confirm the sequence of steps:

1. Create a config object with defaultRoute value set to the name of the space and defaultIndex set to the id of the default index pattern for the space
2. Use update saved objects API to update the space with config object id

---

<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:** [March 9, 2021, 7:12pm UTC](https://discuss.elastic.co/t/rest-api-for-setting-default-landing-page-and-index-pattern-for-a-space/266412/5 "2021-03-09T19:12:19Z")

</div>

yeah, exactly. Step 1 would happen in your script somehow, then you can use any http client to send it to Kibana. For the exact shape of the config object, the easiest approach is to set those things once via ui, then export it and rebuild the same structure in your script.

---

<div class="post-metadata">

**Author:** ![umesh2020](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/umesh2020/32/126038_2.png) [@umesh2020](https://discuss.elastic.co/u/umesh2020)\
**Post date:** [March 9, 2021, 8:31pm UTC](https://discuss.elastic.co/t/rest-api-for-setting-default-landing-page-and-index-pattern-for-a-space/266412/6 "2021-03-09T20:31:25Z")

</div>

Thanks. How do I export the config object ? By default, I don't see any config object under saved objects in Kibana UI even after modifying a namespace with default Index and default route

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [March 9, 2021, 8:45pm UTC](https://discuss.elastic.co/t/rest-api-for-setting-default-landing-page-and-index-pattern-for-a-space/266412/7 "2021-03-09T20:45:24Z")

</div>

Go to Advanced Settings in Kibana UI. Change default route from `/home/app` or whatever it is. Save it. Change it back. Save it. Now that field is in the saved object.

To programmatically update. Might need to add `space` and change `version`.

**API**  
`PUT` - `http://localhost:5601/api/saved_objects/config/7.11.0`

**Header**  
`kbn-xsrf = true `

**Body**

```auto
{
  "attributes": {
    "defaultRoute": "/app/home"
  }
}

```

---

<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:** [April 6, 2021, 8:46pm UTC](https://discuss.elastic.co/t/rest-api-for-setting-default-landing-page-and-index-pattern-for-a-space/266412/8 "2021-04-06T20:46:13Z")

</div>

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