page_title: HTTP API page_description: Grafana HTTP API Reference
The Grafana backend exposes an HTTP API, the same API is used by the frontend to do everything from saving dashboards, creating users and updating data sources.
Currently you can authenticate via an API Token or via a Session cookie (acquired using regular login or oauth).
Open the sidemenu and click the organization dropdown and select the API Keys option.
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 eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
The Authorization header value should be Bearer <your api key>.
POST /api/dashboards/db
Creates a new dashboard or updates an existing dashboard.
Example Request for new dashboard:
POST /api/dashboards/db HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"dashboard": {
"id": null,
"title": "Production Overview",
"tags": [ "templated" ],
"timezone": "browser",
"rows": [
{
}
]
"schemaVersion": 6,
"version": 0
},
"overwrite": false
}
JSON Body schema:
Example Response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 78
{
"slug": "production-overview",
"status": "success",
"version": 1
}
Status Codes:
The 412 status code is used when a newer dashboard already exists (newer, its version is greater than the version that was sent). The same status code is also used if another dashboard exists with the same title. The response body will look like this:
HTTP/1.1 412 Precondition Failed
Content-Type: application/json; charset=UTF-8
Content-Length: 97
{
"message": "The dashboard has been changed by someone else",
"status": "version-mismatch"
}
In in case of title already exists the status property will be name-exists.
GET /api/dashboards/db/:slug
Will return the dashboard given the dashboard slug. Slug is the url friendly version of the dashboard title.
Example Request:
GET /api/dashboards/db/production-overview HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
Example Response:
HTTP/1.1 200
Content-Type: application/json
{
"meta": {
"isStarred": false,
"slug": "production-overview"
},
"model": {
"id": null,
"title": "Production Overview",
"tags": [ "templated" ],
"timezone": "browser",
"rows": [
{
}
]
"schemaVersion": 6,
"version": 0
},
}
DELETE /api/dashboards/db/:slug
The above will delete the dashboard with the specified slug. The slug is the url friendly (unique) version of the dashboard title.
GET /api/dashboards/home
GET /api/dashboards/tags
GET /file/:file
GET /api/search/
Status Codes:
Example Request:
GET /api/search?query=MyDashboard&starred=true&tag=prod HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
GET /api/datasources
GET /api/datasources/:datasourceId
PUT /api/datasources
Example Response:
HTTP/1.1 200
Content-Type: application/json
{"message":"Datasource added"}
POST /api/datasources
DELETE /api/datasources/:datasourceId
Example Response:
HTTP/1.1 200
Content-Type: application/json
{"message":"Data source deleted"}
GET /api/datasources/plugins
GET /api/datasources/proxy/:datasourceId/*
Proxies all calls to the actual datasource.
GET /api/org
GET /api/org/users
POST /api/org/users
Adds a global user to the actual organisation.
PATCH /api/org/users/:userId
DELETE /api/org/users/:userId
GET /api/org/users
GET /api/orgs
PUT /api/orgs/:orgId
GET /api/orgs/:orgId/users
POST /api/orgs/:orgId/users
PATCH /api/orgs/:orgId/users/:userId
DELETE /api/orgs/:orgId/users/:userId
GET /api/users
GET /api/users/:id
PUT /api/users/:id
GET /api/users/:id/orgs
PUT /api/user/password
Changes the password for the user
GET /api/user
The above will return the current user.
POST /api/user/using/:organisationId
Switch user context to the given organisation.
GET /api/user/orgs
The above will return a list of all organisations of the current user.
POST /api/user/stars/dashboard/:dashboardId
Stars the given Dashboard for the actual user.
DELETE /api/user/stars/dashboard/:dashboardId
Deletes the staring of the given Dashboard for the actual user.
POST /api/snapshots
GET /api/snapshots/:key
DELETE /api/snapshots-delete/:key
GET /api/frontend/settings
GET /api/login/ping
GET /api/admin/settings
POST /api/admin/users
PUT /api/admin/users/:id/password
PUT /api/admin/users/:id/permissions
DELETE /api/admin/users/:id