Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To create a Grafana snapshot programmatically, send a JSON POST request to /api/snapshots with a service-account bearer token and the complete dashboard model, including its snapshot data. A dashboard UID by itself is not the documented payload. Choose whether the snapshot is stored locally or externally, set an expiry if it should not remain indefinitely, and protect the returned deletion key.

This is Grafana’s legacy /api route. Grafana’s documentation says the transition toward /apis begins with Grafana 13, but an exact replacement may not exist for every route. Check the API reference for your own Grafana version and deployment before relying on this endpoint.

What the Grafana Snapshot API does

A snapshot is a point-in-time copy of a dashboard that can be shared by URL. It is not a live dashboard: recipients see the captured snapshot rather than a continuously refreshed view. Grafana’s Snapshot API documentation requires the full dashboard payload, including snapshot data, and cautions that the create endpoint is designed for use by the Grafana UI.

The documented legacy API operations are:

Action Method and route Purpose
Create POST /api/snapshots Publish a snapshot from a complete dashboard model.
List GET /api/dashboard/snapshots List snapshots; the documented query parameters include query and limit.
Retrieve GET /api/snapshots/:key Retrieve a snapshot using its share key.
Delete by key DELETE /api/snapshots/:key Delete using the snapshot key with authentication.
Delete by secret GET /api/snapshots-delete/:deleteKey Delete using the deletion key; the documented route can be used without authentication.

These routes and parameters are documented by Grafana’s Snapshot API reference. The listing route’s documented default limit is 1,000 when limit is omitted or invalid.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check compatibility with your Grafana version

Grafana’s current documentation says that starting in Grafana 13, /api endpoints are being deprecated in favor of the /apis route. It also says legacy endpoints remain accessible and operative, while no longer being updated; an exact replacement may not yet exist for every endpoint. Consequently, do not infer that this snapshot route is already unavailable or that a guessed /apis equivalent works.

  1. Identify the Grafana version and deployment you will call.
  2. Consult that instance’s API reference or Swagger documentation and confirm the snapshot operations it exposes.
  3. Use the documented route for that instance. If the legacy operation is present, the examples below use its documented path.

Prepare the dashboard payload

The create request needs a dashboard property containing the full dashboard model and snapshot data. Supplying only a dashboard UID does not meet the documented requirement. The model must represent the snapshot you intend to publish; a normal dashboard reference is not a substitute for the complete payload.

The create operation also accepts optional fields:

  • name: a name for the snapshot.
  • expires: lifetime in seconds. Grafana’s examples use 3600 for one hour and 86400 for one day. If omitted, the API documentation says the snapshot does not expire.
  • external: whether to use external snapshot storage; it defaults to false.
  • key and deleteKey: required by the documentation when using external storage. They are distinct values, and the deletion key is intended to let the creator delete the snapshot.

Use a finite expiry when a snapshot only needs to be available temporarily. If you omit it, treat that as a deliberate choice to leave the snapshot without an API-set expiration.

Create a snapshot with cURL

Set the base URL to your Grafana instance, replace the token placeholder, and provide a JSON file containing the complete payload. For example, snapshot.json might contain the dashboard model supplied by the process that prepares the snapshot:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
{
  "dashboard": {
    "title": "Example snapshot",
    "panels": []
  },
  "name": "Example snapshot",
  "expires": 3600,
  "external": false
}

This abbreviated object illustrates the request shape; it is not a complete dashboard model for a real dashboard. Use the complete model and snapshot data required by your Grafana instance.

curl -X POST "https://grafana.example.com/api/snapshots" 
  -H "Authorization: Bearer YOUR_SERVICE_ACCOUNT_TOKEN" 
  -H "Content-Type: application/json" 
  --data-binary @snapshot.json

Grafana’s API example uses service-account bearer-token authentication. The response documents fields including deleteKey, deleteUrl, key, url, and id. Save the share URL for the intended recipients, and store the deletion credential separately as a secret.

Make the same request with Python

This example uses the standard library, sends a JSON body, and prints the response so you can inspect the returned URL and keys:

import json
import urllib.request

