sandbox_stop

Stops a box and releases its machine and devices. The box is archived the way the idle rules archive one: its disk is kept 30 days and anything that opens the box brings it back until then, while stopping an archived box deletes it for good. It returns unsavedWork, what in /work is neither pushed to a git remote nor kept in a persistent folder. Call it as soon as there is nothing left for the person to see.

Input Output
id ok, id, status (stopping, or terminated when the box was deleted), keptUntil, unsavedWork (path, why), note; linkedFrom when other boxes link to this one
sandbox_stop { "id": "<id>" }
  • The result is { "ok": true, "id": "<id>", "status": "stopping", "keptUntil": "<30 days from now>", "note": "Stopped: the box is archived within a few minutes …" }. A running box is frozen at once: a takeover ends, its phones are released and its persistent folders are saved (below). Within a few minutes it is archived, as the idle rules archive a box (Box states): its status turns from stopping to archived, with a statusReason such as archived: sandbox_stop by …. Box time is billed up to the freeze, and the archived disk as stored files until it is deleted (Credits).

  • Until keptUntil, 30 days after the stop, the same box comes back, with its id and URLs, in a minute or two, whatever opens it: any call on it, its URLs, its review link, the person opening it in the app, or sandbox_start { "restore": "<id>", "goal": "<its goal>" }. /work is as it was when it stopped, and commands that were running with background: true start again; what was only in memory and attached phones are not kept. A review waiting for the person stays valid.

  • While the box is still stopping, anything that would wake a frozen box (a tool call that acts on it, a page load in a browser, the person opening it, a link connection from another box) wakes it instead and calls off the stop: the box runs under the usual idle rules again. Call sandbox_stop again to stop it.

  • Stopping an archived box deletes it for good: its archived copy is deleted, a waiting review ends, status is terminated and note is Deleted: this box was archived, and its archived copy is now deleted for good. From then on its URLs answer 503 box is terminated, and a new box has a new id and new URLs. An archived copy that reaches its keptUntil is deleted the same way.

  • A box that cannot be archived (one on a dedicated machine, or when no host can take its archived copy right then) is deleted at once: status is terminated, there is no keptUntil, and note says that everything on it except its persistent folders is gone.

  • Before it stops a running box, it checks /work and returns in unsavedWork what is neither pushed to a git remote nor kept in a persistent folder, each entry with path and why:

    • a directory that is not a git repository and has none within four levels below it: not a git repository (12 files);
    • a repository with no remote: git repository with no remote (3 commits), 2 uncommitted changes;
    • a repository with commits on no remote, or with uncommitted changes: 1 commit not on any remote, 4 uncommitted changes;
    • files directly in /work: 2 files directly in /work.

    Hidden entries, links into /persist and the *.full.log files sandbox_exec leaves in /work do not count, and unsavedWork is absent when nothing is found. These come back with the box until keptUntil and are deleted after that: to keep them longer, push them to a git remote or copy them into a persistent folder before you stop the box (POST /v1/boxes/{id}/persist/{name} attaches one to a running box, see REST), or bring the box back and do it then. A frozen box is not checked; note says so, as it does when the check could not finish, which never holds up the stop.

  • Its persistent folders (persist at sandbox_start) are saved when it stops and outlive it, also once it is deleted: a folder that changed since its last save is saved after the programs that have files open in it are sent SIGTERM and given up to 20 seconds (then SIGKILL); one that did not change stays as it was last saved. The next box that attaches a folder gets it back.

  • Devices leased with sandbox_device are released with it.

  • In the app the box's card stays, marked Archived, until the box is deleted, and opening it brings the box back. sandbox_media and GET /v1/boxes/{id}/media (REST) return its screenshots for 30 days after capture and its recordings for 7, also once the box is deleted. Use sandbox_review when the person needs to try a running app.

  • When other boxes link to this one, the result also has linkedFrom, those boxes in the same form as the stopped box's sandbox_status.linkedFrom (boxId, boxName, status, name, port, fromPort), and note ends with These boxes had links to this box; their connections to it now fail until you re-point each link with sandbox_wire {id, service, port, fromBox}. (Links to other boxes).

  • It works on a frozen box too, without waking it.

  • When the box cannot be frozen, the call fails with 503 (… it is still running and nothing was deleted. Call sandbox_stop again in a minute); when the box is used again while it is being stopped, with 409. Nothing is deleted either way: call it again.

  • Stop only boxes you started, or whose name says they are yours; ask before stopping a teammate's box, and never stop boxes in bulk by age (sandbox_list).

  • DELETE /v1/boxes/{id} stops a box the same way and returns the same fields (REST), and so does Shut down in the app.


Every tool and topic is listed in the tool reference.