# Get a background command

> Status and output of a command started with background: true. Readable while the sandbox is starting or running.

`GET https://api.zavu.dev/v1/sandboxes/{sandboxId}/commands/{commandId}`

Status and output of a command started with `background: true`. Readable while the sandbox is starting or running.

## Parameters

- `sandboxId` (path, string, required): Sandbox ID.
- `commandId` (path, string, required): Background command ID, as returned when it was started.

## Responses

### 200

The command.

- `command` (object, required): A background command.
  - `id` (string, required)
  - `command` (string, required)
  - `status` (string, required): `unknown`: the machine restarted its process supervisor and lost track of it; the output shown is what was written to disk. One of: `running`, `finished`, `unknown`.
  - `exitCode` (integer, required, nullable)
  - `stdout` (string, required): The last 1 MiB of standard output.
  - `stderr` (string, required): The last 1 MiB of standard error.
  - `stdoutTruncated` (boolean)
  - `stderrTruncated` (boolean)
  - `startedAt` (string<date-time>, nullable)
  - `finishedAt` (string<date-time>, nullable)
  - `createdAt` (string<date-time>, required)

### 401

Unauthorized.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 404

Sandbox or command not found.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 409

`sandbox_not_running`: the sandbox is stopped, stopping, failed or deleted; resume it first. `sandbox_not_ready`: it is still starting and did not become ready in time; retry.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

## Example

```bash
curl -X GET "https://api.zavu.dev/v1/sandboxes/sandbox_abc123/commands/command_abc123" \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY"
```

```typescript
import Zavudev from "@zavudev/sdk";

const zavu = new Zavudev({ apiKey: process.env.ZAVUDEV_API_KEY });

const result = await zavu.sandboxes.commands.retrieve("command_abc123", {
  sandboxId: "sandbox_abc123",
});

console.log(result);
```
