Safely screen requests to pages/api for cron jobs with Vercel

So I've setup my app using create-t3-app and am trying to using vercel cron jobs to send out emails every so often. Basic structure would be to setup pages/api/cron.ts to call a function in server/api/sendEmails.ts. But how do I ensure that not anybody can just send a request to cron.ts and fire off an email blast? I have a couple of webhook endpoints in "pages/api" that verify the source of the request for either stripe or clerk using functions provided by each service, but I'm unsure how to do something like that on my own. Any tips/suggestions on if this is even the right approach?
1 Reply
Entaro
Entaro8mo ago
Found what I was looking for, wasn't on the original docs page I was looking at for some reason. https://vercel.com/docs/cron-jobs/manage-cron-jobs#securing-cron-jobs
Vercel Documentation
Managing Cron Jobs
Learn how to manage Cron Jobs effectively in Vercel. Explore cron job duration, error handling, deployments, concurrency control, local execution, and more to optimize your serverless workflows.