# A workspace that remembers

Normally each chat starts from scratch. A **named sandbox** is different: it keeps its files, installed programs and settings between chats, sleeps while you are away and wakes up when you come back – like a small computer in the cloud that is waiting for you.

## What you'll build

A sandbox called `my-notes` with a small project in it. You close the chat, open a new one tomorrow (or next week), and the assistant continues where you stopped – the files are still there.

## What you need

- Your AI assistant connected to WBX Sandbox – see [Your first result](https://sandbox.wbx.cz/docs/guides/first-result.md).
- About **ten minutes**, spread over two chats. No programming (a short code version is [at the end](#code)).

## How sleeping works

- A sandbox your assistant creates **falls asleep** after its lifetime (30 minutes unless you ask for more) or after 10 minutes without a command.
- **Asleep** means: the files on its disk stay, but running programs and memory do not – a web server you started is stopped. You don't pay for compute while it sleeps; only its disk counts as storage.
- The next command **wakes it up** in a few seconds. A sandbox that has slept for a long time may have been moved to long-term storage and takes a little longer to wake.
- A sleeping sandbox is **kept for a limited number of days** (your plan's retention, for example 7 days on the free plan) and then deleted with its files. You can ask to keep it longer, up to your plan's maximum.

## Steps

1. ### Create the named sandbox

   “Use WBX Sandbox: create a sandbox named my-notes and keep it for 14 days after it falls asleep.”

   What you see: the assistant creates the sandbox and tells you its ID (`sb_…`), its name and when it will fall asleep. Names use lowercase letters, digits, `.`, `_` and `-`. If your plan allows fewer days, the assistant gets an error with the maximum – ask again with that number.
2. ### Put something in it

   “In my-notes, create a folder project, write a file todo.md with three tasks for a garden party, and install the Python package rich.”

   What you see: the assistant writes the file and runs `pip install rich`.
3. ### Let it sleep

   Simply close the chat – after 10 minutes without a command the sandbox falls asleep. Or say it right away:

   “Put my-notes to sleep.”
4. ### Come back in a new chat

   “Use WBX Sandbox: open my sandbox my-notes and show me project/todo.md.”

   What you see: the assistant creates a sandbox with the same name – WBX returns your existing one instead and wakes it up – and shows the three tasks. The package `rich` is still installed. Programs you had running must be started again.
5. ### Check what you have, and clean up

   “List my sandboxes.”

   You get each sandbox with its state (running or asleep), since when it sleeps and how much disk it keeps. The same list is on the *Sandboxes* page in the portal (*Asleep*). When you no longer need the workspace:

   “Delete the sandbox my-notes.”

   Deleting removes the files for good.

## How to tell it works

- In the new chat the file `project/todo.md` has the content from the first chat.
- The portal lists `my-notes` under *Asleep* between your chats, with the date it will be deleted.

## The same from code

A sandbox created with `name` is reused on the next create, and `on_timeout` “pause” makes it fall asleep instead of being destroyed when its lifetime ends.

**Python**

```
# pip install wbxsandbox · export WBXSANDBOX_API_KEY=…
from wbxsandbox import Sandbox

# the first call creates it, every later call returns the same sandbox (woken up if asleep)
sb = Sandbox.create(template="base", name="my-notes", timeout=1800,
                    on_timeout="pause", idle_timeout=600, keep_days=14)
sb.files.write("/home/user/project/todo.md", "- buy lemons\n")
print(sb.files.read_text("/home/user/project/todo.md"))
sb.sleep()                     # fall asleep now; files stay
# sb.kill()                    # delete it with its files when you are done
```

**TypeScript**

```
// npm install wbxsandbox · export WBXSANDBOX_API_KEY=…
import { WBX } from "wbxsandbox";

const wbx = new WBX();
// the first call creates it, every later call returns the same sandbox (woken up if asleep)
const sb = await wbx.sandboxes.create({
  template: "base", name: "my-notes", timeoutSeconds: 1800,
  onTimeout: "pause", idleTimeoutSeconds: 600, keepDays: 14,
});
console.log(sb.existing ? "reused" : "new", sb.id);
await sb.files.write("/home/user/project/todo.md", "- buy lemons\n");
console.log(await sb.files.readText("/home/user/project/todo.md"));
await sb.sleep();              // fall asleep now; files stay
// await sb.kill();            // delete it with its files when you are done
```

**curl**

```
curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes \
  -H "Authorization: Bearer $WBXSANDBOX_API_KEY" -H "Content-Type: application/json" \
  -d '{"template": "base", "name": "my-notes", "timeout_s": 1800,
       "on_timeout": "pause", "idle_timeout_s": 600, "keep_days": 14}'

curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes/SB_ID/sleep -H "Authorization: Bearer $WBXSANDBOX_API_KEY"
curl -s -X PUT https://sandbox.wbx.cz/v1/sandboxes/SB_ID/keep \
  -H "Authorization: Bearer $WBXSANDBOX_API_KEY" -H "Content-Type: application/json" -d '{"keep_days": 14}'
```

`pause` in the REST API and the SDKs (`sb.pause()`) is something else: a short freeze *with* memory. For a workspace you come back to, use sleep. See [Sleep and wake](https://sandbox.wbx.cz/docs/sandboxes/sleep.md).

## Common problems

| What you see | What to do |
| --- | --- |
| In the new chat the assistant creates an empty sandbox | It forgot the name. Say the exact name: “open my sandbox **my-notes**”, or ask it to list your sandboxes first. |
| The sandbox is gone | It slept longer than it was kept (see `delete_at` in the list) or someone deleted it. Ask for a longer keep next time; important results also belong on your own computer. |
| An error about `keep_days` | More days than your plan allows – the message says the maximum. |
| “account limit reached …” (`429 quota`) when waking | A waking sandbox counts as running. End or put to sleep another sandbox, then try again. |
| A program you started is not running any more | Expected after sleep – ask the assistant to start it again. |

## Next steps

- [Get files in and out](https://sandbox.wbx.cz/docs/guides/files.md): Bring your data into the workspace and results back.
- [Prepare once, run many](https://sandbox.wbx.cz/docs/guides/snapshot-clone.md): Save a prepared workspace and start copies of it.
- [Sleep and wake](https://sandbox.wbx.cz/docs/sandboxes/sleep.md): The reference: lifetime, inactivity, keep and archive.

Source: https://sandbox.wbx.cz/docs/guides/workspace
