Sandboxes
Approvals
Approval rules hold risky commands until a person approves or denies them in the dashboard.
An approval rule is a pattern. When a command matches one of your organization's rules, it doesn't run. The API answers 202 with an execution in pending_approval, and the command waits for a person.
Default rules
Every new organization starts with these. You can turn them off, edit them or add your own in the dashboard under Policy.
| Rule | Catches, for example |
|---|---|
| Recursive force delete | rm -rf build, rm -fr /tmp/x |
| Privilege escalation | sudo apt install …, su root |
| Pushing code to a remote | git push origin main |
| Sending data out with curl or wget | curl -X POST …, curl --data …, wget --post-file … |
| Remote shell or file copy | ssh, scp, sftp, rsync |
Rules are regular expressions, matched case-insensitively against the whole command. A rule whose pattern doesn't compile holds every command, so a typo fails safe.
What happens to a held command
execreturns202withstatus: "pending_approval"andapproval.reason, the rule's description.- The command shows up in the dashboard under Approvals, with who asked (which API key or person) and the exact command.
- A signed-in person approves or denies it, with an optional note.
- Approve: the command runs then, with the
cwd,envand timeout it was sent with. The execution moves torunning, thencompletedorfailed. - Deny: the execution becomes
denied. It never runs.
- Approve: the command runs then, with the
- Both the request and the decision are in the audit log.
An API key can't approve. POST /api/v1/executions/{id}/approve and /deny only work for a signed-in dashboard session. A key gets 403 forbidden.
Approvals guard against an agent, not against a teammate. Any signed-in member of the organization can approve a held command, including one they sent themselves. Rules match the text of the command, so they catch the usual forms and a determined person can word around them. To limit what a sandbox can reach whatever runs in it, use the network policy.
Waiting for the decision
Poll GET /api/v1/executions/{id} until status is no longer pending_approval or running. The SDK does this for you:
try {
const run = await sbx.exec("git push origin main", {
onPending: (e) => console.log(`Waiting for a person: ${e.approval?.reason}`),
approvalTimeoutMs: 15 * 60_000, // default 30 minutes
});
console.log(run.exitCode);
} catch (e) {
if (e instanceof CommandDeniedError) console.log("Denied:", e.message);
else throw e;
}Pass waitForApproval: false to get the pending execution back straight away.
Tip
Rules match the text of the command. They're a seatbelt for an agent that means well, not a wall against code that's trying to hide. The outbound network rules are the wall: they hold whatever the command looks like.