# How to add index pattern for a space in Kibana

**URL:** <https://discuss.elastic.co/t/how-to-add-index-pattern-for-a-space-in-kibana/298136>\
**Category:** Kibana\
**Created:** [February 24, 2022, 9:23am UTC](https://discuss.elastic.co/t/how-to-add-index-pattern-for-a-space-in-kibana/298136 "2022-02-24T09:23:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![borisr84](https://avatars.discourse-cdn.com/v4/letter/b/da6949/32.png) [@borisr84](https://discuss.elastic.co/u/borisr84)\
**Post date:** [February 24, 2022, 9:23am UTC](https://discuss.elastic.co/t/how-to-add-index-pattern-for-a-space-in-kibana/298136/1 "2022-02-24T09:23:51Z")

</div>

Hi, I'm trying to add an index pattern for a particular space.  
I tried using the provided API, described here:

> **[Create index pattern API | Kibana Guide \[master\] | Elastic](https://www.elastic.co/guide/en/kibana/master/index-patterns-api-create.html)**
>
> Conceptual and step-by-step procedures for using runtime fields, scripted fields, and field formatters.

```auto
POST <kibana host>:<port>/s/<space_id>/api/index_patterns/index_pattern

```

But, I keep getting 404 response.  
Note: I also tried using the new suggested data\_view API -

```auto
POST <kibana host>:<port>/s/<space_id>/api/data_views/data_view

```

But got the same result (404).

I have managed to workaround this problem by creating an index pattern for the default space and then copying it from there to my other defined space using shared\_objects copy API, however this is not my preferred way for doing this and I prefer the official way.

Thanks in advance for the help!

---

<div class="post-metadata">

**Author:** ![borisr84](https://avatars.discourse-cdn.com/v4/letter/b/da6949/32.png) [@borisr84](https://discuss.elastic.co/u/borisr84)\
**Post date:** [February 24, 2022, 12:06pm UTC](https://discuss.elastic.co/t/how-to-add-index-pattern-for-a-space-in-kibana/298136/2 "2022-02-24T12:06:19Z")

</div>

A quick update, this was my mistake - I have mistakenly did not include the 'api' keyword in the API and thus it did not work.  
I can now confirm that everything works well now. Here's an example for everyone in need:

```auto
localhost:5601/logs/s/default/api/index_patterns/index_pattern

```

with body:

```auto
{
  "index_pattern": {
     "title": "testing"
  }
}

```

---

<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:** [March 24, 2022, 12:06pm UTC](https://discuss.elastic.co/t/how-to-add-index-pattern-for-a-space-in-kibana/298136/3 "2022-03-24T12:06:26Z")

</div>

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