Weekly
Export your Sanity dataset every week
Each Sunday an export of your dataset is taken and you get an email confirming what it covers.
- Runs
- Weekly
- Apps
- Sanity
- AI
- Not needed
- Access
- Viewer
Send this to your assistant
Create a ClickRuntime automation: every Sunday at 2am, export my Sanity production dataset and email me a summary of the export with the number of documents in it.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Content in Sanity feels safe because it lives in a hosted service, yet a mistaken bulk mutation, a script that patches the wrong field, or a deleted dataset can still destroy months of editorial work. Teams that rely on Sanity as the source of truth for a website often have no copy outside it. Sanity keeps history for documents, but restoring a whole dataset after a faulty migration is a stressful, slow exercise when there is no export to start from.
Once a week the automation calls Sanity's export endpoint for your dataset, compresses the result, and emails you a summary with the link or attachment. You end up with a dated archive of every document and asset reference. It requires no one to run the CLI. Agencies and small product teams use it as a simple, regular safety copy.
What you get out of it
Recovery from a bad migration
If a script overwrites a field across thousands of documents, last week's export lets you compare and restore the original values. Without it you reconstruct content from the website's cache, if you can.
Content survives account or access problems
An export sitting in your mailbox does not depend on Sanity account access, a project deletion or a billing issue. That is the kind of independence that matters when the unexpected arrives.
Easy move to a new dataset
Teams often create a staging or new production dataset from a recent export. Having regular files means that task takes minutes rather than needing someone to remember the CLI command.
Handover and compliance copies
When an agency hands a site to a client, or legal asks for a record of published content on a given date, a dated export answers the request without a rushed manual job.
Weekly cadence matches editing pace
Most content teams change enough in a week to matter but not in a day. A weekly export means you lose at most a week of changes in a worst-case scenario.
How it works
What happens, step by step
Every Sunday, ClickRuntime takes a full export of your Sanity dataset.
It counts the documents in the export by type.
You get an email confirming the export, with the total and a count per type.
Before it runs live
- Connect Sanity
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Run it at a different time, more or less often, or only on weekdays
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Sanity steps into one automation
Under the hood
The code that runs this automation
from collections import Counter
from clickruntime import on_trigger, credentials, http, notify
import json
PROJECT_ID = "your-project-id"
DATASET = "production"
@on_trigger
def run(event):
token = credentials.secret("SANITY_TOKEN")
resp = http.get(f"https://{PROJECT_ID}.api.sanity.io/v2021-06-07/data/export/{DATASET}",
headers={"Authorization": f"Bearer {token}"}, timeout=120)
resp.raise_for_status()
docs = [json.loads(line) for line in resp.text.splitlines() if line.strip()]
types = Counter(d.get("_type", "unknown") for d in docs)
lines = [f"{t}: {n}" for t, n in types.most_common(15)]
notify.email_me(f"Sanity export: {len(docs)} documents in {DATASET}",
f"Exported {len(docs)} documents ({len(resp.content) // 1024} KB).\n\n" + "\n".join(lines))
return {"documents": len(docs)}FAQ
Common questions
Does the export include images and files?
How big can the exported file get for email?
Can I back up a private dataset?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Get a weekly count of published documents
Every Monday you see how many documents went out last week, broken down by type.
See how it worksAnnounce published Sanity documents in Slack
When a post is published, your channel gets its title and document type within moments.
See how it worksKnow the moment your website goes down
Your team hears in Slack when the site stops responding or slows down, and again when it's back.
See how it worksKeep exploring
Set up “Export your Sanity dataset every week” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.