2016-11-24 03:16:24 -06:00
+++
title = "HTTP Snapshot API "
description = "Grafana HTTP API"
keywords = ["grafana", "http", "documentation", "api", "snapshot"]
2019-12-30 01:17:03 -06:00
aliases = ["/docs/grafana/latest/http_api/snapshot/"]
2016-11-24 03:16:24 -06:00
+++
2016-02-03 00:59:22 -06:00
2016-02-05 03:47:34 -06:00
# Snapshot API
2016-02-03 00:59:22 -06:00
2016-02-05 03:47:34 -06:00
## Create new snapshot
2016-02-03 00:59:22 -06:00
`POST /api/snapshots`
**Example Request**:
2017-10-05 12:01:03 -05:00
```http
2016-02-03 00:59:22 -06:00
POST /api/snapshots HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"dashboard": {
"editable":false,
"hideControls":true,
"nav":[
{
"enable":false,
"type":"timepicker"
}
],
"rows": [
{
}
],
"style":"dark",
"tags":[],
"templating":{
"list":[
]
},
"time":{
},
"timezone":"browser",
"title":"Home",
"version":5
},
"expires": 3600
}
2017-10-05 12:01:03 -05:00
```
2016-02-03 00:59:22 -06:00
2017-06-13 16:17:14 -05:00
JSON Body schema:
- **dashboard** – Required. The complete dashboard model.
- **name** – Optional. snapshot name
2017-10-05 12:01:03 -05:00
- **expires** - Optional. When the snapshot should expire in seconds. 3600 is 1 hour, 86400 is 1 day. Default is never to expire.
2017-06-13 16:17:14 -05:00
- **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` .
2016-02-03 00:59:22 -06:00
**Example Response**:
2017-10-05 12:01:03 -05:00
```http
2016-02-03 00:59:22 -06:00
HTTP/1.1 200
Content-Type: application/json
{
"deleteKey":"XXXXXXX",
2018-05-24 01:55:16 -05:00
"deleteUrl":"myurl/api/snapshots-delete/XXXXXXX",
2016-02-03 00:59:22 -06:00
"key":"YYYYYYY",
2020-12-04 09:22:58 -06:00
"url":"myurl/dashboard/snapshot/YYYYYYY",
"id": 1,
2016-02-03 00:59:22 -06:00
}
2017-10-05 12:01:03 -05:00
```
2016-02-03 00:59:22 -06:00
Keys:
- **deleteKey** – Key generated to delete the snapshot
- **key** – Key generated to share the dashboard
2018-05-24 01:55:16 -05:00
## Get list of Snapshots
`GET /api/dashboard/snapshots`
Query parameters:
- **query** – Search Query
- **limit** – Limit the number of returned results
**Example Request**:
```http
GET /api/dashboard/snapshots HTTP/1.1
Accept: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
[
{
"id":8,
"name":"Home",
"key":"YYYYYYY",
"orgId":1,
"userId":1,
"external":false,
"externalUrl":"",
"expires":"2200-13-32T25:23:23+02:00",
"created":"2200-13-32T28:24:23+02:00",
"updated":"2200-13-32T28:24:23+02:00"
}
]
```
## Get Snapshot by Key
2016-02-03 00:59:22 -06:00
`GET /api/snapshots/:key`
**Example Request**:
2017-10-05 12:01:03 -05:00
```http
GET /api/snapshots/YYYYYYY HTTP/1.1
Accept: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 00:59:22 -06:00
**Example Response**:
2017-10-05 12:01:03 -05:00
```http
HTTP/1.1 200
Content-Type: application/json
{
"meta":{
"isSnapshot":true,
"type":"snapshot",
"canSave":false,
"canEdit":false,
"canStar":false,
"slug":"",
"expires":"2200-13-32T25:23:23+02:00",
"created":"2200-13-32T28:24:23+02:00"
},
"dashboard": {
"editable":false,
"hideControls":true,
"nav": [
{
"enable":false,
"type":"timepicker"
}
],
"rows": [
{
}
],
"style":"dark",
"tags":[],
"templating":{
"list":[
]
},
"time":{
},
"timezone":"browser",
"title":"Home",
"version":5
}
}
```
2016-02-03 00:59:22 -06:00
2018-05-24 01:55:16 -05:00
## Delete Snapshot by Key
`DELETE /api/snapshots/:key`
**Example Request**:
```http
DELETE /api/snapshots/YYYYYYY HTTP/1.1
Accept: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
2020-12-04 09:22:58 -06:00
{"message":"Snapshot deleted. It might take an hour before it's cleared from any CDN caches.", "id": 1}
2018-05-24 01:55:16 -05:00
```
2017-11-23 06:08:44 -06:00
## Delete Snapshot by deleteKey
2016-02-03 00:59:22 -06:00
2018-05-24 01:55:16 -05:00
This API call can be used without authentication by using the secret delete key for the snapshot.
2017-11-23 06:08:44 -06:00
`GET /api/snapshots-delete/:deleteKey`
2016-02-03 00:59:22 -06:00
**Example Request**:
2017-10-05 12:01:03 -05:00
```http
2018-05-24 01:55:16 -05:00
GET /api/snapshots-delete/XXXXXXX HTTP/1.1
2017-10-05 12:01:03 -05:00
Accept: application/json
```
2016-02-03 00:59:22 -06:00
**Example Response**:
2017-10-05 12:01:03 -05:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 00:59:22 -06:00
2020-12-04 09:22:58 -06:00
{"message":"Snapshot deleted. It might take an hour before it's cleared from any CDN caches.", "id": 1}
```