Build a health check endpoint
What Notert sends to your health check, how it reads the answer, and endpoints that report the right state.
Last updated Tuesday, November 24th, 2026
View as MarkdownOn this page
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. This page is for whoever builds the endpoint behind it.
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
Acceptheader that prefersapplication/health+json, thenapplication/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
Each check settles on one state, in this order:
- Down when no answer arrives within 10 seconds, the connection fails, or the final status is outside 2xx.
- Down or degraded when the body is JSON whose top-level
statussays so, even with a 2xx.fail,down,unhealthy,errorandoutageare down.warnanddegradedare degraded. Case and spaces around the word don't matter. - Degraded when a 2xx's headers take more than 5 seconds to arrive.
- Operational otherwise. A JSON
statusofpass,ok,up,healthyoroperationalsays so too, and any other body leaves the HTTP status to decide.
A body in the Health Check Response Format 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
Check what your product needs to work, such as its database, and answer quickly:
// Express
app.get("/health", async (req, res) => {
try {
await db.query("select 1");
res.json({ status: "ok" });
} catch {
res.status(503).json({ status: "down" });
}
});# 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:
// 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
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:
{ "status": "warn", "notes": "Search is slower than usual" }For example, an API that needs its database but can live without its search index:
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
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 10A 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.