Weekly
Get a weekly count of published documents
Every Monday you see how many documents went out last week, broken down by type.
- Runs
- Weekly
- Apps
- Sanity
- AI
- Not needed
- Access
- Viewer
Send this to your assistant
Create a ClickRuntime automation: every Monday at 8am, count the Sanity documents published in the last 7 days, group them by type (post, product, page), and email me the totals.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
An editor in chief wants to know how much the team actually published this week: how many blog posts, how many product pages, how many case studies. Sanity can answer that, but only through a query written in GROQ or by clicking through the Studio and counting. So the weekly update is a guess, or someone spends twenty minutes counting, and the numbers are different every time because nobody used the same method or date range.
Each week the automation runs a GROQ query for documents updated since the start of the period, groups them by type, and emails you the counts. The same query runs every time, so week-to-week comparisons are fair. It needs no Studio login to read the result. Content leads, marketing managers and agencies reporting to clients use it as a plain weekly output summary.
What you get out of it
Output measured the same way each week
A fixed query and date range mean the count in week 12 is comparable to week 11. Trends show real changes in activity, not differences in how someone counted. A count of 14 posts in week 12 and 9 in week 11 means something because the rules never changed.
Client reports without manual counting
Agencies can include a content summary in a weekly client update without opening the Studio. The numbers are ready on schedule, which makes the report feel dependable. An agency can paste the weekly counts straight into the Friday client email without opening the Studio.
Gaps in the content plan are visible
If no case studies appear for three weeks in a row, the report makes that obvious. Editors can then adjust the plan while the quarter's goals are still reachable. Three weeks with zero case studies stands out in a table when it would hide in a busy Studio.
Workload is easier to discuss
Counts per document type give a factual basis for talking about capacity. A team that publishes forty updates a week can show that it needs help, rather than only claiming it feels busy.
A running record of publishing history
Weekly emails accumulate into a record of what was produced and when. That is useful when reviewing a quarter, preparing a budget, or explaining a change in website traffic. By autumn you can see that March's product launch produced twice the usual number of landing pages.
How it works
What happens, step by step
Every Monday, ClickRuntime asks Sanity for the documents published in the last week.
It groups them by type and counts each.
You get an email with the total and a line 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
import json
from collections import Counter
from datetime import datetime, timedelta, timezone
from clickruntime import on_trigger, credentials, http, notify
PROJECT_ID = "abcd1234"
@on_trigger
def run(event):
since = (datetime.now(timezone.utc) - timedelta(days=7)).isoformat()
resp = http.get(f"https://{PROJECT_ID}.api.sanity.io/v2021-10-21/data/query/production",
headers={"Authorization": f"Bearer {credentials.secret('SANITY_TOKEN')}"},
params={"query": '*[_type in ["post", "product", "page"] && !(_id in path("drafts.**")) '
'&& _updatedAt > $since]{_type}', "$since": json.dumps(since)})
resp.raise_for_status()
counts = Counter(d["_type"] for d in resp.json()["result"])
lines = [f"{t}: {counts.get(t, 0)}" for t in ("post", "product", "page")]
notify.email_me(f"Sanity: {sum(counts.values())} documents published this week", "\n".join(lines))
return dict(counts)FAQ
Common questions
Does the count include drafts or only published documents?
Is a document counted again if it was only edited?
Can I get a list of titles along with the counts?
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
Export your Sanity dataset every week
Each Sunday an export of your dataset is taken and you get an email confirming what it covers.
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 “Get a weekly count of published documents” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.