# Kibana API Map creation

**URL:** https://discuss.elastic.co/t/kibana-api-map-creation/250029
**Category:** Kibana
**Tags:** maps
**Created:** [September 25, 2020, 8:48pm UTC](https://discuss.elastic.co/t/kibana-api-map-creation/250029 "2020-09-25T20:48:44Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Eugene\_Dobrovolskyi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eugene_dobrovolskyi/32/75364_2.png) [@Eugene\_Dobrovolskyi](https://discuss.elastic.co/u/Eugene_Dobrovolskyi)
#### Post date: [September 25, 2020, 8:48pm UTC](https://discuss.elastic.co/t/kibana-api-map-creation/250029/1 "2020-09-25T20:48:44Z")

</div>

Hi all!

I would like to create a map in Kibana via REST API.  
I must provide JSON body in POST request to do it, but it includes some unclear fields and there are no corresponding explanations in Kibana documentation.  
Please explain to me what is:

1. id of layerListJSON object? should I create this object somehow in advance? what type does this object have?
2. layerListJSON-\>sourceDescriptor object and its id ? should I create this object somehow in advance? what type does this object have?

many thanks!

---

<div class="post-metadata">

### Author: ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)
#### Post date: [September 26, 2020, 12:44am UTC](https://discuss.elastic.co/t/kibana-api-map-creation/250029/2 "2020-09-26T00:44:08Z")

</div>

The ids for elasticsearch layers should be a unique string. You will need to define a layerDescriptor with a valid sourceDescriptor.

Layer descriptor is defined at [https://github.com/elastic/kibana/blob/master/x-pack/plugins/maps/common/descriptor\_types/layer\_descriptor\_types.ts](https://github.com/elastic/kibana/blob/master/x-pack/plugins/maps/common/descriptor_types/layer_descriptor_types.ts). Source descriptor is defined at [https://github.com/elastic/kibana/blob/master/x-pack/plugins/maps/common/descriptor\_types/source\_descriptor\_types.ts](https://github.com/elastic/kibana/blob/master/x-pack/plugins/maps/common/descriptor_types/source_descriptor_types.ts).

You can see some examples layer lists in the sample data maps at [https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/server/sample\_data](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/server/sample_data)

Another strategy is to build a map with the UI and then use the saved object UI in management to export the saved object and inspect the generated layer list.

Hope that helps

---

<div class="post-metadata">

### Author: ![Eugene\_Dobrovolskyi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eugene_dobrovolskyi/32/75364_2.png) [@Eugene\_Dobrovolskyi](https://discuss.elastic.co/u/Eugene_Dobrovolskyi)
#### Post date: [September 28, 2020, 10:57am UTC](https://discuss.elastic.co/t/kibana-api-map-creation/250029/3 "2020-09-28T10:57:00Z")

</div>

@Nathan_Reese  
thank you very much!

I already exported the existing map and trying to analyse it.  
When I copied the whole json response and use it to create a new map it works fine. But when I am trying replace ES index id in the reference section I get an empty map.  
i tried to remove ids of layerListJSON and sourceDescriptor but it also didn't give result ( resulted map is empty ).

Should I create layerListJSON and sourceDescriptor objects in advance (how can I do it? ) and then input their id into the final request? or can I create all objects as a single request?

---

<div class="post-metadata">

### Author: ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)
#### Post date: [September 28, 2020, 1:37pm UTC](https://discuss.elastic.co/t/kibana-api-map-creation/250029/4 "2020-09-28T13:37:37Z")

</div>

Can you describe your usecase? Why are you trying to programmatically create maps?

> When I copied the whole json response and use it to create a new map it works fine. But when I am trying replace ES index id in the reference section I get an empty map.

`indexPatternId` must match the saved object id of a Kibana index pattern saved object. If `indexPatternId` does not match a saved object id, then it is not possible to generate elasticsearch requests

---

<div class="post-metadata">

### Author: ![Eugene\_Dobrovolskyi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eugene_dobrovolskyi/32/75364_2.png) [@Eugene\_Dobrovolskyi](https://discuss.elastic.co/u/Eugene_Dobrovolskyi)
#### Post date: [September 28, 2020, 2:33pm UTC](https://discuss.elastic.co/t/kibana-api-map-creation/250029/5 "2020-09-28T14:33:47Z")

</div>

my case is very simple:  
i already automated some data ingestion into ES instance and I would like to automate map creation for this data.  
but this data is very different, so that's why i would like to have separate maps for each uploaded data chunk

---

<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: [October 26, 2020, 2:33pm UTC](https://discuss.elastic.co/t/kibana-api-map-creation/250029/6 "2020-10-26T14:33:54Z")

</div>

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