Dashboard Versions

Get all dashboard versions

Warning: This API is deprecated since Grafana v9.0.0 and will be removed in a future release. Refer to the new dashboard versions API.

Query parameters:

  • limit - Maximum number of results to return
  • start - Version to start from when returning queries

GET /api/dashboards/id/:dashboardId/versions

Gets all existing dashboard versions for the dashboard with the given dashboardId.

Example request for getting all dashboard versions:

  1. GET /api/dashboards/id/1/versions?limit=2?start=0 HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 428
  4. [
  5. {
  6. "id": 2,
  7. "dashboardId": 1,
  8. "parentVersion": 1,
  9. "restoredFrom": 0,
  10. "version": 2,
  11. "created": "2017-06-08T17:24:33-04:00",
  12. "createdBy": "admin",
  13. "message": "Updated panel title"
  14. },
  15. {
  16. "id": 1,
  17. "dashboardId": 1,
  18. "parentVersion": 0,
  19. "restoredFrom": 0,
  20. "version": 1,
  21. "created": "2017-06-08T17:23:33-04:00",
  22. "createdBy": "admin",
  23. "message": "Initial save"
  24. }
  25. ]

Status Codes:

  • 200 - Ok
  • 400 - Errors
  • 401 - Unauthorized
  • 404 - Dashboard version not found

Get all dashboard versions by dashboard UID

Query parameters:

  • limit - Maximum number of results to return
  • start - Version to start from when returning queries

GET /api/dashboards/uid/:uid/versions

Gets all existing dashboard versions for the dashboard with the given uid.

Example request for getting all dashboard versions:

  1. GET /api/dashboards/uid/QA7wKklGz/versions?limit=2?start=0 HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 428
  4. [
  5. {
  6. "id": 2,
  7. "dashboardId": 1,
  8. "uid": "QA7wKklGz",
  9. "parentVersion": 1,
  10. "restoredFrom": 0,
  11. "version": 2,
  12. "created": "2017-06-08T17:24:33-04:00",
  13. "createdBy": "admin",
  14. "message": "Updated panel title"
  15. },
  16. {
  17. "id": 1,
  18. "dashboardId": 1,
  19. "uid": "QA7wKklGz",
  20. "parentVersion": 0,
  21. "restoredFrom": 0,
  22. "version": 1,
  23. "created": "2017-06-08T17:23:33-04:00",
  24. "createdBy": "admin",
  25. "message": "Initial save"
  26. }
  27. ]

Status Codes:

  • 200 - Ok
  • 400 - Errors
  • 401 - Unauthorized
  • 404 - Dashboard version not found

Get dashboard version

Warning: This API is deprecated since Grafana v9.0.0 and will be removed in a future release. Refer to the new get dashboard version API.

GET /api/dashboards/id/:dashboardId/versions/:version

Get the dashboard version with the given version, for the dashboard with the given id.

Example request for getting a dashboard version:

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

Example response:

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 1300
  4. {
  5. "id": 1,
  6. "dashboardId": 1,
  7. "parentVersion": 0,
  8. "restoredFrom": 0,
  9. "version": 1,
  10. "created": "2017-04-26T17:18:38-04:00",
  11. "message": "Initial save",
  12. "data": {
  13. "annotations": {
  14. "list": [
  15. ]
  16. },
  17. "editable": true,
  18. "gnetId": null,
  19. "graphTooltip": 0,
  20. "id": 1,
  21. "links": [
  22. ],
  23. "rows": [
  24. {
  25. "collapse": false,
  26. "height": "250px",
  27. "panels": [
  28. ],
  29. "repeat": null,
  30. "repeatIteration": null,
  31. "repeatRowId": null,
  32. "showTitle": false,
  33. "title": "Dashboard Row",
  34. "titleSize": "h6"
  35. }
  36. ],
  37. "schemaVersion": 14,
  38. "style": "dark",
  39. "tags": [
  40. ],
  41. "templating": {
  42. "list": [
  43. ]
  44. },
  45. "time": {
  46. "from": "now-6h",
  47. "to": "now"
  48. },
  49. "timepicker": {
  50. "refresh_intervals": [
  51. "5s",
  52. "10s",
  53. "30s",
  54. "1m",
  55. "5m",
  56. "15m",
  57. "30m",
  58. "1h",
  59. "2h",
  60. "1d"
  61. ],
  62. "time_options": [
  63. "5m",
  64. "15m",
  65. "1h",
  66. "6h",
  67. "12h",
  68. "24h",
  69. "2d",
  70. "7d",
  71. "30d"
  72. ]
  73. },
  74. "timezone": "browser",
  75. "title": "test",
  76. "version": 1
  77. },
  78. "createdBy": "admin"
  79. }

Status Codes:

  • 200 - Ok
  • 401 - Unauthorized
  • 404 - Dashboard version not found

Get dashboard version by dashboard UID

GET /api/dashboards/uid/:uid/versions/:version

Get the dashboard version with the given version, for the dashboard with the given UID.

Example request for getting a dashboard version:

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

