# Operations and retries

URL: https://heaven.dev/docs/reference/retries
Updated: 2026-11-22

An operation records a change Heaven has accepted. Keep its ID to follow the work after the request that started it ends.

## Operations

A management change can return `data.operation`. Read it by ID with [Read an operation](https://heaven.dev/docs/reference/operations/read), even if the Computer has since been renamed or deleted. Accepted work continues after the client disconnects.

| State | Meaning |
| --- | --- |
| `accepted` | Heaven saved the change and the work is in progress. |
| `complete` | The work finished. |
| `failed` | The work failed. The operation contains its error. |
| `superseded` | A newer change replaced the operation. Read the resource for its current state. |

Some requests return a result per target. Others return a group operation with its own ID and a list of operations. Read the group to follow the whole change and inspect individual results for failures.

## Waiting

[Read an operation](https://heaven.dev/docs/reference/operations/read) can wait for a terminal state. Set `wait` to `true` and optionally specify a `timeout`. The default for this read is 10 seconds and the maximum is 10 minutes. If the wait expires, it returns `unknown` with the operation ID. Read the same operation again.

Some changes also take a wait option. Use `--wait` on the CLI or SSH, or `wait: true` over HTTP, to wait up to 10 minutes. For a shorter wait, use `--wait=30s` or `"wait": "30s"`. The change can return an operation that is still `accepted`.

Over HTTP, `Accept: application/x-ndjson` streams supported operation results. An `accepted` record carries the initial result. `operation` records carry terminal outcomes. The stream sends `complete` after all the operations reach a terminal state. A bounded wait can end with `pending`. Read any remaining operation by ID.

## Request IDs

For commands that support replay, a request ID identifies one intended change. Save a new ID and the original inputs before sending a change you may need to recover. If you omit the ID, Heaven supplies one. The command's reference page shows whether it supports replay.

| Interface | Where to send the ID |
| --- | --- |
| HTTP | Send the `Idempotency-Key` header. Heaven refuses a `request_id` field in the body and refuses the header on commands that don't support it. |
| CLI and SSH | Set `--request-id`. |
| MCP | Set the `request_id` argument. |

Repeating the same command with the same inputs and ID recovers work Heaven already accepted without applying it twice. A request ID already used for a different change returns `conflict`. A new ID is for new work.

## Lost responses

If the connection closes before you get the result, use the information you kept.

| What you have | What to do |
| --- | --- |
| An operation ID | Read the operation to follow the work. |
| A request ID on a command that supports replay | Send the original request again with the same inputs and ID. |
| A change without replay or a usable ID | Inspect the resource before repeating the change. If you lost an API-key creation response, [list your keys](https://heaven.dev/docs/reference/api-keys/view) and revoke the key whose secret you didn't receive before creating another. |
| A guest command | Check its effects inside the Computer before running it again. |
| An ordinary read | Repeat the read after a transient failure. |

When Heaven refuses a request, resolve the cause in its [error](https://heaven.dev/docs/reference/errors). For `rate_limited` or `busy`, wait for the indicated delay if Heaven supplies one.

## Unknown outcomes

`unknown` means Heaven couldn't confirm what happened. The change may already have taken effect. Use the operation or request ID in the error if one is available. Follow the [lost response steps](#lost-responses) when the error gives you no ID.
