redu-cloud / sandbox-sdk
PHP client for the redu.cloud API: sandboxes, isolated machines for running commands.
Requires
- php: >=8.2
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^11.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Start isolated sandboxes on redu.cloud and run commands in them: files, background commands, pause and resume, snapshots and forks. PHP 8.2 or later, with the curl extension. No framework, no other dependency.
composer require redu-cloud/sandbox-sdk
The Composer package is redu-cloud/sandbox-sdk, its namespace Redu\Sandbox.
Quick start
$client = new Redu\Sandbox\Client(); // reads REDU_API_KEY $sb = $client->sandboxes->create(template: 'ubuntu-node'); try { $out = $client->sandboxes->exec($sb->id, 'echo hello'); echo $out->exitCode, ' ', $out->stdout; $client->sandboxes->writeFile($sb->id, '/tmp/note.txt', 'hi'); echo $client->sandboxes->readFile($sb->id, '/tmp/note.txt'); } finally { $client->sandboxes->delete($sb->id); }
API key
Create a key in the redu console with the scope sandbox:* (or just the sandbox:<action> scopes you need) and set
REDU_API_KEY, or pass new Redu\Sandbox\Client(apiKey: ...). A full-access * key does not include sandboxes. An
account that sandboxes are not open to gets 403 sandboxes_not_available.
What it covers
| Area | Methods |
|---|---|
| Sandboxes | create, get, list, delete, templates, limits, extend, resize |
| Commands | exec (waits for the result), startCommand, followCommand, waitForCommand, stopCommand |
| Files | writeFile, readFile, readFileRange, readLargeFile |
| Pause and resume | pause, resume, suspend, setLifecycle (pause by itself when idle) |
| Snapshots and forks | takeSnapshot, listSnapshots, deleteSnapshot, fork |
| Network | changeEgress, addPublicName, removePublicName, egressLog |
| Access | setSecrets, openTerminal, openSsh, addSshKey |
| Audit and templates | auditLog, auditEvents, buildTemplate, deleteTemplate |
These are methods of $client->sandboxes. create also takes a size (vcpus, memoryMb, diskGb), one of your
private networks (networkId), egress rules, secrets bound to hosts, a spend cap (maxSpend) and a lifetime
(timeoutS).
Errors
Every refusal is a Redu\Sandbox\ReduException with status, errorCode (redu's stable code, such as
sandbox_not_found), getMessage() and hint. A command's error also says whether it ran: Ran::No is safe to send
again; after Ran::Yes or Ran::Unknown, check its effects first. A 429 is sent again by itself after its
Retry-After.
Options
$client = new Redu\Sandbox\Client( apiKey: getenv('REDU_API_KEY') ?: null, baseUrl: getenv('REDU_API_BASE') ?: 'https://console.redu.cloud', requestTimeout: 120.0, // seconds per request pollInterval: 5.0, // seconds between reads of a request that answered 202 maxRateLimitRetries: 2, userAgent: 'my-agent/1.0', httpClient: null, // your own Redu\Sandbox\Http\HttpClient, to send through another stack );
The default HTTP client keeps one connection to the API open between calls (libcurl's own idle limit applies, 118 s by default). Reads, file writes and keyed command starts reuse it. A create, a fork, a pause, a resume or a delete always opens a new one, so that it can never be sent twice.
More
- Reference: every method, option and error code, with examples
- Sandboxes on redu
Apache License 2.0 (Apache-2.0): see the LICENSE file. Copyright 2026 REDU CLOUD LTD.