Example response:

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 1300
  4. {
  5. "id": 1,
  6. "dashboardId": 1,
  7. "uid": "QA7wKklGz",
  8. "parentVersion": 0,
  9. "restoredFrom": 0,
  10. "version": 1,
  11. "created": "2017-04-26T17:18:38-04:00",
  12. "message": "Initial save",
  13. "data": {
  14. "annotations": {
  15. "list": [
  16. ]
  17. },
  18. "editable": true,
  19. "gnetId": null,
  20. "graphTooltip": 0,
  21. "id": 1,
  22. "links": [
  23. ],
  24. "rows": [
  25. {
  26. "collapse": false,
  27. "height": "250px",
  28. "panels": [
  29. ],
  30. "repeat": null,
  31. "repeatIteration": null,
  32. "repeatRowId": null,
  33. "showTitle": false,
  34. "title": "Dashboard Row",
  35. "titleSize": "h6"
  36. }
  37. ],
  38. "schemaVersion": 14,
  39. "style": "dark",
  40. "tags": [
  41. ],
  42. "templating": {
  43. "list": [
  44. ]
  45. },
  46. "time": {
  47. "from": "now-6h",
  48. "to": "now"
  49. },
  50. "timepicker": {
  51. "refresh_intervals": [
  52. "5s",
  53. "10s",
  54. "30s",
  55. "1m",
  56. "5m",
  57. "15m",
  58. "30m",
  59. "1h",
  60. "2h",
  61. "1d"
  62. ],
  63. "time_options": [
  64. "5m",
  65. "15m",
  66. "1h",
  67. "6h",
  68. "12h",
  69. "24h",
  70. "2d",
  71. "7d",
  72. "30d"
  73. ]
  74. },
  75. "timezone": "browser",
  76. "title": "test",
  77. "version": 1
  78. },
  79. "createdBy": "admin"
  80. }

Status Codes:

  • 200 - Ok
  • 401 - Unauthorized
  • 404 - Dashboard version not found

Restore dashboard

Warning: This API is deprecated since Grafana v9.0.0 and will be removed in a future release. Refer to the new restore dashboard API.

POST /api/dashboards/id/:dashboardId/restore

Restores a dashboard to a given dashboard version.

Example request for restoring a dashboard version:

  1. POST /api/dashboards/id/1/restore
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "version": 1
  7. }

JSON body schema:

  • version - The dashboard version to restore to

Example response:

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 67
  4. {
  5. "slug": "my-dashboard",
  6. "status": "success",
  7. "version": 3
  8. }

JSON response body schema:

  • slug - the URL friendly slug of the dashboard’s title
  • status - whether the restoration was successful or not
  • version - the new dashboard version, following the restoration

Status codes:

  • 200 - OK
  • 401 - Unauthorized
  • 404 - Not found (dashboard not found or dashboard version not found)
  • 500 - Internal server error (indicates issue retrieving dashboard tags from database)

Example error response

  1. HTTP/1.1 404 Not Found
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 46
  4. {
  5. "message": "Dashboard version not found"
  6. }

JSON response body schema:

  • message - Message explaining the reason for the request failure.

Restore dashboard by dashboard UID

POST /api/dashboards/uid/:uid/restore

Restores a dashboard to a given dashboard version using uid.

Example request for restoring a dashboard version:

  1. POST /api/dashboards/uid/QA7wKklGz/restore
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "version": 1
  7. }

JSON body schema:

  • version - The dashboard version to restore to

Example response:

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 67
  4. {
  5. "id": 70,
  6. "slug": "my-dashboard",
  7. "status": "success",
  8. "uid": "QA7wKklGz",
  9. "url": "/d/QA7wKklGz/my-dashboard",
  10. "version": 3
  11. }

JSON response body schema:

  • slug - the URL friendly slug of the dashboard’s title
  • status - whether the restoration was successful or not
  • version - the new dashboard version, following the restoration

Status codes:

  • 200 - OK
  • 401 - Unauthorized
  • 404 - Not found (dashboard not found or dashboard version not found)
  • 500 - Internal server error (indicates issue retrieving dashboard tags from database)

Example error response

  1. HTTP/1.1 404 Not Found
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 46
  4. {
  5. "message": "Dashboard version not found"
  6. }

JSON response body schema:

  • message - Message explaining the reason for the request failure.

Compare dashboard versions

POST /api/dashboards/calculate-diff

Compares two dashboard versions by calculating the JSON diff of them.

Example request:

  1. POST /api/dashboards/calculate-diff HTTP/1.1
  2. Accept: text/html
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "base": {
  7. "dashboardId": 1,
  8. "version": 1
  9. },
  10. "new": {
  11. "dashboardId": 1,
  12. "version": 2
  13. },
  14. "diffType": "json"
  15. }

JSON body schema:

  • base - an object representing the base dashboard version
  • new - an object representing the new dashboard version
  • diffType - the type of diff to return. Can be “json” or “basic”.

Example response (JSON diff):

  1. HTTP/1.1 200 OK
  2. Content-Type: text/html; charset=UTF-8
  3. <p id="l1" class="diff-line diff-json-same">
  4. <!-- Diff omitted -->
  5. </p>

The response is a textual representation of the diff, with the dashboard values being in JSON, similar to the diffs seen on sites like GitHub or GitLab.

Status Codes:

  • 200 - Ok
  • 400 - Bad request (invalid JSON sent)
  • 401 - Unauthorized
  • 404 - Not found

Example response (basic diff):

  1. HTTP/1.1 200 OK
  2. Content-Type: text/html; charset=UTF-8
  3. <div class="diff-group">
  4. <!-- Diff omitted -->
  5. </div>

The response here is a summary of the changes, derived from the diff between the two JSON objects.

Status Codes:

  • 200 - OK
  • 400 - Bad request (invalid JSON sent)
  • 401 - Unauthorized
  • 404 - Not found