Skip to content

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.

Paste it into your assistant. It tells you what it will send or change before it runs live.

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

  1. Every Monday, ClickRuntime asks Sanity for the documents published in the last week.

  2. It groups them by type and counts each.

  3. You get an email with the total and a line per type.

Before it runs live

  • Connect Sanity

What you get

RunsWeekly
Get a weekly count of published documentstoday, 9:00Succeeded
Email · Sanity: 14 documents published this weekpost: 6 product: 5 page: 3

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • 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

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
weekly_content_report.pyexample
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?
It depends on the query. Documents carry a _updatedAt value for drafts and published versions, so the query can be written to exclude IDs starting with drafts. to count only published content, or to include everything.
Is a document counted again if it was only edited?
The query uses _updatedAt, so an edit to an existing document changes its date and counts it. If you want only newly created documents, use _createdAt instead, which counts each document once, on the week it was first created.
Can I get a list of titles along with the counts?
Yes. The GROQ query can also return the title and type of each updated document, and the email can include them under each type. For busy datasets, a short list of the top few per type keeps it readable.
What permissions does it need?
Viewer. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (weekly). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

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.