The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →To create a Grafana snapshot programmatically, send POST /api/snapshots an authenticated JSON request containing the complete dashboard model—not just its UID. Set an expiry if you do not want the snapshot to remain available indefinitely, choose local or external storage, and handle the returned deletion credential as a secret. Grafana documents this legacy route, while warning that its API structure is changing in Grafana 13; verify the API reference for the Grafana instance you use.
What the Grafana Snapshot API creates
A snapshot is a shareable, point-in-time copy of a dashboard. It is not a live link that follows subsequent dashboard edits: create another snapshot when you need to share a later state. The API’s documented create route is POST /api/snapshots. Grafana Labs’ Snapshot API documentation says the request must include the full dashboard payload, including snapshot data, and describes the endpoint as designed for Grafana’s UI.
That distinction matters when automating snapshots. A dashboard UID identifies a dashboard, but the documented create request body needs the dashboard model itself. Do not send only a UID and expect the snapshot route to fetch and serialize the dashboard for you.
Check your Grafana version and API route
The documented endpoint uses the legacy /api route. Grafana’s API documentation says that starting in Grafana 13, /api endpoints are being deprecated in favor of /apis. The same documentation says legacy routes remain accessible and operative, although they will no longer be updated, and that an exact replacement may not exist for every route. This is a transition, not a reason to assume that POST /apis/snapshots is a supported replacement.
#1 Best Overall
Before implementing a client, check the API reference and live Swagger reference for the specific Grafana instance, its version, and its deployment. This is especially important if you run a managed service or upgrade Grafana independently from the automation that calls it. If the legacy route is present in that instance’s reference, use its documented request and response format; do not infer a replacement route from the new prefix.
Prepare authentication and the dashboard payload
Grafana’s API example authenticates with a service-account bearer token. Make the request from a trusted server or automation environment, not client-side browser code where credentials can be exposed. The token must be valid for the target Grafana instance and permitted to make the API request.
Prepare a JSON file containing the complete dashboard model required by the API. The example below assumes you have already obtained or exported the dashboard model and saved it as dashboard.json. Inspect that file before using it: it should be the actual model, not a small object containing only the dashboard UID. A snapshot captures dashboard data, so review its contents for information you do not intend to share.
Create a local snapshot with cURL
Set the Grafana base URL and token in your shell, then POST the model as JSON. This example sets an expiry of one day; the API measures expiry in seconds.
export GRAFANA_URL='https://grafana.example.com'
export GRAFANA_TOKEN='YOUR_SERVICE_ACCOUNT_TOKEN'
curl --fail-with-body --silent --show-error
-H "Authorization: Bearer ${GRAFANA_TOKEN}"
-H 'Content-Type: application/json'
--data-binary @-
"${GRAFANA_URL}/api/snapshots" <<'JSON'
{
"dashboard": {
"title": "Replace this object with the complete dashboard model"
},
"expires": 86400,
"external": false
}
JSON
The dashboard object shown is illustrative only; it is not a complete model and cannot create a valid snapshot as written. For an actual request, replace the object with the complete JSON model from your dashboard file. One way to preserve the full model without manually copying it into a shell command is:
Rank #2
python3 - <<'PY'
import json
from pathlib import Path
model = json.loads(Path("dashboard.json").read_text())
request = {
"dashboard": model,
"expires": 86400,
"external": False,
}
print(json.dumps(request))
PY
Pipe that output to the cURL request body, or use the Python example below. Do not mistake the demonstration title object for an API-ready dashboard.
Create a snapshot with Python
This script reads the complete model from dashboard.json, posts it to the local snapshot endpoint and prints the JSON response. It expects the token and Grafana URL in environment variables.
import json
import os
from pathlib import Path
import requests
grafana_url = os.environ["GRAFANA_URL"].rstrip("/")
token = os.environ["GRAFANA_TOKEN"]
dashboard = json.loads(Path("dashboard.json").read_text(encoding="utf-8"))
response = requests.post(
f"{grafana_url}/api/snapshots",
headers={
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
},
json={
"dashboard": dashboard,
"expires": 86400,
"external": False,
},
timeout=30,
)
response.raise_for_status()
result = response.json()
print(json.dumps(result, indent=2))
Install the Python dependency with python -m pip install requests in the environment running the script. A successful response is documented to include id, key, url, deleteKey and deleteUrl. Save the share URL for the intended audience, and store deletion credentials separately with restricted access.
Choose expiry and storage deliberately
Expiry
The optional expires value is a duration in seconds. Grafana gives 3600 for one hour and 86400 for one day. If you omit the field, the documented default is that the snapshot does not expire. That makes omission a consequential choice: set a duration when the share should be temporary, and avoid treating a long-lived URL as harmless simply because it is difficult to guess.
Local or external storage
The optional external field defaults to false, meaning local storage. For external storage, Grafana’s documentation requires both key and deleteKey. They are separate values: the key identifies the snapshot, while the deletion key is intended to let its creator delete it. Configure external storage only where the target deployment supports it, and do not reuse the same value for both fields.
Rank #3
Grafana’s sharing guide notes that custom panels cannot be published to snapshot.raintank.io. If your dashboard relies on custom panels and you plan to publish externally, confirm compatibility before creating the share.
Use the returned URL, list, retrieve and delete snapshots
The create response includes a share URL and keys used by the other documented routes. The snapshot key is not the same as the deletion secret. Anyone with a snapshot link can view it, so share that URL only with people who may see the captured dashboard data.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
| Task | Documented route | What to know |
|---|---|---|
| Create | POST /api/snapshots |
Requires the full dashboard model; optional fields include name, expires, external, key and deleteKey. |
| List | GET /api/dashboard/snapshots |
Accepts query and limit; the documented default limit is 1000 if limit is absent or invalid. |
| Retrieve | GET /api/snapshots/:key |
Use the snapshot key from the create response. |
| Delete with authentication | DELETE /api/snapshots/:key |
Uses the snapshot key and authenticated API access. |
| Delete with secret | GET /api/snapshots-delete/:deleteKey |
Can be called without authentication; protect the deletion key as a credential. |
For example, to delete using the authenticated key, substitute the key and request:
curl --fail-with-body
-X DELETE
-H "Authorization: Bearer ${GRAFANA_TOKEN}"
"${GRAFANA_URL}/api/snapshots/SNAPSHOT_KEY"
Deletion may take up to an hour to clear from CDN caches, according to Grafana’s API documentation. Do not treat a still-rendering cached copy during that period as evidence that the delete request was ignored.
Privacy and sharing checks
Grafana’s sharing guide puts the access rule plainly: anyone with the link can view a snapshot. A snapshot URL is therefore a bearer-style share link, not proof that a viewer is an authenticated Grafana user. Before creating or distributing one, inspect the dashboard state and decide whether the audience should see its panels and captured data.
Rank #4
- Use a finite expiry for temporary reviews or handoffs.
- Keep the deletion key out of tickets, public chat, source control and shared logs.
- Share the snapshot URL only with its intended audience; anyone who obtains it can view the snapshot.
- Choose local or external storage based on the target instance and your publication needs.
- For external publishing, account for Grafana’s documented custom-panel limitation for snapshot.raintank.io.
Troubleshoot common failures
The request is rejected or the response is an error
Check that the target instance exposes the legacy route, that the base URL does not contain a duplicate path, and that the token is valid for that instance. Confirm that the request sends JSON with an Authorization: Bearer header and a Content-Type: application/json header. Consult that instance’s API reference if its version or deployment differs from the one used to write the client.
The API does not create the expected dashboard snapshot
Check the request body first. The create operation needs the complete dashboard model; a UID by itself is not the documented payload. Also verify that your client has not accidentally wrapped the model incorrectly or replaced it with an example object. Compare the posted dashboard value with the full model file you intended to send.
The snapshot remains available longer than expected
Confirm that expires is present and expressed in seconds. Omitting it means no expiry under the documented API behavior. If deletion was successful but a copy still appears, allow for the documented CDN cache delay of up to an hour.
An external snapshot does not work as expected
Verify that both key and deleteKey are supplied when external is enabled, and check the target deployment’s external-storage setup. If the dashboard uses custom panels, account for Grafana’s stated limitation on publishing those panels to snapshot.raintank.io.
A user can still view a shared snapshot
That is expected for anyone holding the share link until the snapshot expires or is deleted and cached copies clear. Treat the URL as accessible to whoever receives or discovers it, and rotate your response plan accordingly if it was shared too broadly.
Best Value
Performance, reliability and cost considerations
The request carries the dashboard model as part of its body, so build automation around the actual model rather than assuming that the API can resolve a UID. Keep snapshots only as long as their use requires, and retain the returned identifiers in a place where you can manage or delete them later. For workflows that generate many snapshots, track the response status and returned URL/key per request so a failed create is not confused with a successful one.
The cited Grafana API and sharing documentation does not establish a universal request rate, payload-size limit, or snapshot cost across Grafana deployments. Those operational details depend on the target service and are not specified here; check your deployment’s own API reference and service terms rather than assuming a global limit or price.
Or skip the browser setup
The Grafana Snapshot API creates a shareable dashboard snapshot; a website screenshot API is a different tool for capturing a rendered page as an image or PDF. If your actual need is a clean page capture rather than a Grafana-managed snapshot, ScreenshotNeo takes a screenshot in one GET request. Its API removes cookie banners, newsletter popups and chat widgets before the shot; bot checks, blank pages and failed loads are never billed. It also provides an MCP server for AI agents to take screenshots, and includes 1,000 screenshots a month free with no card, with paid plans starting at $5 for 3,000.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options and setup. If that fits your use case, sign up for 1,000 free screenshots a month with no card.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallFrequently Asked Questions
Can I call the Snapshot API directly from frontend JavaScript?
Avoid putting a Grafana bearer token in browser code, where visitors can inspect and reuse it. Make authenticated snapshot requests from a trusted server or automation environment, and return only the share URL your application intends to expose.
Quick Recap
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.

