Send a text to yourself from a Vercel cron job
Yes. Homing Pigeon (homingpigeon.dev) lets the Next.js route handler your Vercel cron job calls text your phone when the job fails. The route checks your cron secret first, so nobody else can run it, and your coding agent can add it to the project you already have.
What to tell your agent
Use Homing Pigeon to text me when the Vercel cron job in this Next.js app fails.
Your agent asks for your number, you read back the six-digit code, and it does the rest.
How it works in code
Route handlers have fetch built in, so there is nothing to install. Save this as app/api/cron/route.js, and replace runJob with your own code:
async function textMe(message, idempotencyKey) {
try {
const res = await fetch("https://homingpigeon.dev/v1/send", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.HOMINGPIGEON_API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({ message, idempotency_key: idempotencyKey }),
cache: "no-store",
signal: AbortSignal.timeout(5000)
});
if (!res.ok) console.warn("Text alert failed:", (await res.json()).error.message);
} catch (err) {
console.warn("Text alert failed:", err.message);
}
}
export async function GET(request) {
const secret = process.env.CRON_SECRET;
if (!secret || request.headers.get("authorization") !== `Bearer ${secret}`) {
return new Response("Unauthorized", { status: 401 });
}
try {
await runJob();
} catch (err) {
const today = new Date().toISOString().slice(0, 10);
await textMe(`Daily job failed: ${String(err.message).slice(0, 200)}`, `daily-job-${today}`);
return new Response("Job failed", { status: 500 });
}
return new Response("OK");
}
Then add the schedule to vercel.json in your project's root folder. This one calls the route every day at 13:00 UTC:
{
"crons": [
{ "path": "/api/cron", "schedule": "0 13 * * *" }
]
}
Good to know
- When your project has an environment variable named
CRON_SECRET, Vercel sends it with every cron request, in theAuthorizationheader asBearerand the secret. The route answers 401 to any other request, so someone who finds the address cannot run your job or text you. - The
!secretcheck keeps the route closed ifCRON_SECRETis missing, instead of letting in a request that sendsBearer undefined. - Verify your phone with
npx -y homingpigeondev verify +15551234567, then again with the six-digit code it texts you.npx -y homingpigeondev keythen prints your key. In your Vercel project, open Settings, Environment Variables, and addHOMINGPIGEON_API_KEYwith that key andCRON_SECRETwith a long random string, such as the output ofopenssl rand -hex 32. Redeploy afterward, because new variables only apply to new deployments. - The text reads like "Daily job failed: database timed out after 30 s." The error is cut to 200 characters because messages are limited to 480. The 500 response marks the run as failed in your logs.
- Vercel can occasionally deliver the same cron event more than once. The date in the idempotency key means you still get at most one text a day. A quiet phone means the job worked.
- The
tryintextMemeans a failed or slow text never hides the job's own result. If Homing Pigeon rejects a send, its reason goes to your function logs, and the 5-second timeout caps how long a send can take. - Cron schedules are in UTC, and cron jobs run only on your production deployment, not on previews. On the Hobby plan, a cron job can run at most once a day, at some point within the hour you set.
- If the job runs past the function's maximum duration, Vercel stops it and the
catchnever runs, so no text goes out. For a long job, raise the limit withexport const maxDuration = 300;in the route file, within what your plan allows. - To try it on your own machine, put both variables in
.env.local, which the.gitignorefrom create-next-app keeps out of git. Runnpm run dev, then call the route the way Vercel does:curl -H "Authorization: Bearer your-secret" http://localhost:3000/api/cron, with your own secret. - Messages go only to the US mobile number you verified. Keep them plain, with no links. Delivery is not guaranteed, so treat each text as a heads-up.
Get started
Add Homing Pigeon to Claude Code, then ask for what you want:
claude mcp add homingpigeondev -- npx -y homingpigeondev mcp
You get 50 free texts every month, on US mobile numbers. See more use cases.