# How do I add tags via the post api endpoint

**URL:** <https://meta.discourse.org/t/how-do-i-add-tags-via-the-post-api-endpoint/154418>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [June 10, 2020, 2:28pm UTC](https://meta.discourse.org/t/how-do-i-add-tags-via-the-post-api-endpoint/154418 "2020-06-10T14:28:03Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)\
**Post date:** [June 10, 2020, 7:40pm UTC](https://meta.discourse.org/t/how-do-i-add-tags-via-the-post-api-endpoint/154418/3 "2020-06-10T19:40:01Z")

</div>

You have the syntax right. Maybe php is eating your `[]`? The actual curl command (no PHP) is working:

```plaintext
curl -i -sS -X POST "http://localhost:3000/posts.json" \
-H "Content-Type: multipart/form-data;" \
-H "Api-Key: ba8f7..." \
-H "Api-Username: blake.erickson" \
-F "title=2e45e2e8a239dk29d 1f35c2db23232323444a61 1e7e8a39797234" \
-F "raw=f9ef6749c8736db0996bad662187bee6 8a5753d79c027e5a3a576b171c5bc085 a546f59b75bca6f54edd2af2ef069cf8" \
-F "tags[]=asdf" \
-F "tags[]=fdsa" \
-F "tags[]=foo"

```

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/1/415b8de9653741fd7548fa9050f9b7f0c870236a.png)

EDIT:

> [@Faizan\_Zahid](#):
>
> `"topic_id": '.$topicsId.',`

Wait. Why are you including a topic id? You should only be able to add tags when creating a topic, not when creating a post (a reply to a topic).

---

_[View the full topic](https://meta.discourse.org/t/how-do-i-add-tags-via-the-post-api-endpoint/154418)._
