Vercel supports cron jobs for Serverless and Edge Functions. Cron jobs can be added through vercel.json or the Build Output API.
Cron jobs are time-based scheduling tools used to automate repetitive tasks. By using a specific syntax called a cron expression, you can define the frequency and timing of each task. This helps improve efficiency and ensures that important processes are performed consistently.
Some common use cases of cron jobs are:
- Automating backups and archiving
- Sending email and Slack notifications
- Updating Stripe subscription quantities
The following steps will demonstrate how to create a cron job on Vercel that executes every day at 5 am UTC:
First, create a Serverless or Edge Function for your project. The function will be called every time the cron job is triggered.
Go to your vercel.json
file and add the following code:
{
"crons": [
{
"path": "/api/cron",
"schedule": "0 5 * * *"
}
]
}
- The
path
must start with/
- The
schedule
property 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
Once your project is deployed on Vercel, our build process will create the cron job. Cron jobs are invoked only for production deployments. Preview deployments are ignored.
You can also deploy to your production domain through Git.
vercel deploy --prod
Your cron job is now active and will call the /api/cron
path every day at 5:00 am UTC.
To trigger a cron job, Vercel makes an HTTP GET request to your project's production deployment URL, using the path
provided in your project's vercel.json
file. An example endpoint Vercel would make a request to in order to trigger a cron job might be: https://*.vercel.app/api/cron
.
Vercel supports the following cron expressions format:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (0 is Sunday, 6 is Saturday)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
Here are a few example expressions and their schedule:
Cron expression | Description |
---|---|
* * * * * | Triggers every minute |
*/10 * * * * | Triggers every ten minutes |
0 * * * * | Triggers at the beginning of every hour |
0 3 * * * | Triggers every day at 3:00 am |
10 5 * * 0 | Triggers every Sunday at 5:10 am |
The following websites can be used to create cron expressions:
Some considerations:
- We do not support alternative expressions like
MON
,SUN
,JAN
, orDEC
- You cannot configure both day of the month and day of the week at the same time. When one has a value, the other must be
*
- The timezone is always UTC
To view your active cron jobs, select the project from the Vercel dashboard and click the Cron Jobs tab.


- To update cron jobs, change its expression in
vercel.json
file or the function's configuration, and then redeploy - To delete cron jobs, remove the configuration from the
vercel.json
file or the function's configuration, and then redeploy - To disable cron jobs for a project, navigate to the Cron Jobs tab and then click the Disable Cron Jobs button
Disabled cron jobs will still be listed and will count towards your Cron Jobs limits.
Cron jobs invoke Serverless or Edge Functions. This means the same usage and pricing limits will apply. There's currently a hard limit of 20 cron jobs per project during the beta phase.
Number of cron jobs | Schedule | |
---|---|---|
Hobby | 2 cron jobs | Triggered once a day |
Pro | 40 cron jobs | Unlimited cron invocations |
Enterprise | 100 cron jobs | Unlimited cron invocations |
On the Hobby plan, we cannot assure a timely cron job invocation. For example, a cron job configured as 0 1 * * *
(every day at 1 am) will trigger anywhere between 1:00 am and 1:59 am. For more accurate and timely cron job executions, upgrade to our Pro plan.
Cron jobs duration limits are the same as Serverless and Edge functions limits:
Serverless Functions | Edge Functions | |
---|---|---|
Hobby | 10s | 25s |
Pro | 60s (default) - configurable up to 300s | 25s |
Enterprise | 900s | 25s |
In most cases, these limits are sufficient. However, it's recommended to split your cron jobs into different units if you need more processing time. You can also combine cron jobs with regular HTTP requests with your API if you want to distribute your workload.
While in beta, cron jobs are free on all plans. However, it'll be a paid feature for general availability.
When a cron job fails, Vercel will not retry an invocation. You can check for error logs through the View Log button in the Cron Jobs tab.
There is currently no built-in way to secure cron jobs, but you can use the query string of a path
to share a key with your function.
First, add a shared query parameter to the path
property of your cron job (key
in this example):
{
"crons": [
{
"path": "/api/cron?key=sharedKey",
"schedule": "0 5 * * *"
}
]
}
Then, check the shared query parameter (key=sharedKey
) in your function code:
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const sharedKey = searchParams.get('sharedKey');
if (!sharedKey) {
return new Response('Failed to get sharedKey', { status: 200 });
}
return new Response('Successfully got sharedKey', { status: 200 });
}
Yes, you can create a cron job for a dynamic route as follows:
{
"crons": [
{
"path": "/api/sync-slack-team/T0CAQ10TZ",
"schedule": "0 5 * * *"
},
{
"path": "/api/sync-slack-team/T4BOE34OP",
"schedule": "0 5 * * *"
}
]
}
If you create a cron job for a path that does not exist, it generates a 404. In that case, Vercel still executes your cron job. You can analyze your logs to check if there are any issues.
No. If you create a new deployment, your running cron jobs will continue until they finish.
When a cron job takes too long to run, you can expect two concurrent cron job invocations. This could create problems. In such cases, it's recommended to implement a lock mechanism in your cron job by using Redis for example.
Alternatively, you can ensure your cron job is fast enough or should timeout if it runs for too long.
Cron jobs are API routes. You can run them locally by making a request to their endpoint. For example, if your cron job is in /api/cron
, you could visit the following endpoint in your browser: http://localhost:3000/api/cron
.
There's no support for vercel dev
, next dev
, or other framework-native local development servers.
Was this helpful?