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

# Block until the job reaches terminal status, or until timeout

> Synchronously wait for a job to terminate. Useful for shell scripts and simple HTTP clients that can't consume SSE…

Synchronously wait for a job to terminate.

Useful for shell scripts and simple HTTP clients that can't consume
SSE. Returns immediately when the job is already in a terminal
status; otherwise blocks up to `timeout_seconds` (default 30, max
60\) before returning the current state with `is_terminal: false`.

Implementation: server-side polling on a 1-second interval,
refreshing the row each tick. Avoids holding an open broker
subscription so connection-pool pressure stays bounded — the
long-running idiom is `/events/stream` (SSE) when you need
intermediate updates rather than just terminal status.

### Path parameters

<ParamField path="job_id" type="string (uuid)" required />

### Request body

JSON body of type `WaitJobRequest,null`.

### Response

`WaitJobResponse`

<ResponseField name="job_id" type="string" required />

<ResponseField name="status" type="string" required />

<ResponseField name="is_terminal" type="boolean" required>
  True if the job reached `succeeded`/`failed`/`cancelled` before the timeout. False means the timeout fired and the returned status is still in-flight.
</ResponseField>

<ResponseField name="waited_seconds" type="number" required>
  Wall-clock seconds spent blocking inside the handler.
</ResponseField>

<ResponseField name="summary" type="string,null" />

<ResponseField name="error" type="string,null" />

<ResponseField name="cost_usd" type="number,null" />

### Status codes

| Code  | Meaning             |
| ----- | ------------------- |
| `200` | Successful Response |
| `422` | Validation Error    |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.computer.stateset.app/api/v1/jobs/{job_id}/wait' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "timeout_seconds": 30
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "job_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "status": "pending",
    "is_terminal": true,
    "waited_seconds": 250,
    "summary": "Two-person tent, green — replacement for damaged pole set.",
    "error": "string",
    "cost_usd": 1.5
  }
  ```
</ResponseExample>
