Skip to content

Use cases

Call an API endpoint on a schedule

Some jobs are just an HTTP call that needs to happen on a timetable: refresh a cache, roll up yesterday's numbers, kick off a nightly export. Cronhost calls any API endpoint you own on the cron schedule you set, with the method, headers, and body it needs.

The problem

You have an endpoint that does the work already. What you are missing is something reliable to hit it on time, with auth headers, retries when the call blips, and a record of whether each run actually succeeded.

How to set it up

  1. 1

    Create the schedule with the right method and auth

    Set the endpoint, HTTP method, and any headers your API needs (an API key or bearer token, for example). Add a request body for POST/PUT/PATCH calls.

    const refresh = await cronhost.createSchedule({ name: "Refresh cache", cronExpression: "0 */6 * * *", // every 6 hours timezone: "UTC", endpoint: "https://api.example.com/cache/refresh", httpMethod: "POST", headers: JSON.stringify({ Authorization: "Bearer YOUR_TOKEN" }), timeoutSeconds: 60, });
  2. 2

    Tune the timeout for slower endpoints

    If the call does real work, raise the timeout so Cronhost waits for it to finish instead of cutting it off. A run only counts as failed once it exhausts its retries.

  3. 3

    Watch it in the run history

    Every run records the status code, response, and timing. Open the schedule to see whether the last call returned what you expected, and attach a notification channel so you hear about failures without checking.

Example cadence: Run a cron job every 6 hours

Run your API call on a reliable schedule

Set the endpoint, method, and headers. Cronhost handles the timing and retries.

Frequently asked questions