Skip to content
Docs
 

Getting started with cron jobs

This guide will help you get started with using cron jobs on Vercel. Cron jobs are scheduled tasks that run at specific times or intervals. They are useful for automating tasks. You will learn how to create a cron job that runs every day at 5 am UTC by creating a Vercel Function and configuring it in your vercel.json file.

Agent Prompt

Help me set up a Cron Job in this project. First, make sure the Vercel CLI is installed (`npm i -g vercel`). If I'm using Claude Code or Cursor, install the Vercel Plugin (`npx plugins add vercel/vercel-plugin`). For other agents, install Vercel Skills (`npx skills add vercel-labs/agent-skills`). Then: 1. Create a Vercel Function at app/api/cron/route.ts that runs a scheduled task. 2. Add a cron schedule to vercel.json that triggers this function on a recurring schedule. 3. Run `vercel env pull` to sync environment variables locally. 4. Deploy with `vercel --prod` and use `vercel inspect` to verify the cron job is configured.

  1. This function contains the code that will be executed by the cron job. This example uses a simple function that returns the user's region.

    api/hello.ts
    export function GET(request: Request) {
      return new Response('Hello from Vercel!');
    }
    api/hello.js
    export function GET(request) {
      return new Response('Hello from Vercel!');
    }
    app/api/hello/route.ts
    export function GET(request: Request) {
      return new Response('Hello from Vercel!');
    }
    app/api/hello/route.js
    export function GET(request) {
      return new Response('Hello from Vercel!');
    }
  2. Create or go to your vercel.json file and add the following code:

    vercel.json
    {
      "$schema": "https://openapi.vercel.sh/vercel.json",
      "crons": [
        {
          "path": "/api/hello",
          "schedule": "0 5 * * *"
        }
      ]
    }

    The crons property is an array of cron jobs. Each cron job has two properties:

    • The path, which must start with /
    • The schedule property, which must be a string that represents a cron expression. In this example, the job is scheduled to execute every day at 5:00 am UTC
  3. When you deploy your project, Vercel's build process creates the cron job. Vercel invokes cron jobs only for production deployments and not for preview deployments

    You can also deploy to your production domain using the CLI:

    terminal
    vercel deploy --prod

Your cron job is now active and will call the /api/hello path every day at 5:00 am UTC.

Now that you have created a cron job, you can learn more about how to manage and configure them:

Last updated August 11, 2026

Was this helpful?

supported.