Skip to content
HookPulse

Monitor Vercel Cron Jobs with HookPulse check-ins

The function checks in when the job ends and reports the failure. Vercel calls it on the schedule in vercel.json.

Updated

1Create the monitor

Add a routine named vercel-cron and set how often the job runs. Its page shows the check-in URL: use it in place of https://hookpulse.net/in/YOUR_ID.

2Add the cron to vercel.json

Vercel runs cron jobs in UTC: this one runs at 03:00 UTC.

{
  "crons": [
    {
      "path": "/api/nightly",
      "schedule": "0 3 * * *"
    }
  ]
}

3Write the function

Set CRON_SECRET and HOOKPULSE_URL in the project settings. Vercel sends CRON_SECRET in the Authorization header, so only Vercel can start the job.

// api/nightly.js
export async function GET(request) {
  if (request.headers.get("authorization") !== `Bearer ${process.env.CRON_SECRET}`) {
    return new Response("Unauthorized", { status: 401 });
  }
  const checkIn = (path = "") =>
    fetch(process.env.HOOKPULSE_URL + path, { signal: AbortSignal.timeout(10_000) });
  try {
    await runJob();
    await checkIn();
    return new Response("ok");
  } catch (error) {
    await checkIn("/fail").catch(() => {});
    return new Response("failed", { status: 500 });
  }
}

4Run it once

Deploy, then run the cron job once from the project settings. The routine shows the first check-in. From then on, a missed or failed run sends the alert.