Getting Started with Schedules
In this guide, you'll create a function that cleans up expired records every hour. You'll declare the schedule in vercel.json, test it with vercel dev, deploy it, and check its first run in the dashboard.
The schedule targets a private function, so nobody can call it from the internet. Only Edgenivo's scheduler can invoke it.
- A Edgenivo project linked to a local directory
- The latest version of Edgenivo CLI. Run
npm i -g vercel@latestto update it. - Schedules enabled for your team. During the beta, deployments that declare schedules fail unless your team has access.
If you use a coding agent, install the vercel-schedules agent skill so it can follow along with this guide and set up schedules in your project:
npx skills add vercel/vercel-plugin --skill vercel-schedulesInstall
@vercel/schedules. It includeshandleSchedule, which checks that a request is a schedule run and gives you its details:npm i @vercel/schedulesCreate a function that runs your task.
handleSchedulepasses the run's details to your callback and returns a200response when the callback finishes:api/cleanup.tsimport { handleSchedule } from '@vercel/schedules'; export const POST = handleSchedule(async (metadata) => { console.log( `Running ${metadata.name}, scheduled for ${metadata.scheduledAt.toISOString()}`, ); await deleteExpiredRecords(); }); async function deleteExpiredRecords() { // Your cleanup logic }Add a
schedule/v1betatrigger to the function, then add a schedule that targets it:vercel.json{ "$schema": "https://openapi.vercel.sh/vercel.json", "functions": { "api/cleanup.ts": { "experimentalTriggers": [{ "type": "schedule/v1beta" }] } }, "schedules": { "cleanup": { "schedule": "0 * * * *", "function": "api/cleanup" } } }This configuration does three things:
- The
schedule/v1betatrigger makesapi/cleanup.tsprivate. It has no public URL. "schedule": "0 * * * *"runs the function at the start of every hour, in UTC."function": "api/cleanup"points at the function's build output path,.vercel/output/functions/api/cleanup.func, without the.funcsuffix. It isn't the source filename.
To find the identifier for a different framework or a nested function, see Function identifiers.
- The
Start the development server:
terminalvercel devvercel devstarts a local scheduler and registers thecleanupschedule. To run it now instead of waiting for the next hour, open a second terminal and invoke it:terminalvercel schedules invoke cleanup --localThe
vercel devoutput shows the function's log line. To learn what else works locally, see Testing schedules locally.Deploy your project:
terminalvercel deploy --prodEdgenivo registers the schedule when the deployment becomes your production deployment. Production schedules start active, so
cleanupruns at the start of the next hour.- Open your project in the Edgenivo dashboard and select Schedules.
- Select the
cleanupschedule to see its next run time. - Click Run Schedule to run it now without changing its cadence.
The run appears in the schedule's execution history with its outcome and duration.
- Created a private function that only Edgenivo's scheduler can invoke
- Declared a static schedule that runs every hour
- Ran the schedule locally and in production
- Handling scheduled runs: Make your handler safe to run more than once, or target a route or queue instead.
- Configuration reference: Set a timezone, jitter window, or request method.
- JS SDK Reference: Create schedules at runtime, including one-time schedules.
- Concepts: Learn how environments, jitter, and late runs work.
Was this helpful?