> For the complete documentation index, see [llms.txt](https://docs.orchard.airoverflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.orchard.airoverflow.com/guides/sandbox-lifecycle.md).

# Sandbox lifecycle

A sandbox is one virtual device. It has a stable **uuid**, a **name**, a **state** (`stopped` / `booting` / `running` / …), a **tag** with a colour, and a set of **capabilities** describing what you may do with it.

## Selectors

Everywhere a guide says "address a sandbox", you pass a selector to `orchard.sandbox(...)`, resolved in this order: exact uuid, uuid prefix, exact name, then tag. A tag that matches several sandboxes is ambiguous for a single-target call; use `sandboxes.resolveAll` / `sandboxes.resolve_all` to get them all.

## List, create, control

{% tabs %}
{% tab title="Python" %}

```python
orchard.sandboxes.list()["instances"]
orchard.sandboxes.create(platform="android", name="x", cpu=4, memory_mb=4096,
                         image="system-images;android-35;google_apis;x86_64")
orchard.sandboxes.create_sim(name="sim", device_type="iPhone 15", runtime="iOS-18-0")

sb = orchard.sandbox("x")
sb.start(); sb.stop()
sb.edit(notes="hi", cpu=8, memory_mb=8192)   # cpu/memory need the sandbox stopped
sb.tag("payments", "#22c55e")
sb.delete()                                   # terminate (deletes its disk)
```

{% endtab %}

{% tab title="TypeScript" %}

```ts
await orchard.sandboxes.list();
await orchard.sandboxes.create({ platform: "android", name: "x", cpu: 4, memory_mb: 4096,
  image: "system-images;android-35;google_apis;x86_64" });
await orchard.sandboxes.createSim({ name: "sim", device_type: "iPhone 15", runtime: "iOS-18-0" });

const sb = await orchard.sandbox("x");
await sb.start(); await sb.stop();
await sb.edit({ notes: "hi", cpu: 8, memory_mb: 8192 });  // cpu/memory need it stopped
await sb.tag("payments", "#22c55e");
await sb.delete();
```

{% endtab %}
{% endtabs %}

## Editable fields

`edit` accepts `notes`, `tag`, `tag_color` (`#rrggbb`), `owner` (org-admin only), and `cpu` / `memory_mb` (the sandbox must be stopped; the change is re-checked against your org quota). `tag(name, color)` is a shortcut for the first two.

## Snapshots & templates

```python
sb.snapshots.create("clean")
sb.snapshots.restore("clean")
sb.snapshots.save_as_template("golden", visibility="org")
orchard.templates.launch(template_id, "from-tpl")
```

See [Files & apps](/guides/files-and-apps.md) and [Live channels](/guides/live-channels.md) for what you do with a running sandbox.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.orchard.airoverflow.com/guides/sandbox-lifecycle.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
