# API Key for service admin

**URL:** <https://community.grafana.com/t/api-key-for-service-admin/937>\
**Category:** General\
**Created:** [May 16, 2017, 1:44am UTC](https://community.grafana.com/t/api-key-for-service-admin/937 "2017-05-16T01:44:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cch](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@cch](https://community.grafana.com/u/cch)\
**Post date:** [May 16, 2017, 1:44am UTC](https://community.grafana.com/t/api-key-for-service-admin/937/1 "2017-05-16T01:44:27Z")

</div>

From the issues listed below, I can understand I can not simply use api key to call /api/org endpoints but the examples given in this link [http://docs.grafana.org/http\_api/org/](http://docs.grafana.org/http_api/org/) are using “Bearer” token as example and confuses me.

Is the doc needed for update? If api key is not supported for server admin, why the doc uses Bearer token?

> <https://github.com/grafana/grafana/issues/5752>
>
> when I run with
> curl -v -H "Authorization: Bearer eyJrIjoiZkVBWHZwbzdRRFZFZWFHSUhtdjE1TXllZmY0TW9PcGoiLCJuIjoidGVzdCIsImlkIjoxfQ==" http://admin:\*\*password\*\*@my.grafana.com/api/org/
> it return me 200 ok, but when I run as follow：
> curl -v...

  

> <https://github.com/grafana/grafana/issues/5019>
>
> Hi,
> I am using grafana 2.6. I have created an admin API key in one organization. Used that key for authentication using...

  

> <https://github.com/grafana/grafana/issues/5477>
>
> What Grafana version are you using? 3.0
> What datasource are you using? opentsdb
> What OS are you running grafana on? Linux
> What did you...

---

<div class="post-metadata">

**Author:** ![daniellee](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/daniellee/32/41_2.png) [@daniellee](https://community.grafana.com/u/daniellee)\
**Post date:** [May 16, 2017, 9:31am UTC](https://community.grafana.com/t/api-key-for-service-admin/937/2 "2017-05-16T09:31:46Z")

</div>

Are there any specific routes that are not working? Some routes are restricted to not work with api keys - for example changing the Grafana Admin password. Most of the org routes require that the user is an organization admin.

These worked for me when using a key for a user that is an org admin:

```auto
curl -H "Authorization: Bearer eyJrestofmykey" http://grafana.staged-by-discourse.com/api/org
curl -H "Authorization: Bearer eyJrestofmykey" http://grafana.staged-by-discourse.com/api/org/users

```

---

<div class="post-metadata">

**Author:** ![cch](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@cch](https://community.grafana.com/u/cch)\
**Post date:** [May 16, 2017, 12:46pm UTC](https://community.grafana.com/t/api-key-for-service-admin/937/3 "2017-05-16T12:46:32Z")

</div>

Thank you for the information.

Path such as api/orgs using Bearer token doesn’t seem to work. When the documentation (copied below) suggests it should ([http://docs.grafana.org/http\_api/org/](http://docs.grafana.org/http_api/org/)). Or I am missing something?

Organisations  
Search all Organisations

GET /api/orgs

Example Request:

GET /api/orgs HTTP/1.1  
Accept: application/json  
Content-Type: application/json  
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

---

<div class="post-metadata">

**Author:** ![daniellee](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/daniellee/32/41_2.png) [@daniellee](https://community.grafana.com/u/daniellee)\
**Post date:** [May 16, 2017, 12:57pm UTC](https://community.grafana.com/t/api-key-for-service-admin/937/4 "2017-05-16T12:57:30Z")

</div>

No, you are correct. The documentation is wrong for all routes under /api/orgs. /api/org routes work with an API key.

You will have to use Basic Auth:

`curl http://admin:admin@community.grafana.com/api/orgs`

I’ll fix the documentation. Thanks for reporting it and saving future pain for other users!

---

<div class="post-metadata">

**Author:** ![cch](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@cch](https://community.grafana.com/u/cch)\
**Post date:** [May 16, 2017, 1:48pm UTC](https://community.grafana.com/t/api-key-for-service-admin/937/5 "2017-05-16T13:48:52Z")

</div>

thanks for confirming. I was able to use basic auth without problems.

---

<div class="post-metadata">

**Author:** ![user112233](https://avatars.discourse-cdn.com/v4/letter/u/e19adc/32.png) [@user112233](https://community.grafana.com/u/user112233)\
**Post date:** [December 20, 2018, 9:34am UTC](https://community.grafana.com/t/api-key-for-service-admin/937/6 "2018-12-20T09:34:06Z")

</div>

Hii,

I am trying to search all the organisation using curl [http://admin:admin@community.grafana.com/api/orgs](http://admin:admin@community.grafana.com/api/orgs) but I am getting {“message”:“Permission denied”} response though username and password is correct. I am using grafana 3.0

Thank you,

---

<div class="post-metadata">

**Author:** ![anon80964540](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@anon80964540](https://community.grafana.com/u/anon80964540)\
**Post date:** [January 13, 2021, 4:40pm UTC](https://community.grafana.com/t/api-key-for-service-admin/937/7 "2021-01-13T16:40:17Z")

</div>


