Skip to content
Guide

How to check an API every few minutes and get an alert when it's down

A schedule calls your API every few minutes: a failed call emails you, a 200 that reports a problem posts to Slack. What it covers, and what it doesn't.

Updated

You have an API, a site or a health endpoint, and you want to know when it stops answering. A full uptime monitor checks from many places and keeps a status page; this guide is the lightweight version: a schedule calls the URL every few minutes, a failed call emails you, and a response that says “degraded” while still answering 200 posts to Slack. Here is exactly what it does and doesn't cover.

  1. Trigger

    On a schedule

    Every 15 minutes.
  2. Step 1

    HTTP request

    GET https://api.example.com/health
  3. Step 2

    Branch

    If Step 1 → Body → Status is not ok
  4. Yes path

    Post to Slack

    “Health check: Step 1 → Body → Status”
The workflow you'll build. The Branch and Slack tiles are optional.

What counts as “down”

The HTTP request step fails when the URL doesn't answer within 15 seconds, when the connection fails, or when the response status is 400 or above. For a GET, network errors, timeouts and 408, 425, 429, 500, 502, 503 and 504 are retried after 30 seconds, 2 minutes and 10 minutes before the run is marked failed; a 404 or 401 fails right away. When a run fails, Foliot emails you with the step, the status and the error, at most once an hour per workflow, so an outage of three hours is one email, not twelve. That email is the “down” alert.

Because a failed step stops the run, no later step can post “it's down” to Slack. The Slack step in this workflow is for the other case: the endpoint answers 200 but reports a problem in its body.

Before you start

  • A Foliot account. Checking every 2 hours or less often fits the free plan; see the run math below.
  • The URL to check. A health endpoint that returns JSON like {"status": "ok"} is ideal.
  • For the Slack part, an incoming webhook URL for your channel (see how to create one).

Set it up

1. Create the workflow and pick a schedule

Create a new workflow and choose On a schedule. Pick every 15 minutes, or whatever fits your plan, and your timezone.

2. Add the HTTP request

Click + and choose HTTP request. Method GET, the URL of your endpoint. If it needs a key, store it as an “API credentials” connection so it stays encrypted and out of the run history. Test this step shows the status, headers and body you get back.

3. Branch on the body (optional)

Add a Branch: “If Step 1 → Body → Status is not ok”. On the Yes path, add Post to Slack (or Send email) with a message that includes the status and Trigger → Scheduled at. Leave the No path empty: a healthy check ends quietly.

4. Turn it on

Switch the workflow on. Each check is a run in the history with the full response. A run marked Failed is a check that couldn't reach the URL or got an error status; the step that failed is marked in the editor with its error until the next run.

How often to check

Every check is one run. Over a 30-day month:

Every 5 minutes

Runs a month
8,640
Plan
Pro

Every 15 minutes

Runs a month
2,880
Plan
Pro

Every hour

Runs a month
720
Plan
Pro

Every 2 hours

Runs a month
360
Plan
Free

The free plan includes 500 runs a month; Pro includes 10,000 for $12 a month, so Pro covers one URL every 5 minutes or three URLs every 15 minutes. To check several URLs in one run, add one HTTP request step per URL: it's still one run.

Useful variations

  • Slow responses: a request that takes longer than 15 seconds fails, so a very slow endpoint alerts the same way as a dead one.
  • Check the content, not only the status: branch on any field of the body, such as a queue length Step 1 → Body → Pending being greater than 100.
  • Post to Discord instead with Post to Discord on the Yes path.
  • Keep a log: Add row to Google Sheets after the request, with the status and Trigger → Scheduled at, for a cheap history beyond the 30 days Foliot keeps runs.

Other ways to do it

  • An uptime monitor (there are many, with free tiers) checks from several regions, alerts when a site goes down and when it recovers, and gives you a status page. If you run a public service, use one. Foliot fits for internal endpoints, a side project, or when the check is part of a bigger workflow.
  • A cron job and a script on a server you already run. See cron job without a server for the trade-offs.

Questions

How does Foliot know the API is down?

The HTTP request step fails when the URL doesn't answer within 15 seconds or returns a status of 400 or above (temporary errors are retried after 30 seconds, 2 minutes and 10 minutes first). A failed run emails you, at most once an hour per workflow.

Can it post to Slack when the API is down?

Not for a failed request: a failed step stops the run, so later steps don't run. The down alert is Foliot's failure email. Slack works for a 200 response whose body reports a problem, through a Branch step.

How often can it check?

As often as every minute. Every 5 minutes is about 8,640 runs a month, which needs Pro (10,000 runs for $12 a month). Every 2 hours fits the free plan's 500 runs.

Is this an uptime monitor?

No. It checks from one place, alerts at most once an hour per workflow, and has no status page or recovery message. For a public service, use a dedicated monitor.