# How to Retrieve user\_api\_keys Value via API

**URL:** https://meta.discourse.org/t/how-to-retrieve-user-api-keys-value-via-api/327679
**Category:** Development
**Created:** [September 23, 2024, 4:42am UTC](https://meta.discourse.org/t/how-to-retrieve-user-api-keys-value-via-api/327679 "2024-09-23T04:42:21Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [September 23, 2024, 5:49am UTC](https://meta.discourse.org/t/how-to-retrieve-user-api-keys-value-via-api/327679/3 "2024-09-23T05:49:59Z")

</div>

I don’t it is possible to retrieve the value of an API key via the API. Discourse doesn’t save unencrypted API keys to the database. Even if you could retrieve the encrypted value, there wouldn’t be a way to decrypt it on your application.

Can you explain your use case a bit more? If a user API key has already been generated for a user, it’s not clear to me why they would need to approve authorization a second time.

Edit: it’s possible to use an Admin API Key to generate an API key for a user. Some details about that are here: [Generate User Api Key Without User Approval - #2 by simon](https://meta.discourse.org/t/generate-user-api-key-without-user-approval/310210/2)

> [@Generate User Api Key Without User Approval](https://meta.discourse.org/t/generate-user-api-key-without-user-approval/310210/2):
>
> Edit: instead of using the [User API Keys Specification](https://meta.discourse.org/t/user-api-keys-specification/48536) for generating the keys, you can use an admin API key for generating user API keys. That gets around the issue of user’s having to approve the app.

Re-reading my post, I see that I didn’t explain how the `$json` variable was set for the request. The easiest way to figure out how to structure the data is to make a request to generate a single user API with the scopes you want to use through the Discourse UI, then look at the value of the request payload that is sent with the request to `/admin/api/keys`:

 ![20240922_22h55m56s_grim](https://global.discourse-cdn.com/meta/original/4X/0/3/b/03bcb37365e83f3667168de6f0b2acf740a010e3.png)

---

_[View the full topic](https://meta.discourse.org/t/how-to-retrieve-user-api-keys-value-via-api/327679)._
