> For the list of every page, fetch /llms.txt. The API contract is the OpenAPI file linked from the API reference.

# Read a background command

GET https%3A%2F%2Fapi.usemeadow.ai/v1/sandboxes/{sandbox_id}/execs/{exec_id}

Returns the status of a background command and its output from the given offsets
onward. To follow a command, call this in a loop: pass the `stdout_offset` and
`stderr_offset` from the last response, and set `wait_seconds` so the call holds
until there is new output, the command ends, or the time passes. Stop when
`status` is no longer `running`.

Offsets are byte counts. With both offsets at 0 you get the output from the
start. One call returns at most 1 MiB of each stream, so keep reading until the
offset stops growing.

Limits:

- Meadow keeps the first 16 MiB of each stream. Output past that is dropped, the
  offset stops growing, and `stdout_truncated` or `stderr_truncated` is true
  (also sent as `X-Meadow-Stdout-Truncated` and `X-Meadow-Stderr-Truncated`
  response headers). A command that writes more should write to a file.
- The full output (up to the 16 MiB above) can be read for one hour after the
  command ends, while the sandbox is running.
- Meadow also keeps the last 256 KiB of each stream for 24 hours. It takes
  that copy when the command ends, when the command is killed, and for a
  command that is still running when the sandbox is deleted or times out.
  After the hour above, and after the sandbox has ended, this call returns
  the status, the exit code and that kept part. It does the same for a
  command that has ended when the vendor cannot find the sandbox for the
  moment. A command that ended on its own before the sandbox was deleted
  keeps its real status and exit code, also when it was never read, for
  up to 8 commands of the sandbox, newest first. Offsets stay byte positions
  in the whole stream: a read from before the kept part starts at the kept
  part and sets `stdout_truncated` or `stderr_truncated`, and
  `stdout_offset` and `stderr_offset` are the full length of each stream.
  After the 24 hours the output is empty. The copy is encrypted at rest.
- Nothing is kept when the vendor lost the sandbox before Meadow could read
  it, or when a command's files inside the sandbox were removed. Write
  results you need to your own storage.
- If the command's state inside the sandbox is lost, this call returns 502 for 2
  minutes and then reports `failed` with `failure_reason` `state_lost` and a
  null `exit_code`. Treat that as an unknown outcome: the command itself may
  have finished. `failed` is a new status (2026-11-24). Treat any status other
  than `running` as final.
- If the vendor loses the sandbox while the command runs, the command reads
  `failed` with `failure_reason` `sandbox_lost` and a null `exit_code`, and the
  sandbox reads `failed` with `failure_reason` `provider_lost`. Meadow asks the
  vendor three times over about 6 seconds before it decides that, so one wrong
  "not found" from a vendor does not end a command. While the vendor's answers
  disagree, this call returns 502 with the code `sandbox_unreachable` and
  `Retry-After`, and the command stays `running`: call again.
- If that goes on for 10 minutes for one command, with the vendor still
  reporting the sandbox as running, the command reads `failed` with
  `failure_reason` `provider_unreachable`. Its siblings and the sandbox are
  left alone.

Scope: `sandboxes`.


Reference: https://docs.usemeadow.ai/api-endpoints/sandboxes/get-exec

## Authentication

- `Authorization` header (bearer token, required) — A Meadow API key, sent as `Authorization: Bearer mdw_...`. The header `x-api-key: mdw_...` is accepted in its place.

## Request

### Path parameters

- `sandbox_id` (string, required) — The sandbox `id` returned by `POST /v1/sandboxes`. It must belong to the key's project.
- `exec_id` (string, required) — The `id` returned when the background command was started.

### Query parameters

- `stdout_offset` (integer, optional, default: 0) — Byte offset to read `stdout` from. Use the `stdout_offset` of the last response. At least 0.
- `stderr_offset` (integer, optional, default: 0) — Byte offset to read `stderr` from. Use the `stderr_offset` of the last response. At least 0.
- `wait_seconds` (integer, optional, default: 0) — Hold the request for up to this many seconds, until there is new output or the command ends. From 0 to 60. A value outside that range returns 400. 0 returns at once.

## Response

### 200

The command's status and the output from the offsets onward.

