Dashboard Versions

Get all dashboard versions

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 dashboard version

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. "hideControls": false,
  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

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.

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