# How find tags id to add tags when create topic via API

**URL:** https://meta.discourse.org/t/how-find-tags-id-to-add-tags-when-create-topic-via-api/84387
**Category:** Support
**Created:** [02.Апрель.2018 15:31:16 UTC](https://meta.discourse.org/t/how-find-tags-id-to-add-tags-when-create-topic-via-api/84387 "2018-04-02T15:31:16Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![thaidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thaidb/32/68488_2.png) [@thaidb](https://meta.discourse.org/u/thaidb)
#### Post date: [02.Апрель.2018 15:31:16 UTC](https://meta.discourse.org/t/how-find-tags-id-to-add-tags-when-create-topic-via-api/84387/1 "2018-04-02T15:31:16Z")

</div>

I wanna create topic via API

How find tags id to add tags when create topic via API

Thank!

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [03.Апрель.2018 07:15:27 UTC](https://meta.discourse.org/t/how-find-tags-id-to-add-tags-when-create-topic-via-api/84387/2 "2018-04-03T07:15:27Z")

</div>

AFAIK you don’t need tag ids. You can just pass the tag names.

---

<div class="post-metadata">

### Author: ![dpausp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dpausp/32/95291_2.png) [@dpausp](https://meta.discourse.org/u/dpausp)
#### Post date: [13.Май.2018 20:50:21 UTC](https://meta.discourse.org/t/how-find-tags-id-to-add-tags-when-create-topic-via-api/84387/3 "2018-05-13T20:50:21Z")

</div>

> [@vinothkannans](#):
>
> AFAIK you don’t need tag ids. You can just pass the tag names.

Does anyone know if this should work in 2.0.0.beta9? Tags are not mentioned in the API docs for `POST /posts`.  
I tried to create topics with `tags="testtag"` but got a HTTP 500 error.

From the logs:

```plaintext
NoMethodError (undefined method `-' for "testtag":String)                                                                                                                                                                                       
/var/www/discourse/lib/discourse_tagging.rb:220:in `tags_for_saving' 

```

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [14.Май.2018 05:15:54 UTC](https://meta.discourse.org/t/how-find-tags-id-to-add-tags-when-create-topic-via-api/84387/4 "2018-05-14T05:15:54Z")

</div>

You should try like `tags[]="testtag"`. It’s an array type.

---

<div class="post-metadata">

### Author: ![Ghazal\_Taimur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ghazal_taimur/32/151076_2.png) [@Ghazal\_Taimur](https://meta.discourse.org/u/Ghazal_Taimur)
#### Post date: [10.Июнь.2020 14:56:53 UTC](https://meta.discourse.org/t/how-find-tags-id-to-add-tags-when-create-topic-via-api/84387/5 "2020-06-10T14:56:53Z")

</div>

Это не работает. Есть способ добавить теги?

---

<div class="post-metadata">

### Author: ![Faizan\_Zahid](https://avatars.discourse-cdn.com/v4/letter/f/b9bd4f/32.png) [@Faizan\_Zahid](https://meta.discourse.org/u/Faizan_Zahid)
#### Post date: [10.Июнь.2020 15:21:17 UTC](https://meta.discourse.org/t/how-find-tags-id-to-add-tags-when-create-topic-via-api/84387/6 "2020-06-10T15:21:17Z")

</div>

Это не работает, мой вызов выглядит так:

```
$body = '{
            "async": false,
            "title": "'.$word.'",
            "raw": "'.$definition.'",
            "category":'.$categoryId.',
            "topic_id": '.$topicsId.',
            "tags[]": "test-tag"
        }';

```

Тема создаётся, но тег не создаётся и не добавляется к новой теме. @vinothkannans
