Read a background command
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_truncatedorstderr_truncatedis true (also sent asX-Meadow-Stdout-TruncatedandX-Meadow-Stderr-Truncatedresponse 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_truncatedorstderr_truncated, andstdout_offsetandstderr_offsetare 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
failedwithfailure_reasonstate_lostand a nullexit_code. Treat that as an unknown outcome: the command itself may have finished.failedis a new status (2026-11-24). Treat any status other thanrunningas final. - If the vendor loses the sandbox while the command runs, the command reads
failedwithfailure_reasonsandbox_lostand a nullexit_code, and the sandbox readsfailedwithfailure_reasonprovider_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 codesandbox_unreachableandRetry-After, and the command staysrunning: call again. - If that goes on for 10 minutes for one command, with the vendor still
reporting the sandbox as running, the command reads
failedwithfailure_reasonprovider_unreachable. Its siblings and the sandbox are left alone.
Scope: sandboxes.
Authentication
A Meadow API key, sent as Authorization: Bearer mdw_.... The header
x-api-key: mdw_... is accepted in its place.
Path parameters
The sandbox id returned by POST /v1/sandboxes. It must belong to the key’s project.
The id returned when the background command was started.
Query parameters
Byte offset to read stdout from. Use the stdout_offset of the last response. At least 0.
Byte offset to read stderr from. Use the stderr_offset of the last response. At least 0.
Response headers
Meadow’s id for this request, req_ and 24 hex characters. Every response
carries it, including errors, streams and unknown routes. Every error in the
Error schema repeats it as request_id. Quote it when you report a problem.
true when the command wrote more than 16 MiB to stdout. Absent otherwise.
true when the command wrote more than 16 MiB to stderr. Absent otherwise.
Response
running: still going.exited: ended on its own. Readexit_code.killed: ended by the kill call.killedwith a nullexit_codemeans the sandbox was deleted or timed out before the command ended.timed_out: killed attimeout_seconds.failed: Meadow could not learn how the command ended.failure_reasonsays 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 thanrunningas final.
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 andexit_codeis null. The command itself may have finished.sandbox_lost: the vendor lost the sandbox while the command was running. The sandbox readsfailedwithfailure_reasonprovider_lost. This value is new (2026-11-24). These commands readkilledwith a nullexit_codebefore.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.
Output from stdout_offset onward. Empty in the start and kill responses.
Error output from stderr_offset onward. Empty in the start and kill responses.
The byte offset after the returned stdout. Pass this on the next read.
The byte offset after the returned stderr. Pass this on the next read.
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.
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.