- `id` (string, required) — The command id.
- `status` (enum, required) — - `running`: still going. - `exited`: ended on its own. Read `exit_code`. - `killed`: ended by the kill call. `killed` with a null `exit_code` means the sandbox was deleted or timed out before the command ended. - `timed_out`: killed at `timeout_seconds`. - `failed`: Meadow could not learn how the command ended. `failure_reason` says why. This value is new (2026-11-24): a client with a fixed list of statuses must add it, and should treat any status other than `running` as final.
  - Allowed values: `running`, `exited`, `killed`, `timed_out`, `failed`
- `failure_reason` (enum, optional) — Set when `status` is `failed`. - `state_lost`: the command's state inside the sandbox (its files under `/tmp/.meadow-exec`, or the process that supervises it) was gone for more than 2 minutes, so the exit code is unknown and `exit_code` is null. The command itself may have finished. - `sandbox_lost`: the vendor lost the sandbox while the command was running. The sandbox reads `failed` with `failure_reason` `provider_lost`. This value is new (2026-11-24). These commands read `killed` with a null `exit_code` before. - `provider_unreachable`: for 10 minutes the vendor answered "not found" or "not running" on every call about this command while it reported the sandbox as running. Meadow stopped tracking this one command. Other commands and the sandbox are not changed. The command itself may still be running. New on 2026-11-24. More values can be added. Treat one you do not know as an unknown outcome.
  - Allowed values: `state_lost`, `sandbox_lost`, `provider_unreachable`
- `exit_code` (integer, optional, nullable) — The exit code. Null while running, and when the outcome is unknown.
- `stdout` (string, optional) — Output from `stdout_offset` onward. Empty in the start and kill responses.
- `stderr` (string, optional) — Error output from `stderr_offset` onward. Empty in the start and kill responses.
- `stdout_offset` (integer, optional) — The byte offset after the returned `stdout`. Pass this on the next read.
- `stderr_offset` (integer, optional) — The byte offset after the returned `stderr`. Pass this on the next read.
- `stdout_truncated` (boolean, optional) — True when the command wrote more than 16 MiB to `stdout` and only the first 16 MiB is kept, or when this read is served from the part Meadow keeps after the sandbox ended and it starts later than the offset you asked for. Absent otherwise.
- `stderr_truncated` (boolean, optional) — True when the command wrote more than 16 MiB to `stderr` and only the first 16 MiB is kept, or when this read is served from the part Meadow keeps after the sandbox ended and it starts later than the offset you asked for. Absent otherwise.
- `started_at` (datetime, optional) — When the command started.
- `finished_at` (datetime, optional, nullable) — When the command ended. Null while running.

## Errors

### 400 Bad Request Error

A query parameter is out of range.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 401 Unauthorized Error

The key is missing, malformed, unknown, revoked, or expired, or a key it was minted from no longer exists. Check the key and the header.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 403 Forbidden Error

The key does not have the `sandboxes` scope. Use a key that has it.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 404 Not Found Error

The sandbox does not exist in the key's project, or it has no command with this id.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 409 Conflict Error

The sandbox is still `creating`. Wait for `running`. For a sandbox that has ended, this call returns 200 with the command's last known state.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 429 Too Many Requests Error

The sandbox vendor rate limited the call, the server instance was full and no slot came free for the account within 3 seconds (`account_in_flight_limit_exceeded`), or too many failed authentications came from your address. Wait for `retry-after` seconds, then retry.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 500 Internal Server Error

Meadow failed. Retry with backoff, and tell us if it persists.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 502 Bad Gateway Error

The sandbox vendor failed, refused, or timed out on this call, or the state of a background command could not be read. Retry with backoff. If it persists, read the sandbox with `GET /v1/sandboxes/{sandbox_id}` to see whether it is still `running`. The code `sandbox_unreachable` means the vendor answered "not found" or "not running" for a sandbox that it still reports as running, or Meadow could not tell which. Nothing was changed and no command was ended. The response carries `Retry-After`. Send the call again.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

## Types

### ErrorError

