Back to 🚢 DevOps & Deployment

Setup Vercel Cron Jobs

VercelCronAutomation
---
description: Create and test scheduled tasks in Next.js
---

1. **Create Cron Config**:
- Add crons to vercel.json.
{
"crons": [
{
"path": "/api/cron/daily-report",
"schedule": "0 10 * * *"
}
]
}


2. **Create API Route**:
- Create the endpoint at src/app/api/cron/daily-report/route.ts.
import { NextResponse } from 'next/server';

export async function GET(request: Request) {
// Verify the request is from Vercel Cron
const authHeader = request.headers.get('authorization');
if (authHeader !== Bearer ${process.env.CRON_SECRET}) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}

// Your cron job logic here
console.log('Daily report cron executed');

return NextResponse.json({ success: true });
}


3. **Set Environment Variable**:
- Add CRON_SECRET to your .env.local and Vercel project settings.
- Generate a secure random string: openssl rand -base64 32

4. **Pro Tips**:
- Vercel sends an Authorization: Bearer <token> header with cron requests.
- Test locally by manually calling the endpoint with the correct header.
- Cron expressions use UTC timezone.
By Antigravity Team

How to Use This Workflow

Option A: Project-Specific (Recommended)

  1. Click "Download" above
  2. In your project, create the directory: .agent/workflows/
  3. Save the file as setup-vercel-cron-jobs-scheduled-tasks.md
  4. In Antigravity, type /setup_vercel_cron_jobs_scheduled_tasks or just describe what you want to do

Learn more about workflows →

Related Workflows

Recommended Rules

View more rules →

Recommended MCP Servers

View more MCP servers →

Take It Further

Maximize your productivity with these powerful resources

📋

Define Your Standards

Set up coding standards to ensure this workflow produces consistent, high-quality results.

Browse Rules Library
📖

Master Workflows

Learn how to create custom workflows, use Turbo Mode, and build your automation library.

Complete Guide