Dashboard API

Identifier (id) vs unique identifier (uid)

The identifier (id) of a dashboard is an auto-incrementing numeric value and is only unique per Grafana install.

The unique identifier (uid) of a dashboard can be used for uniquely identify a dashboard between multiple Grafana installs. It’s automatically generated if not provided when creating a dashboard. The uid allows having consistent URL’s for accessing dashboards and when syncing dashboards between multiple Grafana installs, see dashboard provisioning for more information. This means that changing the title of a dashboard will not break any bookmarked links to that dashboard.

The uid can have a maximum length of 40 characters.

Create / Update dashboard

POST /api/dashboards/db

Creates a new dashboard or updates an existing dashboard.

Example Request for new dashboard:

  1. POST /api/dashboards/db HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "dashboard": {
  7. "id": null,
  8. "uid": null,
  9. "title": "Production Overview",
  10. "tags": [ "templated" ],
  11. "timezone": "browser",
  12. "schemaVersion": 16,
  13. "version": 0
  14. },
  15. "folderId": 0,
  16. "overwrite": false
  17. }

JSON Body schema:

  • dashboard – The complete dashboard model, id = null to create a new dashboard.
  • dashboard.id – id = null to create a new dashboard.
  • dashboard.uid – Optional unique identifier when creating a dashboard. uid = null will generate a new uid.
  • folderId – The id of the folder to save the dashboard in.
  • overwrite – Set to true if you want to overwrite existing dashboard with newer version, same dashboard title in folder or same dashboard uid.
  • message - Set a commit message for the version history.Example Response:
  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 78
  4. {
  5. "id": 1,
  6. "uid": "cIBgcSjkk",
  7. "url": "/d/cIBgcSjkk/production-overview",
  8. "status": "success",
  9. "version": 1,
  10. "slug": "production-overview" //deprecated in Grafana v5.0
  11. }

Status Codes:

  • 200 – Created
  • 400 – Errors (invalid json, missing or invalid fields, etc)
  • 401 – Unauthorized
  • 403 – Access denied
  • 412 – Precondition failedThe 412 status code is used for explaining that you cannot create the dashboard and why. There can be different reasons for this:

  • The dashboard has been changed by someone else, status=version-mismatch

  • A dashboard with the same name in the folder already exists, status=name-exists
  • A dashboard with the same uid already exists, status=name-exists
  • The dashboard belongs to plugin <plugin title>, status=plugin-dashboardThe response body will have the following properties:
  1. HTTP/1.1 412 Precondition Failed
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 97
  4. {
  5. "message": "The dashboard has been changed by someone else",
  6. "status": "version-mismatch"
  7. }

In case of title already exists the status property will be name-exists.

Get dashboard by uid

GET /api/dashboards/uid/:uid

Will return the dashboard given the dashboard unique identifier (uid).

Example Request:

  1. GET /api/dashboards/uid/cIBgcSjkk HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "dashboard": {
  5. "id": 1,
  6. "uid": "cIBgcSjkk",
  7. "title": "Production Overview",
  8. "tags": [ "templated" ],
  9. "timezone": "browser",
  10. "schemaVersion": 16,
  11. "version": 0
  12. },
  13. "meta": {
  14. "isStarred": false,
  15. "url": "/d/cIBgcSjkk/production-overview",
  16. "slug": "production-overview" //deprecated in Grafana v5.0
  17. }
  18. }

Status Codes:

  • 200 – Found
  • 401 – Unauthorized
  • 403 – Access denied
  • 404 – Not found

Delete dashboard by uid

DELETE /api/dashboards/uid/:uid

Will delete the dashboard given the specified unique identifier (uid).

Example Request:

  1. DELETE /api/dashboards/uid/cIBgcSjkk HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"title": "Production Overview"}

Status Codes:

  • 200 – Deleted
  • 401 – Unauthorized
  • 403 – Access denied
  • 404 – Not found

Gets the home dashboard

GET /api/dashboards/home

Will return the home dashboard.

Example Request:

  1. GET /api/dashboards/home HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "dashboard": {
  5. "editable":false,
  6. "hideControls":true,
  7. "nav":[
  8. {
  9. "enable":false,
  10. "type":"timepicker"
  11. }
  12. ],
  13. "style":"dark",
  14. "tags":[],
  15. "templating":{
  16. "list":[
  17. ]
  18. },
  19. "time":{
  20. },
  21. "timezone":"browser",
  22. "title":"Home",
  23. "version":5
  24. },
  25. "meta": {
  26. "isHome":true,
  27. "canSave":false,
  28. "canEdit":false,
  29. "canStar":false,
  30. "url":"",
  31. "expires":"0001-01-01T00:00:00Z",
  32. "created":"0001-01-01T00:00:00Z"
  33. }
  34. }

Tags for Dashboard

GET /api/dashboards/tags

Get all tags of dashboards

Example Request:

  1. GET /api/dashboards/tags HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. [
  4. {
  5. "term":"tag1",
  6. "count":1
  7. },
  8. {
  9. "term":"tag2",
  10. "count":4
  11. }
  12. ]

See Folder/Dashboard Search API.

Deprecated resources

Please note that these resource have been deprecated and will be removed in a future release.

Get dashboard by slug

Deprecated starting from Grafana v5.0. Please update to use the new Get dashboard by uid resource instead

GET /api/dashboards/db/:slug

Will return the dashboard given the dashboard slug. Slug is the url friendly version of the dashboard title. If there exists multiple dashboards with the same slug, one of them will be returned in the response.

Example Request:

  1. GET /api/dashboards/db/production-overview HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "dashboard": {
  5. "id": 1,
  6. "uid": "cIBgcSjkk",
  7. "title": "Production Overview",
  8. "tags": [ "templated" ],
  9. "timezone": "browser",
  10. "schemaVersion": 16,
  11. "version": 0
  12. },
  13. "meta": {
  14. "isStarred": false,
  15. "url": "/d/cIBgcSjkk/production-overview",
  16. "slug": "production-overview" // deprecated in Grafana v5.0
  17. }
  18. }

Status Codes:

  • 200 – Found
  • 401 – Unauthorized
  • 403 – Access denied
  • 404 – Not found

Delete dashboard by slug

Deprecated starting from Grafana v5.0. Please update to use the Delete dashboard by uid resource instead.

DELETE /api/dashboards/db/:slug

Will delete the dashboard given the specified slug. Slug is the url friendly version of the dashboard title.

Example Request:

  1. DELETE /api/dashboards/db/test HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"title": "Production Overview"}

Status Codes:

  • 200 – Deleted
  • 401 – Unauthorized
  • 403 – Access denied
  • 404 – Not found
  • 412 – Precondition failedThe 412 status code is used when there exists multiple dashboards with the same slug. The response body will look like this:
  1. HTTP/1.1 412 Precondition Failed
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 97
  4. {
  5. "message": "Multiple dashboards with the same slug exists",
  6. "status": "multiple-slugs-exists"
  7. }