- `type` (enum, required) — The class of the failure. - `invalid_request`: the request is malformed or breaks a rule (400), or is too large (413). - `conflict`: the request is valid and the current state refuses it (409). Before 2026-11-24 a 409 used `invalid_request`. - `unauthorized`: the key is missing, unknown, revoked, or expired (401). - `forbidden`: the key's scope or limit does not allow this, or the project's routing is locked (403). - `not_found`: no such resource or route (404). - `no_provider_key`: no stored credential can serve this request (422). - `all_providers_failed`: every vendor in the route was tried (502). - `provider_error`: a vendor failed and no fallback was possible (502). - `rate_limited`: too many requests (429). - `insufficient_quota`: a dollar `limit` on the key, or on a key above it, is spent (402). The name is OpenAI's. - `unavailable`: a dependency Meadow needs is not set up (503). - `internal`: Meadow failed (500), or the feature is not set up (501).
  - Allowed values: `invalid_request`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `no_provider_key`, `all_providers_failed`, `provider_error`, `rate_limited`, `insufficient_quota`, `unavailable`, `internal`
- `message` (string, required) — A sentence for people. It can change, so do not match on it.
- `code` (string, optional) — A stable name for the specific failure. Every Meadow error carries one. `type` stays the general class, and several codes share a type. Branch on `code` when you need to tell two failures of one type apart, for example `api_key_expired` from `api_key_revoked`. The full list is in the Errors guide. A new code can be added at any time, so treat a code you do not know as its `type`. A spent limit (`key_request_limit_exceeded`, `key_token_limit_exceeded`) stays a 403 and not a 429, so a client that retries a 429 does not resend a call a spent key can never make. A spent dollar `limit` (`key_spend_limit_exceeded`) is a 402 for the same reason.
- `param` (string, optional) — The request field, query parameter or header the error is about, when there is one. A nested field is written with dots, such as `credentials.api_key`. Set on most validation errors (400).
- `attempts` (list of Attempt, optional) — The vendors Meadow tried for this request, in order. Present only when it tried at least one.
- `retry` (enum, optional) — Whether to send the same request again. Set on routes under `/v1/sandboxes` only. The values are BoxRouter's (https://boxrouter.ai/docs/error-codes). - `safe`: send the same request again, after `retry-after` seconds when the response has that header. A 429, a 409 `exec_start_in_progress` or `idempotency_request_in_progress`, a 502 `sandbox_unreachable`, and a 5xx on a `GET`, `PUT` or `DELETE`, on `POST /v1/sandboxes/route`, or on a sandbox create or background command start sent with `Idempotency-Key`. - `after_fix`: change the request, the key or the account first. Any other 4xx. - `check_outcome`: read the sandbox or the command before you send it again, because the work may have happened. A 5xx on any other `POST`, which includes a blocking command. - `never`: do not send it again. A 501. When the response has `x-should-retry`, `retry` is `safe` exactly when the header is `true`.
  - Allowed values: `safe`, `after_fix`, `check_outcome`, `never`
- `outcome` (enum, optional) — What happened to the work. Set on routes under `/v1/sandboxes` only. The values are BoxRouter's (https://boxrouter.ai/docs/error-codes). - `not_started`: nothing was changed. Every 4xx, a 501, and a 502 `sandbox_unreachable`. - `unknown`: the work may have happened. Any other 5xx. - `completed` and `partial`: the work happened, in whole or in part. Meadow does not send them today. Handle them as `unknown`. A sandbox create that fails after Meadow accepted it is not an error response: the create returns 202, and the sandbox later has `status` `failed` and a `failure_reason`.
  - Allowed values: `not_started`, `completed`, `partial`, `unknown`

### Attempt

One try at one vendor, for a model call or a sandbox create.

- `provider` (enum, required) — The name of a vendor. Model providers and sandbox providers share one list. Model providers: `anthropic`, `openai`, `google`, `xai`, `azure`, `bedrock`, `vertex`, `openrouter`, `fireworks`, `deepseek`. Sandbox providers: `daytona`, `modal`.
  - Allowed values: `anthropic`, `openai`, `google`, `xai`, `azure`, `bedrock`, `vertex`, `openrouter`, `fireworks`, `deepseek`, `daytona`, `modal`
- `outcome` (enum, required) — How the try ended. - `served`: this vendor served the request. - `unsupported`: the vendor cannot do what was asked, such as a resource size, a network rule, or a model it does not offer. - `refused`: the vendor rejected the request or the stored credential. - `no_capacity`: the vendor had no capacity. - `timeout`: the vendor did not answer in time. - `rate_limited`: the vendor answered 429. - `error`: any other failure.
  - Allowed values: `served`, `unsupported`, `refused`, `no_capacity`, `timeout`, `rate_limited`, `error`
