2022-05-26 23:06:25 +08:00
---
aliases:
2022-12-10 00:36:04 +08:00
- ../../http_api/snapshot/
2023-02-07 01:14:36 +08:00
canonical: /docs/grafana/latest/developers/http_api/snapshot/
2022-05-26 23:06:25 +08:00
description: Grafana HTTP API
keywords:
- grafana
- http
- documentation
- api
- snapshot
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 16:10:12 +08:00
labels:
products:
- enterprise
- oss
2024-08-30 16:27:24 +08:00
title: 'Snapshot API'
2022-05-26 23:06:25 +08:00
---
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
# Snapshot API
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Create new snapshot
2016-02-03 14:59:22 +08:00
`POST /api/snapshots`
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
2016-02-03 14:59:22 +08:00
POST /api/snapshots HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"dashboard": {
"editable":false,
"nav":[
{
"enable":false,
"type":"timepicker"
}
],
"rows": [
{
}
],
"style":"dark",
"tags":[],
"templating":{
"list":[
]
},
"time":{
},
"timezone":"browser",
"title":"Home",
"version":5
},
"expires": 3600
}
2017-10-06 01:01:03 +08:00
```
2016-02-03 14:59:22 +08:00
2017-06-14 05:17:14 +08:00
JSON Body schema:
- **dashboard** – Required. The complete dashboard model.
- **name** – Optional. snapshot name
2017-10-06 01:01:03 +08: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-14 05:17:14 +08: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` .
2025-06-20 00:31:13 +08:00
{{< admonition type = "note" > }}
2023-05-23 04:45:28 +08:00
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.
2025-06-20 00:31:13 +08:00
{{< / admonition > }}
2021-05-01 01:11:08 +08:00
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
2016-02-03 14:59:22 +08:00
HTTP/1.1 200
Content-Type: application/json
{
"deleteKey":"XXXXXXX",
2018-05-24 14:55:16 +08:00
"deleteUrl":"myurl/api/snapshots-delete/XXXXXXX",
2016-02-03 14:59:22 +08:00
"key":"YYYYYYY",
2020-12-04 23:22:58 +08:00
"url":"myurl/dashboard/snapshot/YYYYYYY",
2022-02-02 21:03:14 +08:00
"id": 1
2016-02-03 14:59:22 +08:00
}
2017-10-06 01:01:03 +08:00
```
2016-02-03 14:59:22 +08:00
Keys:
- **deleteKey** – Key generated to delete the snapshot
- **key** – Key generated to share the dashboard
2018-05-24 14:55:16 +08: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 14:59:22 +08:00
`GET /api/snapshots/:key`
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
GET /api/snapshots/YYYYYYY HTTP/1.1
Accept: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08: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,
"nav": [
{
"enable":false,
"type":"timepicker"
}
],
"rows": [
{
}
],
"style":"dark",
"tags":[],
"templating":{
"list":[
]
},
"time":{
},
"timezone":"browser",
"title":"Home",
"version":5
}
}
```
2016-02-03 14:59:22 +08:00
2018-05-24 14:55:16 +08: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 23:22:58 +08:00
{"message":"Snapshot deleted. It might take an hour before it's cleared from any CDN caches.", "id": 1}
2018-05-24 14:55:16 +08:00
```
2017-11-23 20:08:44 +08:00
## Delete Snapshot by deleteKey
2016-02-03 14:59:22 +08:00
2018-05-24 14:55:16 +08:00
This API call can be used without authentication by using the secret delete key for the snapshot.
2017-11-23 20:08:44 +08:00
`GET /api/snapshots-delete/:deleteKey`
2016-02-03 14:59:22 +08:00
**Example Request**:
2017-10-06 01:01:03 +08:00
```http
2018-05-24 14:55:16 +08:00
GET /api/snapshots-delete/XXXXXXX HTTP/1.1
2017-10-06 01:01:03 +08:00
Accept: application/json
```
2016-02-03 14:59:22 +08:00
**Example Response**:
2017-10-06 01:01:03 +08:00
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
2020-12-04 23:22:58 +08:00
{"message":"Snapshot deleted. It might take an hour before it's cleared from any CDN caches.", "id": 1}
```