Skip to main content
Create a sandbox to execute commands and exchange files in one isolated running environment. Commands share its filesystem until it stops. All requests below use https://api.mobilerun.ai/v1/compute and your API key. TypeScript and Python examples require SDK 6.3.0 or later.

Serverless Functions

For saved, versioned code that runs in a fresh sandbox each time, see Working with Serverless Functions. That guide covers creating functions, running them, and reading results and logs.

Create and use a sandbox

Use the API for a standalone sandbox. Create it once, execute commands in it, then stop it when finished. This example needs no device or outbound network access.
Creation returns 201; poll its status until running before executing commands. Command execution returns 200 when the command exits or 202 while it continues. Save commandId to poll the command before stopping a sandbox that still has work to finish. Stopping returns 202, or 204 if already stopped. Use URL-encoded absolute paths within /work for file operations. Keep files you need by downloading them before the sandbox stops.

Limits

Concurrency and available minutes can also prevent a sandbox from starting.

Results and logs

Sandbox command results include status, exitCode, timedOut, stdout, stderr, and truncated. A successful HTTP response does not guarantee the command succeeded: inspect its exit code. For larger results, write a file under /work and download it within the file limit.

Network access and cost

Sandbox creation accepts allowedHosts. External network requests must use HTTPS on the default port and match an allowed hostname exactly; redirect targets are not followed automatically. Mobilerun API access uses platform-controlled credentials and permissions. Keep secrets out of source, inputs, output, and logs. Sandboxes consume function minutes while running, including idle time. Stop them when finished. See Credits & usage for function minutes and concurrent-run capacity.