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

# check

> The check block defines post-deploy assertions that validate deployed resources at runtime.

The `check` block defines post-deploy, runtime assertions that validate the state of deployed resources. Checks run after resources are provisioned and can depend on specific resources being in place.

## Syntax

```xcl theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
check name {
  depends_on = [resource_a, resource_b]

  assert {
    condition     = <boolean expression>
    error_message = <string expression>
  }
}
```

The label is a bare identifier, quotes optional. A quoted label may contain spaces.

## Fields

| Field        | Description                                                                                                       |
| ------------ | ----------------------------------------------------------------------------------------------------------------- |
| `depends_on` | Optional. A list of resource references the check depends on. The check runs after these resources are available. |
| `assert { }` | One or more assertion blocks. See [assert](#assert-blocks).                                                       |

## Assert blocks

Each `assert` block has exactly two required fields:

| Field           | Description                                                              |
| --------------- | ------------------------------------------------------------------------ |
| `condition`     | A boolean expression that must evaluate to `true` for the check to pass. |
| `error_message` | A string expression reported when the condition is `false`.              |

<Note>
  `for`, `count`, and `for_each` are not allowed inside `check` blocks.
</Note>

## Example

```xcl theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
check api_health {
  depends_on = [api_gateway, backend]

  assert {
    condition     = api_gateway.stage == "prod"
    error_message = "API gateway must be on the prod stage"
  }
}
```

## How checks are used

Checks run as post-deploy assertions. Use `depends_on` to ensure the referenced resources exist before the `assert` conditions are evaluated against their live state.
