# How to get an API key

**URL:** https://meta.discourse.org/t/how-to-get-an-api-key/223847
**Category:** Development
**Tags:** rest-api
**Created:** [April 10, 2022, 2:39pm UTC](https://meta.discourse.org/t/how-to-get-an-api-key/223847 "2022-04-10T14:39:03Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![dsclrsr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dsclrsr/32/256402_2.png) [@dsclrsr](https://meta.discourse.org/u/dsclrsr)
#### Post date: [April 10, 2022, 2:39pm UTC](https://meta.discourse.org/t/how-to-get-an-api-key/223847/1 "2022-04-10T14:39:03Z")

</div>

I’m trying to programmatically create a topic with Python on a Discourse instance where I have the admin role.

The [documentation](https://docs.discourse.org/) states:

> you will need to create an API Key from the admin panel

I have searched/looked in the admin panel, but I cannot find where I can generate this API key.

Unfortunately I have lost quite a bit of time already looking how to generate a key I can use as the `Api-Key` header. Should be simple? Where can I generate it?

---

<div class="post-metadata">

### Author: ![dsclrsr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dsclrsr/32/256402_2.png) [@dsclrsr](https://meta.discourse.org/u/dsclrsr)
#### Post date: [April 10, 2022, 2:46pm UTC](https://meta.discourse.org/t/how-to-get-an-api-key/223847/2 "2022-04-10T14:46:09Z")

</div>

In addition I don’t mind what kind of API key I can get, either `system` or my own `username`.

The only thing I care about is the ability to programmatically create a topic using a Python script.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [April 10, 2022, 2:53pm UTC](https://meta.discourse.org/t/how-to-get-an-api-key/223847/3 "2022-04-10T14:53:45Z")

</div>

Hello and welcome @dsclrsr :slightly_smiling_face:

You should be able to generate an api key from the admin api page `[YourSite]/admin/api/keys`

---

<div class="post-metadata">

### Author: ![dsclrsr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dsclrsr/32/256402_2.png) [@dsclrsr](https://meta.discourse.org/u/dsclrsr)
#### Post date: [April 10, 2022, 2:55pm UTC](https://meta.discourse.org/t/how-to-get-an-api-key/223847/4 "2022-04-10T14:55:08Z")

</div>

Ok turns out I am not a real **admin** , even though I can visit the admin panel over at `/admin/` I **cannot** visit `/admin/api/keys`, I asked the hoster who setup the forum and he was able to create me a key at this location.

Seems to be a distinction between ‘admin’ (like a moderator) and ‘admin’ (like a system admin).

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [April 10, 2022, 3:07pm UTC](https://meta.discourse.org/t/how-to-get-an-api-key/223847/5 "2022-04-10T15:07:00Z")

</div>

Ah yes. Moderator and Admin are distinct roles in Discourse. A Moderator has quite a lot of high level functions for user and content moderation, but an Admin (or Sysadmin) has access to far more settings and functions to do with setting up the forum itself. You can read more info about those roles in [Understanding user statuses, roles, and permissions](https://meta.discourse.org/t/description-of-various-user-states-in-discourse-admin-moderator-staff-developer-other/35171)

---

<div class="post-metadata">

### Author: ![dsclrsr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dsclrsr/32/256402_2.png) [@dsclrsr](https://meta.discourse.org/u/dsclrsr)
#### Post date: [April 10, 2022, 3:07pm UTC](https://meta.discourse.org/t/how-to-get-an-api-key/223847/6 "2022-04-10T15:07:22Z")

</div>

Thanks for the help!

---

<div class="post-metadata">

### Author: ![Robert\_Mercado](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Robert\_Mercado](https://meta.discourse.org/u/Robert_Mercado)
#### Post date: [June 11, 2024, 2:51pm UTC](https://meta.discourse.org/t/how-to-get-an-api-key/223847/7 "2024-06-11T14:51:09Z")

</div>

Hi @JammyDodger,

Could you explain the request parameters for that API or share the documentation?

I receive a response without the `scopes` parameter, but when I include the `scopes` parameter, it results in errors.

If possible, please share example code for that API. Thanks!
