# Build a health check endpoint (https://notert.io/docs/system-status/health-checks)

Last updated 2026-11-24

The widget's system status reads one address per service, such as `api.acme.com/health`, every minute. Adding a service is covered in [show your system status in the widget](/support/workspace/system-status). This page is for whoever builds the endpoint behind it.

<Screenshot name="status-services" alt="The Widget page's System status section, with Show status in the widget and the services under each application, Search among them degraded" />

## What Notert sends [#what-notert-sends]

- **A plain `GET`**, with no cookies, no credentials and no custom headers, so the endpoint must answer without a sign-in.
- **An `Accept` header** that prefers `application/health+json`, then `application/json`.
- **A user agent** that contains `NotertStatus/1.0`. If a firewall or bot protection stands in front of the endpoint, allow it.
- **Only to a public address**, on the standard ports, following redirects. An address on a port such as `:8080`, or with a username and password in it, can't be added, and an address on a private network is down.

## How the answer is read [#how-the-answer-is-read]

Each check settles on one state, in this order:

1. **Down** when no answer arrives within 10 seconds, the connection fails, or the final status is outside 2xx.
2. **Down or degraded** when the body is JSON whose top-level `status` says so, even with a 2xx. `fail`, `down`, `unhealthy`, `error` and `outage` are down. `warn` and `degraded` are degraded. Case and spaces around the word don't matter.
3. **Degraded** when a 2xx's headers take more than 5 seconds to arrive.
4. **Operational** otherwise. A JSON `status` of `pass`, `ok`, `up`, `healthy` or `operational` says so too, and any other body leaves the HTTP status to decide.

A body in the [Health Check Response Format](https://datatracker.ietf.org/doc/html/draft-inadarei-api-health-check) or Spring Boot Actuator's `/actuator/health` is read as it is, with nothing to change.

What visitors see changes only after two checks in a row agree, so one slow answer during a deploy never reaches them. A service failing three of its last five checks shows its problem too, however the failures alternate with passes.

## A simple endpoint [#a-simple-endpoint]

Check what your product needs to work, such as its database, and answer quickly:

```js
// Express
app.get("/health", async (req, res) => {
  try {
    await db.query("select 1");
    res.json({ status: "ok" });
  } catch {
    res.status(503).json({ status: "down" });
  }
});
```

```python
# FastAPI
@app.get("/health")
async def health(response: Response):
    try:
        await database.execute("select 1")
        return {"status": "ok"}
    except Exception:
        response.status_code = 503
        return {"status": "down"}
```

In a Next.js route handler:

```ts
// app/health/route.ts
export const dynamic = "force-dynamic";

export async function GET() {
  try {
    await db.query("select 1");
    return Response.json({ status: "ok" });
  } catch {
    return Response.json({ status: "down" }, { status: 503 });
  }
}
```

## Reporting degraded [#reporting-degraded]

When part of a service is slow or failing but it still answers, return a 2xx with `"status": "warn"` or `"status": "degraded"`. Visitors then see that it's having issues rather than that it's down:

```json
{ "status": "warn", "notes": "Search is slower than usual" }
```

For example, an API that needs its database but can live without its search index:

```js
app.get("/health", async (req, res) => {
  const database = await db.query("select 1").then(
    () => true,
    () => false,
  );
  if (!database) return res.status(503).json({ status: "down" });

  const search = await Promise.race([
    searchIndex.ping().then(
      () => true,
      () => false,
    ),
    new Promise((resolve) => setTimeout(() => resolve(false), 2000)),
  ]);
  res.json({ status: search ? "ok" : "warn" });
});
```

Give each check inside the endpoint a short timeout of its own, as the search check does, so one slow part answers degraded rather than running past Notert's wait and reading as down.

Only `status` is read. Keep the body small and leave out anything you wouldn't want public, since the address can be reached by anyone.

## Try it as Notert does [#try-it-as-notert-does]

```sh
curl -i https://api.acme.com/health \
  -H "Accept: application/health+json, application/json;q=0.9" \
  -A "Mozilla/5.0 (compatible; NotertStatus/1.0)" \
  --max-time 10
```

A 2xx within a few seconds, with a body whose `status` is one of the words above, or none, is what you want. A firewall's challenge, a `401` or a `403` reads as down. A redirect to a sign-in page that answers 200 reads as up whatever your service is doing, so keep the endpoint outside your sign-in.

<Note>
Give each part of your product that can fail on its own its own endpoint, such as one for the app
and one for the API. Each becomes a service with its own row on the widget's Status screen.
</Note>