# Introducing Scheduled Functions

**Version:** v2026-05-07

**Published:** May 7, 2026

Scheduled Functions are now available. They run on a timer instead of in response to document events. Use them for daily digests, cache expiration, periodic content syncs, or any task that needs to happen on a fixed cadence.

## Run code on a schedule

Define a scheduled function with `defineScheduledFunction` from `@sanity/blueprints`. Schedules accept either a UNIX cron expression or an explicit object with `minute`, `hour`, `dayOfWeek`, `month`, and `dayOfMonth` fields.

**sanity.blueprint.ts**

```
import {defineBlueprint, defineScheduledFunction} from '@sanity/blueprints'

export default defineBlueprint({
  resources: [
    defineScheduledFunction({
      name: 'expire-cache',
      event: {expression: '0 0 * * *'},
    }),
  ],
})
```

Inside the function, the `scheduledEventHandler` helper from `@sanity/functions` gives you typed access to the run context.

**functions/expire-cache/index.ts**

```
import {scheduledEventHandler} from '@sanity/functions'

export const handler = scheduledEventHandler(async ({context}) => {
  const time = new Date().toLocaleTimeString()
  console.log(`👋 Your Sanity Function was called at ${time}`)
})
```

## Get started

Add a scheduled function with the CLI:

**CLI**

```sh
npx sanity@latest functions add --name expire-cache --type scheduled-function --language ts
```

Scheduled functions run independently of any single project, so they require an [organization-scoped blueprint stack](https://www.sanity.io/docs/blueprints/promote-stack-to-organization-scope). If your stack is project-scoped, run `npx sanity@latest blueprints promote` before deploying.

Read the [Create a Scheduled Function quickstart](https://www.sanity.io/docs/functions/scheduled-function-quickstart) for a step-by-step walkthrough, or browse the [Functions documentation](https://www.sanity.io/docs/functions/functions-introduction).

