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

# Logs and metrics

> Read what a sandbox's commands wrote and how much CPU, memory and disk it used.

**You need** a sandbox ([Quickstart](https://docs.styne.ai/quickstart.md)).

## Read command logs

`GET /sandboxes/{id}/logs` answers with what the commands of the sandbox wrote to stdout and stderr: every command
started through `exec`, `/commands` or the envd API, read from [the command history](https://docs.styne.ai/exec.md). Entries come oldest first,
in E2B's two shapes:

```text theme={"theme":"css-variables"}
{
  "logs": [{ "timestamp": "2026-11-12T10:00:00.000Z", "line": "listening on 8080" }],
  "logEntries": [{
    "timestamp": "2026-11-12T10:00:00.000Z",
    "level": "info",
    "message": "listening on 8080",
    "fields": { "commandId": "cmd_...", "stream": "stdout" }
  }]
}
```

`limit` (default 1000, at most 10000) keeps the newest lines, `stream` is `stdout`, `stderr` or `all`, and `start` and
`end` (milliseconds since the epoch) bound the commands by when they started. A line carries the time its command
started. `stderr` lines have the level `warn`. Only the last 1 MiB of each stream of a command is kept. Finished commands of the last
6 hours also come from the stored history with the last 16 KiB of each stream, so an API restart keeps them and every API
instance shows them. A sandbox of another account is a `404`.

## Read CPU, memory and disk

Read how much CPU, memory and disk one of your sandboxes used over a window. The sample is E2B's `SandboxMetric`, so
the E2B SDK's `getMetrics` reads it unchanged.

```bash theme={"theme":"css-variables"}
curl -sS "https://api.styne.ai/sandboxes/$SANDBOX_ID/metrics" \
  -H "Authorization: Bearer $STYNE_API_KEY"
```

The answer is an array, oldest sample first:

```text theme={"theme":"css-variables"}
[
  {
    "timestamp": "2026-11-12T10:00:00.000Z",
    "timestampUnix": 1794477600,
    "cpuCount": 2,
    "cpuUsedPct": 12.5,
    "memUsed": 268435456,
    "memTotal": 2147483648,
    "diskUsed": 536870912,
    "diskTotal": 10737418240
  }
]
```

`start` and `end` (milliseconds since the epoch, both optional) bound the window; a window that runs backwards is a
`400`. A sandbox of another account is a `404`, the same as one that does not exist.

## Operations

| Method | Path | What it does |
| - | - | - |
| `GET` | `/sandboxes/{id}/logs` | Read the output of a sandbox's commands |
| `GET` | `/sandboxes/{id}/metrics` | Read a sandbox's CPU, memory and disk over time |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.