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

# Automation Reliability

> Validate definitions, control failed runs, and test waits without delivery.

## Validate before publish

`POST /automations/validate` accepts `{ "definition": { ... } }` and returns
`valid`, human-readable `errors`, and structured validation `issues`.

`wait_for_event` supports a canonical `timeout_seconds` value. Legacy
`timeout: { amount, unit }` definitions are normalized for compatibility, but
new definitions should always use seconds.

## Correlated waits

Define a trigger correlation key and use the same key on a wait:

```json theme={null}
{
  "trigger": {
    "event_name": "checkout.started",
    "correlation": {
      "key": "checkout_id",
      "duplicate_policy": "ignore_active"
    }
  },
  "steps": [
    {
      "key": "wait_for_checkout",
      "type": "wait_for_event",
      "config": {
        "event_name": "checkout.completed",
        "timeout_seconds": 3600,
        "correlation": { "key": "checkout_id" }
      }
    }
  ]
}
```

Use `end_automation` as a terminal step for an explicit successful branch.

## Run controls

* `POST /automation-runs/:runId/cancel`
* `POST /automation-runs/:runId/retry`

Both accept an optional `{ "reason": "..." }`, are project-scoped and audited,
and require a Sendrealm API key. Cancellation cannot retract a delivery that
has already started.

## Test runs

Test a saved draft without delivery or production mutations:

* `POST /automations/:id/test-runs`
* `GET /automation-test-runs/:runId`
* `POST /automation-test-runs/:runId/events`
* `POST /automation-test-runs/:runId/advance`

Test runs record simulated actions, use isolated synthetic events, and advance
delays or wait timeouts with a virtual clock.