- `reason` (enum, optional) — A stable code for why the try ended as it did. It is narrower than `outcome`, and it is the code to branch on or to count. More values can be added: treat one you do not know like `vendor_error`. - `served`: this vendor served the request. - `no_capacity`: the vendor had no capacity. - `quota_exceeded`: the vendor account is out of quota or credit. - `rate_limited`: the vendor answered 429. - `timeout`: the vendor did not answer in time. - `auth_failed`: the vendor rejected the stored vendor key. - `invalid_request`: the vendor rejected the request itself. - `refused`: the vendor refused for another reason. - `unsupported`: the vendor cannot do what was asked, such as a model, a GPU type, a size or a network rule. - `no_provider_key`: skipped, because no usable vendor key was stored. - `image_pull_failed`, `build_failed`: the vendor could not pull or build the image (sandboxes). - `provider_lost`: the vendor lost the sandbox while it was starting. - `vendor_error`: any other failure.
  - Allowed values: `served`, `no_capacity`, `quota_exceeded`, `rate_limited`, `timeout`, `auth_failed`, `invalid_request`, `refused`, `unsupported`, `no_provider_key`, `image_pull_failed`, `build_failed`, `provider_lost`, `vendor_error`
- `started_at` (datetime, optional) — When Meadow started this try. Absent on attempts recorded before 2026-11-24.
- `finished_at` (datetime, optional) — When this try ended.
- `detail` (string, optional) — A short description of what happened, written by Meadow, such as `provider returned HTTP 404`. On a `served` sandbox attempt it reports resources the vendor granted that differ from the request, such as `provider granted cpu 2 instead of 1.5` or `gpu type H200 instead of H100`. It says `provider built a copy of the image for this size` when this create made a new Daytona snapshot for an `image_id`. On an `unsupported` attempt it carries the vendor's size limit, such as `daytona cannot serve this size: CPU request 8 exceeds maximum allowed per sandbox (4)`. Absent when there is nothing to say.
- `duration_ms` (integer, optional) — How long the try took, in milliseconds.

## Examples

### Still running, read with stdout_offset=14

**Response**

```json
{
  "id": "exec_0000e1b1",
  "status": "running",
  "exit_code": null,
  "stdout": "tick 3\n",
  "stderr": "",
  "stdout_offset": 21,
  "stderr_offset": 0,
  "started_at": "2026-11-23T22:20:50.758Z",
  "finished_at": null
}
```

**SDK Code**

```python Still running, read with stdout_offset=14
import requests

url = "https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1"

querystring = {"stderr_offset":"0","stdout_offset":"14","wait_seconds":"10"}

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Still running, read with stdout_offset=14
const url = 'https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Still running, read with stdout_offset=14
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Still running, read with stdout_offset=14
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Still running, read with stdout_offset=14
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Still running, read with stdout_offset=14
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Still running, read with stdout_offset=14
using RestSharp;

var client = new RestClient("https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Still running, read with stdout_offset=14
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Finished, read with stdout_offset=0

**Response**

```json
{
  "id": "exec_0000e1b1",
  "status": "exited",
  "exit_code": 0,
  "stdout": "tick 1\ntick 2\ntick 3\ntick 4\ntick 5\ntick 6\ndone\n",
  "stderr": "",
  "stdout_offset": 47,
  "stderr_offset": 0,
  "started_at": "2026-11-23T22:20:50.758Z",
  "finished_at": "2026-11-23T22:20:57.053Z"
}
```

**SDK Code**

```python Finished, read with stdout_offset=0
import requests

url = "https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1"

querystring = {"stderr_offset":"0","stdout_offset":"14","wait_seconds":"10"}

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Finished, read with stdout_offset=0
const url = 'https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Finished, read with stdout_offset=0
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Finished, read with stdout_offset=0
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Finished, read with stdout_offset=0
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Finished, read with stdout_offset=0
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Finished, read with stdout_offset=0
using RestSharp;

var client = new RestClient("https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Finished, read with stdout_offset=0
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/sandboxes/sbx_0000be20/execs/exec_0000e1b1?stderr_offset=0&stdout_offset=14&wait_seconds=10")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```