Snapshot API

Create new snapshot

POST /api/snapshots

Example Request:

  1. POST /api/snapshots HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "dashboard": {
  7. "editable":false,
  8. "nav":[
  9. {
  10. "enable":false,
  11. "type":"timepicker"
  12. }
  13. ],
  14. "rows": [
  15. {
  16. }
  17. ],
  18. "style":"dark",
  19. "tags":[],
  20. "templating":{
  21. "list":[
  22. ]
  23. },
  24. "time":{
  25. },
  26. "timezone":"browser",
  27. "title":"Home",
  28. "version":5
  29. },
  30. "expires": 3600
  31. }

JSON Body schema:

  • dashboard – Required. The complete dashboard model.
  • name – Optional. snapshot name
  • expires - Optional. When the snapshot should expire in seconds. 3600 is 1 hour, 86400 is 1 day. Default is never to expire.
  • external - Optional. Save the snapshot on an external server rather than locally. Default is false.
  • key - Optional. Define the unique key. Required if external is true.
  • deleteKey - Optional. Unique key used to delete the snapshot. It is different from the key so that only the creator can delete the snapshot. Required if external is true.

Note: When creating a snapshot using the API, you have to provide the full dashboard payload including the snapshot data. This endpoint is designed for the Grafana UI.

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "deleteKey":"XXXXXXX",
  5. "deleteUrl":"myurl/api/snapshots-delete/XXXXXXX",
  6. "key":"YYYYYYY",
  7. "url":"myurl/dashboard/snapshot/YYYYYYY",
  8. "id": 1
  9. }

Keys:

  • deleteKey – Key generated to delete the snapshot
  • key – Key generated to share the dashboard

Get list of Snapshots

GET /api/dashboard/snapshots

Query parameters:

  • query – Search Query
  • limit – Limit the number of returned results

Example Request:

  1. GET /api/dashboard/snapshots HTTP/1.1
  2. Accept: application/json
  3. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. [
  4. {
  5. "id":8,
  6. "name":"Home",
  7. "key":"YYYYYYY",
  8. "orgId":1,
  9. "userId":1,
  10. "external":false,
  11. "externalUrl":"",
  12. "expires":"2200-13-32T25:23:23+02:00",
  13. "created":"2200-13-32T28:24:23+02:00",
  14. "updated":"2200-13-32T28:24:23+02:00"
  15. }
  16. ]

Get Snapshot by Key

GET /api/snapshots/:key

Example Request:

  1. GET /api/snapshots/YYYYYYY HTTP/1.1
  2. Accept: application/json
  3. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "meta":{
  5. "isSnapshot":true,
  6. "type":"snapshot",
  7. "canSave":false,
  8. "canEdit":false,
  9. "canStar":false,
  10. "slug":"",
  11. "expires":"2200-13-32T25:23:23+02:00",
  12. "created":"2200-13-32T28:24:23+02:00"
  13. },
  14. "dashboard": {
  15. "editable":false,
  16. "nav": [
  17. {
  18. "enable":false,
  19. "type":"timepicker"
  20. }
  21. ],
  22. "rows": [
  23. {
  24. }
  25. ],
  26. "style":"dark",
  27. "tags":[],
  28. "templating":{
  29. "list":[
  30. ]
  31. },
  32. "time":{
  33. },
  34. "timezone":"browser",
  35. "title":"Home",
  36. "version":5
  37. }
  38. }

Delete Snapshot by Key

DELETE /api/snapshots/:key

Example Request:

  1. DELETE /api/snapshots/YYYYYYY HTTP/1.1
  2. Accept: application/json
  3. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"message":"Snapshot deleted. It might take an hour before it's cleared from any CDN caches.", "id": 1}

Delete Snapshot by deleteKey

This API call can be used without authentication by using the secret delete key for the snapshot.

GET /api/snapshots-delete/:deleteKey

Example Request:

  1. GET /api/snapshots-delete/XXXXXXX HTTP/1.1
  2. Accept: application/json

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"message":"Snapshot deleted. It might take an hour before it's cleared from any CDN caches.", "id": 1}