# Daytona-compatible API

> Point the Daytona SDK at Sandboxer by changing the API URL and key. What's covered, what isn't yet, and how the two differ.

Sandboxer has a second API that speaks Daytona's. Code that uses the Daytona TypeScript or Python SDK for sandboxes, commands, files and previews runs on Sandboxer when you change two environment variables. See [what's covered](#whats-covered) below. Your sandboxes are Sandboxer microVMs, billed and limited exactly like the ones you create with `sbx` or the [Sandboxer API](/docs/api).

Moving a project over step by step? The [Daytona migration guide](/migrate/daytona) walks through it. This page is the reference.

## Switch

1. [Create an API key](/docs/api-keys) in the dashboard, or with `sbx api-key create daytona --preset ci` (create, run, files, previews, and delete what it created).
2. Set two variables where your code runs:

```bash
export DAYTONA_API_URL=https://sandboxer.com/daytona/api
export DAYTONA_API_KEY=sbx_live_…   # a Sandboxer API key
```

3. Run your code unchanged:

```ts
import { Daytona } from "@daytonaio/sdk";

const daytona = new Daytona(); // reads DAYTONA_API_URL and DAYTONA_API_KEY
const sandbox = await daytona.create();
const r = await sandbox.process.executeCommand("echo hello");
console.log(r.result); // hello
const link = await sandbox.getPreviewLink(3000); // https://…-3000.box.sandboxer.com, plus a token
await sandbox.stop();
await sandbox.delete();
```

```python
from daytona import Daytona

daytona = Daytona()  # reads DAYTONA_API_URL and DAYTONA_API_KEY
sandbox = daytona.create()
print(sandbox.process.exec("echo hello").result)  # hello
sandbox.fs.upload_file(b"hi", "/tmp/hi.txt")
sandbox.stop()
sandbox.delete()
```

We test the official TypeScript and Python SDKs (`@daytonaio/sdk` and `daytona` 0.225.0) against this API end to end: create, run a command, write and read a file, open a preview URL with its token, stop and delete. The Go, Ruby and Java SDKs call the same API, but we haven't tested them.

## What's covered

| Area | Supported |
| - | - |
| **Sandboxes** | Create, list (by id, name or labels, paged), get, delete, start, stop. Labels, auto-stop, auto-delete, public previews. |
| **Sizes** | Pick a [Sandboxer size](/docs/machines) with the label `sandboxer.type`: `small`, `default`, `large` or `xlarge`, for example `labels: { "sandboxer.type": "default" }`. Without it you get `small`. Raw API calls can instead send `cpu`, `memory` and `disk`, which pick the smallest size that has at least each. Above `xlarge` (16 vCPU, 32 GB, 251 GB) is refused, and `xlarge` needs the $100 plan or higher. |
| **Regions** | `target` picks the [region](/docs/regions): `us` or `eu`, or `us-east` / `eu-central`. Without it, the region nearest you. |
| **Processes** | `executeCommand`/`exec` and `codeRun` (Python, JavaScript, TypeScript). Sessions keep their working directory and exported variables, with sync or async commands and their logs. |
| **Files** | List, info, upload (single and bulk), download (single and bulk), delete, create folder, move, find, search, replace, permissions. Up to 50 MiB per file. |
| **Previews** | `getPreviewLink` returns the port's HTTPS URL and its token (sent as `x-daytona-preview-token`). Signed, expiring preview URLs, and expiring them early. |
| **Ports and info** | Listening ports, work and home directories, version. |
| **Account** | Current user and API keys (create, list, get, delete). Daytona's `write:sandboxes` and `delete:sandboxes` map to [Sandboxer key scopes](/docs/api-keys). |
| **Organizations** | `X-Daytona-Organization-ID` picks one of your [organizations](/docs/organizations), so usage is billed to its wallet. |

## Not covered yet

These return an error with the code `not_supported`, never a silent no-op. A field counts as used when it's set to anything but its default. Real-time events are refused when the connection opens, and the SDKs fall back to polling.

- Custom images, Daytona snapshots and declarative builds. Every sandbox starts from Sandboxer's Ubuntu image. For your own base, use [named snapshots](/docs/snapshots) through `sbx` or the Sandboxer API.
- Volumes, GPUs, spot instances.
- Daytona's pause and fork. Here, a plain stop already keeps memory.
- Network controls: `networkBlockAll`, allow-lists, outbound proxy.
- Git, LSP, computer use, PTY and the code interpreter in the toolbox.
- Following command logs live (`follow`). Fetch them instead.
- Sorting the list, and filtering it by state or snapshot.

## How it differs

- **Every sandbox is a microVM.** Each sandbox is a Linux VM with its own kernel, root, systemd, Docker and `/dev/kvm`. There are no container sandboxes. `kvm` is always on.
- **Stop keeps memory.** A stop snapshots memory and disk, and a start resumes with running processes intact. A stopped sandbox is archived at once, so `autoArchiveInterval` is accepted but has no effect.
- **Auto-stop works as in Daytona.** `autoStopInterval` (minutes, default 15) stops the sandbox that many minutes after it starts or after its last toolbox call, whichever is later. A command keeps it up until the command's timeout plus a minute, so a command with no timeout holds it for about 11 minutes. A stopped sandbox isn't billed for compute. `0` means it never stops by itself, so stop or delete it when you're done. On the free trial the interval must be 8 hours or less, and `0` is refused with `trial_auto_stop_required`. On any plan it's at most 30 days. Sandboxer's own [idle pause](/docs/long-running) is off for sandboxes created through this API.
- **Previews are per port.** Each port has its own token, not one per sandbox.
- **Errors** use Daytona's shape (`statusCode`, `message`, `error`) with Sandboxer's machine code in `code`, so the SDKs raise their usual exceptions.
- **The same account.** Billing, [limits](/docs/limits), API key scopes and organizations are shared with the rest of Sandboxer. A sandbox created through either API shows up in both, in the dashboard and in `sbx ls`.

Endpoints: the control API is at `https://sandboxer.com/daytona/api` and the toolbox at `https://sandboxer.com/daytona/toolbox`. The SDKs find the toolbox themselves.
