# Revoke Api Keys

**URL:** <https://forums.balena.io/t/revoke-api-keys/350079>\
**Category:** openBalena\
**Created:** [November 12, 2021, 2:07pm UTC](https://forums.balena.io/t/revoke-api-keys/350079 "2021-11-12T14:07:52Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![luclucluca](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@luclucluca](https://forums.balena.io/u/luclucluca)\
**Post date:** [November 12, 2021, 2:07pm UTC](https://forums.balena.io/t/revoke-api-keys/350079/1 "2021-11-12T14:07:52Z")

</div>

We are currently trying out openBalena and recently figured out that we could use “generate api-key” to get a key we can use to log in. Now the question, where are these Keys saved and can they be deleted/revoked somehow?

---

<div class="post-metadata">

**Author:** ![20k-ultra](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/20k-ultra/32/3435_2.png) [@20k-ultra](https://forums.balena.io/u/20k-ultra)\
**Post date:** [November 16, 2021, 4:20pm UTC](https://forums.balena.io/t/revoke-api-keys/350079/2 "2021-11-16T16:20:58Z")

</div>

Can you specify where/how you’re generate the API key ? Are you using [balena CLI Documentation - Balena Documentation](https://www.balena.io/docs/reference/balena-cli/#api-key-generate-name) ?

---

<div class="post-metadata">

**Author:** ![Lizzieepton](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/lizzieepton/32/5393_2.png) [@Lizzieepton](https://forums.balena.io/u/Lizzieepton)\
**Post date:** [November 16, 2021, 4:44pm UTC](https://forums.balena.io/t/revoke-api-keys/350079/8 "2021-11-16T16:44:39Z")

</div>

Hi @luclucluca I’m just sharing some more of our docs on generating API keys in case they are useful to you

- [Resources - Balena Documentation](https://www.balena.io/docs/reference/api/resources/api_key/)
- [Resources - Balena Documentation](https://www.balena.io/docs/reference/api/resources/device_tag/)

The second link there has a code snippet for deleting an API key which should hopefully work for you if you want to delete any of your existing keys

---

<div class="post-metadata">

**Author:** ![luclucluca](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@luclucluca](https://forums.balena.io/u/luclucluca)\
**Post date:** [November 16, 2021, 7:10pm UTC](https://forums.balena.io/t/revoke-api-keys/350079/10 "2021-11-16T19:10:23Z")

</div>

Yes that’s how we generated them.

---

<div class="post-metadata">

**Author:** ![luclucluca](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@luclucluca](https://forums.balena.io/u/luclucluca)\
**Post date:** [November 16, 2021, 7:10pm UTC](https://forums.balena.io/t/revoke-api-keys/350079/11 "2021-11-16T19:10:55Z")

</div>

Thank you very much! I’ll try these tomorrow.

---

<div class="post-metadata">

**Author:** ![Lizzieepton](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/lizzieepton/32/5393_2.png) [@Lizzieepton](https://forums.balena.io/u/Lizzieepton)\
**Post date:** [November 19, 2021, 12:18pm UTC](https://forums.balena.io/t/revoke-api-keys/350079/12 "2021-11-19T12:18:13Z")

</div>

great, let us know if you have any more questions 😊

---

<div class="post-metadata">

**Author:** ![luclucluca](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@luclucluca](https://forums.balena.io/u/luclucluca)\
**Post date:** [November 25, 2021, 7:18am UTC](https://forums.balena.io/t/revoke-api-keys/350079/14 "2021-11-25T07:18:22Z")

</div>

Thanks very much for the Great help! We are able now the see all the generated api keys! Tho it seems that, since we use those generated api keys to access them, we dont have the permission do Delete any api keys. I’ve read before about a “supervisor” api key but we were unable to find it anywhere. Does that also exist in openBalena? If yes where do we find it or how do we generate it?

Thanks in Advance!

---

<div class="post-metadata">

**Author:** ![luclucluca](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@luclucluca](https://forums.balena.io/u/luclucluca)\
**Post date:** [December 17, 2021, 1:52pm UTC](https://forums.balena.io/t/revoke-api-keys/350079/15 "2021-12-17T13:52:23Z")

</div>

Any news here? @Lizzieepton

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [December 20, 2021, 11:45am UTC](https://forums.balena.io/t/revoke-api-keys/350079/16 "2021-12-20T11:45:08Z")

</div>

Hello @luclucluca

Could you please confirm if you have set the `io.balena.features.supervisor-api` on your docker-compose file? Then running `echo $BALENA_SUPERVISOR_API_KEY` that should work.

Let me know if that solves the question or we can help you more! (sorry for the delay).

---

<div class="post-metadata">

**Author:** ![GoogleIt](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@GoogleIt](https://forums.balena.io/u/GoogleIt)\
**Post date:** [January 5, 2022, 3:15pm UTC](https://forums.balena.io/t/revoke-api-keys/350079/19 "2022-01-05T15:15:36Z")

</div>

Only the admin user (using credentials to log-in) could delete this if I am correct.  
I guess you could generate a temporary token using the credentials and then use that token to delete whatever you want.

I believe the main API key can be found in your docker compose/environment file.

---

<div class="post-metadata">

**Author:** ![luclucluca](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@luclucluca](https://forums.balena.io/u/luclucluca)\
**Post date:** [January 6, 2022, 10:59am UTC](https://forums.balena.io/t/revoke-api-keys/350079/20 "2022-01-06T10:59:04Z")

</div>

We are creating the Tokens using the Admin user(The account we used to set up the server). Even then if i send a DELETE Request for a api Key I get an “Unauthorized” back. I couldnt find any API keys that work in the Docker compose files on the server.

---

<div class="post-metadata">

**Author:** ![GoogleIt](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@GoogleIt](https://forums.balena.io/u/GoogleIt)\
**Post date:** [January 6, 2022, 11:13am UTC](https://forums.balena.io/t/revoke-api-keys/350079/21 "2022-01-06T11:13:06Z")

</div>

If you first authenticate with the admin user using the API, you get a token back.  
Try use this token to delete the API keys.

---

<div class="post-metadata">

**Author:** ![luclucluca](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@luclucluca](https://forums.balena.io/u/luclucluca)\
**Post date:** [January 6, 2022, 11:44am UTC](https://forums.balena.io/t/revoke-api-keys/350079/22 "2022-01-06T11:44:44Z")

</div>

How would you authenticate with the API?

---

<div class="post-metadata">

**Author:** ![GoogleIt](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@GoogleIt](https://forums.balena.io/u/GoogleIt)\
**Post date:** [January 7, 2022, 4:46pm UTC](https://forums.balena.io/t/revoke-api-keys/350079/23 "2022-01-07T16:46:24Z")

</div>

Hello @luclucluca

I made a very quick and dirty bash script you can use to revoke API keys. Not clean at all but it works.  
You can find it here: [GitHub - robbe-haesendonck/open-balena-scripts: Some scripts for interacting with the open-balena API](https://github.com/robbe-haesendonck/open-balena-scripts)

Will probably put some time in cleaning it up some day

Best regards,  
Robbe

---

<div class="post-metadata">

**Author:** ![luclucluca](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@luclucluca](https://forums.balena.io/u/luclucluca)\
**Post date:** [January 10, 2022, 7:33am UTC](https://forums.balena.io/t/revoke-api-keys/350079/24 "2022-01-10T07:33:34Z")

</div>

This is exactly what I was looking for. Thank you very much!
