# E2B SDK

> Hosted E2B endpoint configuration and method mappings for JavaScript and Python.

## Connection

Set `E2B_API_URL=https://e2b.shardflux.dev`, `E2B_DOMAIN=e2b.shardflux.dev` and `E2B_API_KEY` to a Shardflux project
API key. The returned sandbox domain supplies envd at `https://49983-<sandboxId>.e2b.shardflux.dev` and application
ports at `https://<port>-<sandboxId>.e2b.shardflux.dev`. The [guide](https://docs.shardflux.dev/guides/e2b.md) includes JavaScript and Python examples.

| Client | Tested version |
| --- | --- |
| Official npm `e2b` | 2.51.0 |
| Official PyPI `e2b` | 2.16.0 |

## Method mappings

| E2B method | Behavior on Shardflux |
| --- | --- |
| Create, connect, getInfo, kill | Workspace creation/resume, resource view and deletion; sandbox id equals workspace id |
| List | Project workspaces, exact metadata filters, running/paused filters and pagination |
| Commands, background handles and wait | Streamed stdout/stderr, exit codes and command timeouts |
| File read, write, list and remove | Native file tools; byte and text content; recursive removal |
| Pause and resume | Memory, processes and disk preserved; connect resumes |
| Sandbox timeout | Defaults to 300 seconds; positive values up to 24 hours; setTimeout renews from now |
| Timeout action kill / pause | Delete / suspend; action begins within the one-second expiry interval |
| Lifecycle autoResume false | Explicit connect controls resume |
| HTTP and WebSocket application ports | Private traffic token in `e2b-traffic-access-token`; native port entitlement and quota apply |
| Snapshot/template builds, E2B metrics, dynamic network rules, watchers, PTYs, sandbox-wide envs, reboot resume and autoResume true | Explicit protocol error; use the native Shardflux APIs for their corresponding capabilities |

Metadata maps to workspace labels. `metadata.shardflux_workspace_key` selects a stable workspace key; an ordinary
create generates a fresh key. Relative file paths resolve under `/home/user`. Directory listing supports depth
1..32 and returns up to 1000 entries per directory and 10000 per recursive response; larger listings return a
resource error. Pause requires a persistent workspace. API-key revocation stops access to its sandbox tools.
