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

# Health Checks

> A Health Check helps you make sure your connected API is online and working correctly before your AI Agent tries to use it.

## **Why Add a Health Check?**

Adding a Health Check helps:

* Detect downtime or broken connections early
* Prevent user frustration when the API is offline
* Give your Agent clear fallback behavior when the service is unavailable

A Health Check is like a “heartbeat” that confirms your Action’s backend is alive and responding.

## **How It Works**

When you provide a **Health Check URL**, Watermelon pings that endpoint to make sure it returns a valid **200 OK** response.

If the endpoint returns an error (for example 500 or 404), or doesn’t respond at all, the check fails.

When that happens, your Agent will follow the **instruction** you define under *“Provide an instruction”*.

## **Setting Up a Health Check**

<Steps>
  <Step title="Go to actions">
    Go to your **AI Agent → Actions**.
  </Step>

  <Step title="Open the Action you want to add a health check to.">
    Scroll down to the **Health check** section (see screenshot)

    <Frame>
      <img src="https://mintcdn.com/watermelon/inCKLCH0W-_-CMh8/images/developer-resources/actions/health-check.png?fit=max&auto=format&n=inCKLCH0W-_-CMh8&q=85&s=db6dad995393becc6c4ad848279724e7" alt="Health Check" width="2938" height="1390" data-path="images/developer-resources/actions/health-check.png" />
    </Frame>
  </Step>

  <Step title="Fill in the health check URL">
    Enter a lightweight API endpoint that reliably returns a **200 OK** status when the system is healthy.

    **Examples:**

    * /health
    * /status
    * /ping

    **Example URL:**

    ```html theme={null}
    https://api.example.com/v1/health
    ```

    The endpoint should:

    * Use **HTTPS**
    * Require minimal or no authentication
    * Return a fast, small response (ideally under 1 second)
  </Step>

  <Step title="Provide an Instruction">
    This tells your AI Agent what to do if the health check fails — for example, what to tell the user or how to proceed.

    **Example instructions:**

    > “If this API is unavailable, tell the user: ‘I can’t reach the system right now, please try again later.’”
    >
    > “When the health check fails, stop all actions and ask the user to retry after a few minutes."
    >
    > “If the system is down, provide a polite fallback message instead of continuing the Action.”

    Your Agent will automatically follow this instruction whenever the API connection fails.
  </Step>
</Steps>

## **What a Valid Health Check Response Looks Like**

A healthy endpoint should return:

```javascript theme={null}
HTTP/1.1 200 OK
Content-Type: application/json
{
  "status": "healthy"
}
```

**Unhealthy responses** include:

* 401 Unauthorized → Invalid credentials
* 404 Not Found → Wrong URL
* 500 Internal Server Error → Server issue
* Timeout → API unreachable

If Watermelon detects one of these, it executes your fallback instruction.
