How to use API key for creating Grafana Org?


I tried many way to create orgs in Grafana using API key instead of using Basic Auth mechanism. However, it always gives some permission related errors. Please see the steps I followed for checking this feature.

  1. Logged into Grafana as an admin user
  2. Created an API key in my Grafana with “Admin” role.
  3. Used the API in curl request as showing below.

curl -X POST --insecure -H “Content-Type: application/json” -H “Authorization: Bearer eyJrIjoiU1IySTlZWEpOSAVVQUtaRlh0UkhZZXU1YFRnRmhuMG0iLCJuIjoidGVzdCIsImlkIjo3OX0=” -d ‘{“name”:“TESTORG”}’

When I execute the above curl request I am getting following error in the json respose.
{“message”:“Access denied”}

Kindly help me to fix this issue.

Thank You,

There is a tutorial here that might help: