> ## Documentation Index
> Fetch the complete documentation index at: https://unkey.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Unkey is two separate products. Compute builds, deploys, and runs apps behind a gateway. API Management issues API keys, enforces rate limits, manages identities and permissions, and reports usage. Say which product a page belongs to; a reader can use either without the other.
> Every Unkey API endpoint is an HTTP POST to https://api.unkey.com/v2/{service}.{procedure} with a root key in the Authorization: Bearer header. Root keys are workspace scoped.
> Error codes have the form err:{system}:{category}:{specific} and each has a page at /errors/{system}/{category}/{specific}.
> The word environment means production or preview in Compute. Rate limiting has four meanings on this site; the glossary lists them.

# Health checks

> Tell Unkey how to probe your app and what happens when the probe fails.

A health check tells us how to tell whether your <Tooltip tip="A Compute app: a deployable service inside a project. Not 'your application' in general.">app</Tooltip> is ready and still working. We send an HTTP request to each instance on a schedule. It's optional, and you set it per <Tooltip tip="A production or preview environment of a Compute app, not the dashboard label on a key.">environment</Tooltip>.

## What the health check does

* **An instance gets no traffic until it passes.** So a deployment can wait for your app to finish starting before the first request arrives.
* **An instance that fails `failureThreshold` checks in a row is restarted.**

A `GET` check passes on any status from 200 to 399. Anything else, including a timeout, is a failure.

Without a health check, an instance is ready as soon as its container is running, and it's only restarted if the process exits. That's fine for apps that are ready as soon as they open the port. Add a check if startup takes a while, or if your process can be running but unable to serve.

## Choose what to check

Check the process, not its dependencies. A failing check restarts the container, so a check that queries your database takes every instance down when the database has a bad minute. `GET /healthz` returning `200` is enough.

## Add a health check

<Frame>
  <img src="https://mintcdn.com/unkey/TjbnJStfcJRkiuek/images/dashboard/compute--configure-runtime-settings--runtime.png?fit=max&auto=format&n=TjbnJStfcJRkiuek&q=85&s=f2a5cd0d51b2327daf1a7f8ca435f224" alt="App Settings runtime section showing instances, max CPU, memory, storage, healthcheck, port, and command for production and preview" width="2560" height="1600" data-path="images/dashboard/compute--configure-runtime-settings--runtime.png" />
</Frame>

In the dashboard, open the app's settings and use the **Health check** card. In the API, set `healthcheck` in [runtime settings](/docs/compute/configure/runtime-settings) with `environments.updateSettings`:

```bash Add a check with a shorter timeout theme={"system"}
curl -X POST https://api.unkey.com/v2/environments.updateSettings \
  -H "Authorization: Bearer $UNKEY_ROOT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "payments",
    "app": "api",
    "environment": "production",
    "healthcheck": {
      "method": "GET",
      "path": "/healthz",
      "intervalSeconds": 10,
      "timeoutSeconds": 3,
      "failureThreshold": 3,
      "initialDelaySeconds": 5
    }
  }'
```

Like every runtime setting, it applies from the next deployment. To remove the check, use the remove action on the card, or send `"healthcheck": null`.

## Fields

Only `method` and `path` are required. The others use the defaults below.

<ParamField body="method" type="GET | POST" required>
  The HTTP method. `POST` sends an empty body using `wget` inside your container, so your image must include `wget`.
</ParamField>

<ParamField body="path" type="string" required>
  The path to request on your app's port, 1 to 512 characters, starting with `/` and matching `^(/[\w\-]+)+(\.[\w]+)?$`, for example `/healthz`.
</ParamField>

<ParamField body="intervalSeconds" type="integer" default="10">
  Seconds between checks, 1 to 3600. The dashboard defaults to `30s` and accepts values like `15s`, `2m`, or `1h`.
</ParamField>

<ParamField body="timeoutSeconds" type="integer" default="5">
  Seconds to wait for a response before the check fails, 1 to 3600. Only settable in the API. Saving from the dashboard sets 5.
</ParamField>

<ParamField body="failureThreshold" type="integer" default="3">
  Failures in a row before the instance is restarted, 1 to 100. Only settable in the API. Saving from the dashboard sets 3.
</ParamField>

<ParamField body="initialDelaySeconds" type="integer" default="0">
  Seconds after the container starts before the first check, 0 to 3600. Only settable in the API. Saving from the dashboard sets 0.
</ParamField>

## Next steps

<Columns cols={2}>
  <Card title="Instances and autoscaling" icon="server" href="/docs/compute/concepts/instances-and-autoscaling">
    How readiness, restarts, and traffic distribution fit together.
  </Card>

  <Card title="Deployments" icon="rocket" href="/docs/compute/concepts/deployments">
    How a deployment waits for healthy instances across regions.
  </Card>
</Columns>
