# Run a command

URL: https://heaven.dev/docs/reference/exec/run
Updated: 2026-11-21

Run a shell command or transfer one file inside a Computer as the image's login user. Requires owner or root access. Inline execution allows 30 seconds and 1 MiB of output. The streamed API allows an hour with unlimited output. Direct SSH execution has neither limit.

`POST /v1/computer/exec`

## Parameters

- `computer` (string, required): Computer name or ID.
- `command` (string, required): Shell command to run as the image's login user.
- `stdin` (string): Base64-encoded standard input, up to 1 MiB decoded. For larger input, send a non-JSON body with `computer` and `command` in the query.

## Returns

- `data` (object, always present): Captured guest output and exit status, or an upload receipt. Downloads return file bytes; streams return output events and a final exit event.
  - `alternative-1` (object): Captured output and exit status of a bounded guest command.
    - `exit_code` (integer, always present): Guest exit status; zero means success.
    - `output` (string (base64) | null, always present): Captured output as base64-encoded bytes.
  - `alternative-2` (object): A receipt for a file uploaded into the Computer.
    - `bytes` (integer, always present): Number of file bytes uploaded.
    - `path` (string, always present): Destination path inside the Computer.
- `stream` (object): Returned with `Accept: application/x-ndjson`. One event per JSON line: base64-encoded `stdout` or `stderr`, guest `exit_code`, or `error`. Errors after streaming begins can leave the command outcome unknown.

## Errors

Each code is explained in full at https://heaven.dev/docs/reference/errors.

| Code | Status | What happened |
|---|---:|---|
| `invalid` | 400 | An input is missing or invalid. |
| `unauthenticated` | 401 | The credential is missing, invalid, expired or revoked. |
| `denied` | 403 | The caller lacks permission for this action. |
| `not_found` | 404 | The resource is absent or inaccessible to this caller. |
| `conflict` | 409 | The request conflicts with the current resource state or an earlier request. |
| `over_capacity` | 409 | The request exceeds a resource or credential allowance. |
| `access_list_full` | 409 | The change would exceed the access-list allowance. |
| `payment_required` | 402 | Payment or credit is required. |
| `rate_limited` | 429 | The caller's request rate exceeds its limit. |
| `busy` | 429 | Too much work is in progress to accept this request. |
| `unknown` | 503 | The outcome is unconfirmed; a change may have happened. |
| `unavailable` | 503 | The service or requested feature is unavailable. |

## Notes

- API key permission: `exec`.

## Examples

```sh tab="heaven CLI"
heaven exec COMPUTER [COMMAND...]
  [--download DOWNLOAD]
  [--upload UPLOAD]
  [--mode MODE]
```

```sh tab="SSH"
ssh COMPUTER@heaven.dev COMMAND
```

```sh tab="cURL"
curl https://heaven.dev/v1/computer/exec \
  -H "Authorization: Bearer $HEAVEN_API_KEY" \
  --json '{"computer": "my-site", "command": "uname -a"}'
```

```json tab="MCP"
{ "tool": "exec",
  "arguments": { "computer": "my-site", "command": "uname -a" } }
```

Response:

```json title="Response excerpt"
{
  "version": 1,
  "data": {
    "exit_code": 0,
    "output": "TGludXggbXktc2l0ZSA2LjguMC00OS1nZW5lcmljICM0OS1VYnVudHUgU01QIFBSRUVNUFRfRFlOQU1JQyB4ODZfNjQgR05VL0xpbnV4Cg=="
  }
}
```
