Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Grafana HTTP API reference
Every Grafana instance exposes an HTTP API, which is the same API used by the Grafana frontend to manage resources like saving dashboards, creating users, updating data sources, deleting alerts, and more. You can use the HTTP API to programmatically access or manage resources from your Grafana instance.
If you need to manage or access other resources from your Grafana Cloud Stack, refer to the Grafana Cloud API instead.
New generation HTTP APIs
Grafana is deprecating legacy APIs (/api) in favor of a new generation of improved APIs (/apis) which follow a standardized API structure alongside consistent API versioning. To learn more refer to the
new API structure in Grafana.
These are the available new generation APIs:
Grafana API specification
HTTP API specs are available in Swagger:
- OpenAPI v2 specification
- OpenAPI v3 specification, generated from the v2 specs
You can browser and try out both via the Swagger UI editor (served by the Grafana server) by navigating to /swagger-ui.
Authenticate HTTP API requests
Grafana OSS
You can authenticate HTTP API requests using basic authentication or a service account token.
Basic auth
If basic auth is enabled (it is enabled by default), then you can authenticate your HTTP request via standard basic auth. Basic auth will also authenticate LDAP users.
curl example:
curl http://admin:admin@localhost:3000/api/org
{"id":1,"name":"Main Org."}Service account token
To create a service account token, click on Administration in the left-side menu, click Users and access, then Service Accounts. For more information on how to use service account tokens, refer to the Service Accounts documentation.
You use the token in all requests in the Authorization header, like this:
Example:
GET http://your.grafana.com/api/dashboards/db/mydash HTTP/1.1
Accept: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbkThe Authorization header value should be Bearer <YOUR_SERVICE_ACCOUNT_TOKEN>.
Grafana Cloud
To use the HTTP API provided by a Grafana Cloud instance, authenticate requests with a service account token.
To access or create your service account tokens, click on Administration in the left-side menu, click Users and access, then Service Accounts. For details on creating service accounts, assigning permissions, and adding tokens, refer to Service Accounts.
Include the service account token in the Authorization header for all requests to your Grafana instance:
GET http://your.grafana.com/api/dashboards/db/mydash HTTP/1.1
Accept: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbkRequests to the HTTP API are authenticated using the Authorization header:
Authorization: Bearer <SERVICE ACCOUNT TOKEN>X-Grafana-Org-Id Header
X-Grafana-Org-Id is an optional property that specifies the organization to which the action is applied. If not set, the created key belongs to the current context org. Use this header in all requests except those regarding admin.
Example Request:
GET /api/org/ HTTP/1.1
Accept: application/json
Content-Type: application/json
X-Grafana-Org-Id: 2
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

