You can even use the Replit URL to run your job, as long as the Repl is running. Make sure to replace YOUR_EMAIL_ADDRESS with a valid email address and YOUR_RESEND_API_KEY with your Resend API key, and then you can run the following in your terminal:
Copy
# This assumes your API key is set in the current env# BOOPER_API_KEY=sk_...curl --location --request POST 'https://scheduler.booper.dev/api/jobs' \--header "Content-Type: application/json" \--header "Authorization: Bearer $BOOPER_API_KEY" \--data-raw '{ "method": "post", "url": "https://pg.reichertjalex.repl.co/api/run", "body": { "recipient": YOUR_EMAIL_ADDRESS, "resend_api_key": YOUR_RESEND_API_KEY, "exclude": "$state.sent" }, "cron": "0 10 * * MON,WED,FRI"}'
When you create a job on a schedule, the scheduler will pass in some metadata into the body of each request. Included in the metadata is the schedule’s state, which can be accessed at req.body.$state and set or updated in the response.
Let’s modify the API handler to take advantage of $state:
We can clean this up a bit by taking advantage of dynamic values in our job schedule configuration. When we set the request body for our job, we can write it like this:
Copy
{ // Pass in `req.body.$state?.sent` as `req.body.exclude` "exclude": "$state.sent"}
If we do this, we can change the line above from this:
Copy
const exclude = req.body.$state?.sent || [];
To this:
Copy
const exclude = req.body.exclude || [];
Now, assuming you’ve deployed your API endpoint to https://yourdomain.com/api/pg, you can create your scheduled job by running the following script in your terminal with your BOOPER_API_KEY set, and the url modified to the appropriate domain:
Copy
# This assumes your API key is set in the current env# BOOPER_API_KEY=sk_...curl --location --request POST 'https://scheduler.booper.dev/api/jobs' \--header "Content-Type: application/json" \--header "Authorization: Bearer $BOOPER_API_KEY" \--data-raw '{ "method": "post", "url": "https://yourdomain.com/api/pg", "body": { "recipient": YOUR_EMAIL_ADDRESS, "resend_api_key": YOUR_RESEND_API_KEY, "exclude": "$state.sent" }, "cron": "0 10 * * MON,WED,FRI"}'