# Sandbox

> **Class** in `langsmith`

📖 [View in docs](https://reference.langchain.com/python/langsmith/sandbox/_sandbox/Sandbox)

Represents an active sandbox for running commands and file operations.

This class is typically obtained from SandboxClient.sandbox() and supports
the context manager protocol for automatic cleanup.

## Signature

```python
Sandbox(
    self,
    name: str,
    template_name: str,
    dataplane_url: Optional[str] = None,
    id: Optional[str] = None,
    status: str = 'ready',
    status_message: Optional[str] = None,
    created_at: Optional[str] = None,
    updated_at: Optional[str] = None,
    ttl_seconds: Optional[int] = None,
    idle_ttl_seconds: Optional[int] = None,
    expires_at: Optional[str] = None,
    _client: SandboxClient = None,
    _auto_delete: bool = True,
)
```

## Description

**Example:**

with client.sandbox(template_name="python-sandbox") as sandbox:
result = sandbox.run("python --version")
print(result.stdout)

## Constructors

```python
__init__(
    self,
    name: str,
    template_name: str,
    dataplane_url: Optional[str] = None,
    id: Optional[str] = None,
    status: str = 'ready',
    status_message: Optional[str] = None,
    created_at: Optional[str] = None,
    updated_at: Optional[str] = None,
    ttl_seconds: Optional[int] = None,
    idle_ttl_seconds: Optional[int] = None,
    expires_at: Optional[str] = None,
    _client: SandboxClient = None,
    _auto_delete: bool = True,
) -> None
```

| Name | Type |
|------|------|
| `name` | `str` |
| `template_name` | `str` |
| `dataplane_url` | `Optional[str]` |
| `id` | `Optional[str]` |
| `status` | `str` |
| `status_message` | `Optional[str]` |
| `created_at` | `Optional[str]` |
| `updated_at` | `Optional[str]` |
| `ttl_seconds` | `Optional[int]` |
| `idle_ttl_seconds` | `Optional[int]` |
| `expires_at` | `Optional[str]` |
| `_client` | `SandboxClient` |
| `_auto_delete` | `bool` |


## Properties

- `name`
- `template_name`
- `dataplane_url`
- `id`
- `status`
- `status_message`
- `created_at`
- `updated_at`
- `ttl_seconds`
- `idle_ttl_seconds`
- `expires_at`

## Methods

- [`from_dict()`](https://reference.langchain.com/python/langsmith/sandbox/_sandbox/Sandbox/from_dict)
- [`run()`](https://reference.langchain.com/python/langsmith/sandbox/_sandbox/Sandbox/run)
- [`reconnect()`](https://reference.langchain.com/python/langsmith/sandbox/_sandbox/Sandbox/reconnect)
- [`write()`](https://reference.langchain.com/python/langsmith/sandbox/_sandbox/Sandbox/write)
- [`read()`](https://reference.langchain.com/python/langsmith/sandbox/_sandbox/Sandbox/read)
- [`tunnel()`](https://reference.langchain.com/python/langsmith/sandbox/_sandbox/Sandbox/tunnel)
- [`service()`](https://reference.langchain.com/python/langsmith/sandbox/_sandbox/Sandbox/service)

---

[View source on GitHub](https://github.com/langchain-ai/langsmith-sdk/blob/6a74bf5af9e542d8065af8edca54b2448f430916/python/langsmith/sandbox/_sandbox.py#L32)