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

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Wait for Actor run

> Waits for an Apify Actor run and returns its latest state.

`apify.waitForRun` waits for an Apify Actor run and returns its latest state.

## Example

```ts automations/apify-wait-for-run.automation.ts theme={null}
import { automation, onHttpRequest } from "automate.ax"
import { apify } from "automate.ax/apify"

export default automation("Wait for Actor run", () => {
  onHttpRequest({ scope: "automation" })

  apify.waitForRun({ runId: "run-id", waitSecs: 120 })
})
```

## Inputs

| Field      | Type     | Required | Description                                                     |
| ---------- | -------- | -------- | --------------------------------------------------------------- |
| `runId`    | `string` | Yes      | Actor run ID.                                                   |
| `waitSecs` | `number` | No       | Maximum client-side wait in seconds. Omit to wait indefinitely. |

## Output

Returns the latest run state. A timeout returns the still-running state; it does not abort the run.

This action polls through Apify's official client. Use the returned `status` to distinguish completion from a caller-defined wait limit.
