Dashboard Versions

    Query parameters:

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

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

    Example request for getting all dashboard versions:

    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 /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

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

    Status Codes:

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

    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

    JSON response body schema:

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

    Restore dashboard by dashboard UID

    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.

    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):

    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>

    Status Codes:

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