# Creating a topic via the API using Node.js

**URL:** <https://meta.discourse.org/t/creating-a-topic-via-the-api-using-node-js/117160>\
**Category:** Development\
**Created:** [May 8, 2019, 10:11am UTC](https://meta.discourse.org/t/creating-a-topic-via-the-api-using-node-js/117160 "2019-05-08T10:11:01Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Vishal\_Kaushik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vishal_kaushik/32/140452_2.png) [@Vishal\_Kaushik](https://meta.discourse.org/u/Vishal_Kaushik)\
**Post date:** [May 8, 2019, 10:11am UTC](https://meta.discourse.org/t/creating-a-topic-via-the-api-using-node-js/117160/1 "2019-05-08T10:11:01Z")

</div>

I am trying to create a new topic via Node.js API by sending the following payload :

```
 { title: 'topic:329201',
  raw: 'topic-description:32920111948',
  created_at: '2019-05-08',
  api_key:
   '2371b6549b0c3aeb1f12e49c22db5f25fb1f8ca740619e5304f12f4d29896097',
  api_username: 'cb1' 
}

```

I am hitting the API via HTTP module of node with the following options :

```
{ host: '13.127.14.24',
  port: '3000',
  path: '/posts',
  method: 'POST',
  headers:
   { 'content-type': 'application/x-www-form-urlencoded',
     'content-length': 194,
     Accept: '*/*',
     Connection: 'keep-alive' }
 }

```

But I am getting [“BAD CSRF”] in body. Can anyone help.

---

_[View the full topic](https://meta.discourse.org/t/creating-a-topic-via-the-api-using-node-js/117160)._
