# How to get space\_id on server side

**URL:** <https://discuss.elastic.co/t/how-to-get-space-id-on-server-side/328054>\
**Category:** Kibana\
**Tags:** kibana-plugin-development\
**Created:** [March 20, 2023, 8:50am UTC](https://discuss.elastic.co/t/how-to-get-space-id-on-server-side/328054 "2023-03-20T08:50:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iljaskajrris](https://avatars.discourse-cdn.com/v4/letter/i/f1d935/32.png) [@iljaskajrris](https://discuss.elastic.co/u/iljaskajrris)\
**Post date:** [March 20, 2023, 8:50am UTC](https://discuss.elastic.co/t/how-to-get-space-id-on-server-side/328054/1 "2023-03-20T08:50:02Z")

</div>

Hi team, can you help me please to get space on the server side? I need to do smth like to get data based on space.

```auto
router.get(
	{
		path: '/api/get_data',
		validate: false,
	},
	async (context, req, response) => {
                const space = someFunctionThatHelpsToGetSpaceOnServerSide()
                const result = await context.core.elasticsearch.client.asCurrentUser.search({
                    index: space + "management-data"       
                })
		return response.ok({
			body: result
		})
	}
);

```

---

<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 17, 2023, 8:50am UTC](https://discuss.elastic.co/t/how-to-get-space-id-on-server-side/328054/2 "2023-04-17T08:50:04Z")

</div>

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