base_url = "https://grafana.example.com"
token = "YOUR_SERVICE_ACCOUNT_TOKEN"

with open("snapshot.json", "r", encoding="utf-8") as f:
    payload = json.load(f)

request = urllib.request.Request(
    f"{base_url}/api/snapshots",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {token}",
        "Content-Type": "application/json",
    },
    method="POST",
)

with urllib.request.urlopen(request, timeout=30) as response:
    print(response.status)
    print(response.read().decode("utf-8"))

Keep the token outside source control and avoid logging the deletion key alongside ordinary application logs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make the same request with Node.js

In a Node.js runtime with built-in fetch, read the payload from the same JSON file:

import { readFile } from "node:fs/promises";

const baseUrl = "https://grafana.example.com";
const token = "YOUR_SERVICE_ACCOUNT_TOKEN";
const payload = JSON.parse(await readFile("snapshot.json", "utf8"));

const response = await fetch(`${baseUrl}/api/snapshots`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${token}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});

const responseText = await response.text();
if (!response.ok) {
  throw new Error(`Grafana returned ${response.status}: ${responseText}`);
}
console.log(responseText);

For production code, parse the successful JSON response and handle its returned fields explicitly rather than treating the response body as an opaque string.

Choose storage and manage snapshot access

Local or external storage

The API’s external option defaults to false. If you choose external storage, provide both key and deleteKey as required by Grafana’s documentation. Keep the share key and deletion key separate: one identifies the snapshot for viewing, while the other enables deletion.

Sharing is access

Grafana’s dashboard-sharing guide says anyone with a snapshot link can view it. Treat the link as accessible to anyone who obtains it, not as a private invitation tied to a particular user. Review the dashboard content before publishing and only share data appropriate for that audience.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Delete carefully

Grafana documents deletion by authenticated DELETE /api/snapshots/:key and by calling GET /api/snapshots-delete/:deleteKey, which can be used without authentication. Because the latter relies on the secret itself, anyone who obtains that deletion key may be able to invoke it. Do not expose it in public pages, client-side code, or shared logs.

A successful deletion may not make the snapshot disappear everywhere immediately: Grafana says CDN caches can take up to an hour to clear.

List and retrieve snapshots

To list snapshots, call GET /api/dashboard/snapshots. The documented query parameters include query and limit; when limit is not set or is invalid, the documented default is 1,000. To retrieve one by its share key, call GET /api/snapshots/:key. Use the exact behavior shown by the API reference for your Grafana version, especially if you are building automation that must work across deployments.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

  • Request rejected because the payload is incomplete: include the entire dashboard model and snapshot data under dashboard; a UID alone is insufficient.
  • Authentication fails: verify the bearer token is valid for the target Grafana deployment and is sent in the Authorization header in the form Bearer TOKEN.
  • External-storage creation fails: confirm that both key and deleteKey are supplied when external is enabled.
  • A snapshot link exposes more than intended: anyone with the link can view it. Review the dashboard before creating or distributing the snapshot; do not assume the link restricts access to named recipients.
  • A deleted snapshot still appears: allow for CDN cache clearing, which Grafana says may take up to an hour.
  • The route or behavior differs on a newer Grafana deployment: check that instance’s API reference. Grafana’s Grafana 13 transition note concerns legacy /api endpoints, but it does not establish a one-to-one replacement for this route.
  • External snapshots do not support a panel: Grafana’s sharing guide says custom panels cannot be published to snapshot.raintank.io. Consider local storage or another supported way to share the dashboard if that limitation applies.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server, not a Grafana Snapshot API replacement: it captures a URL as an image or PDF rather than creating a Grafana snapshot object. If your need is a rendered visual capture of a dashboard page that you can access, a single request can take that shot. See the ScreenshotNeo API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://grafana.example.com/d/your-dashboard -o shot.webp

Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; each of those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Frequently Asked Questions

Can I create a snapshot by sending only a dashboard UID?

No. Grafana’s documented create request requires the complete dashboard model, including snapshot data.

Does deleting a snapshot immediately remove every copy of its link?

Not necessarily. Grafana says CDN caches can take up to an hour to clear after deletion.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.