> ## Documentation Index
> Fetch the complete documentation index at: https://docs.beta.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Set a sandbox's timeout (E2B)

E2B's `POST /sandboxes/{sandboxID}/timeout`. The sandbox now ends `timeout` seconds from now (at least 1, at most the plan's limit), as `POST /v1/sandboxes/{sandbox_id}/timeout` sets it.

` POST /compat/e2b/sandboxes/{sandboxID}/timeout `

Set a sandbox's timeout (E2B)

E2B's `POST /sandboxes/{sandboxID}/timeout`. The sandbox now ends `timeout` seconds from now (at least 1, at most the plan's limit), as `POST /v1/sandboxes/{sandbox_id}/timeout` sets it.

## Servers

- ` https://beta-api.b3os.org ` — API (API keys and CLI tokens)

- ` https://beta.b3os.org ` — Dashboard (session cookie and CSRF header; same paths)

## Authentication

The operation accepts these alternatives. Schemes within one alternative are required together.

### Alternative 1

- ` apiKey `: ` http `

  - HTTP scheme: ` bearer ` (b3os_sk_ API key or b3os_pat_ token)

  - `Authorization: Bearer <credential>`. Two credential kinds are accepted:

- **API keys** `b3os_sk_<32 base32>_<crc32>`, created in the dashboard or with `POST /v1/keys`. A key belongs to
  one project, has scopes, an optional spend cap and expiry, and is shown only once.
- **CLI tokens** `b3os_pat_<32 base32>_<crc32>`, issued by the device login (`b3os login`). They act for one
  user in the organization and project chosen at approval.

Keys are stored as SHA-256 hashes. The edge exchanges them for a 60-second node token before forwarding
a request to a node, so nodes never see your key.


## Parameters

### ` sandboxID ` (path, required)

The sandbox, as `sbx-<ulid>` (the `sandboxID` of the create answer) or `sbx_<ulid>`.

- ` value `: type ` string `

  - pattern: ` "^sbx[-_][0-9a-hjkmnp-tv-z]{26}$" `

## Request body (required)

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` timeout `

  - ` timeout `: type ` integer ` — Seconds from now.

    - minimum: ` 1 `

Example:

```json
{
  "timeout": 600
}
```

## Responses

### ` 204 ` — Set.

Response header ` x-request-id ` — The request ID (`req_…`). It is the `instance` of any problem and the key for `GET /v1/requests/{request_id}`.

- ` value `: type ` string `

  - pattern: ` "^req_[0-9a-hjkmnp-tv-z]{26}$" `

Response header ` Server-Timing ` — Phase durations in milliseconds (W3C Server Timing); the handler's phases break the request down. For a
response whose body size is known, `total` runs from reading the request head to writing the response head.
Streaming responses (event streams, WebSockets, chunked bodies) carry no `total` here: they report their
final phases in the terminal event (`job.succeeded`, `job.failed`, `job.canceled`) or the final job. The
time from the first request byte to the last response byte is recorded in the node's metrics and request
log (`GET /v1/requests/{request_id}`). The edge prepends `edge_auth` and `edge_upstream`.


- ` value `: type ` string `

### ` 400 ` — A malformed value, or an option B3OS cannot honor named in the message (`invalid_request`, `unsupported_option`).

Content type: ` application/json `

- ` value `: type ` object ` — E2B's error body.

  - Required fields: ` code `, ` message `

  - ` code `: type ` integer ` — The HTTP status.

  - ` message `: type ` string `

Response header ` x-request-id ` — The request ID (`req_…`). It is the `instance` of any problem and the key for `GET /v1/requests/{request_id}`.

- ` value `: type ` string `

  - pattern: ` "^req_[0-9a-hjkmnp-tv-z]{26}$" `

Response header ` Server-Timing ` — Phase durations in milliseconds (W3C Server Timing); the handler's phases break the request down. For a
response whose body size is known, `total` runs from reading the request head to writing the response head.
Streaming responses (event streams, WebSockets, chunked bodies) carry no `total` here: they report their
final phases in the terminal event (`job.succeeded`, `job.failed`, `job.canceled`) or the final job. The
time from the first request byte to the last response byte is recorded in the node's metrics and request
log (`GET /v1/requests/{request_id}`). The edge prepends `edge_auth` and `edge_upstream`.


- ` value `: type ` string `

Example:

```json
{
  "code": 400,
  "message": "mcp is not supported by B3OS: run your MCP server as a process in the sandbox"
}
```

### ` 401 ` — Missing or invalid B3OS key in `X-API-KEY` (`unauthorized`).

Content type: ` application/json `

- ` value `: type ` object ` — E2B's error body.

  - Required fields: ` code `, ` message `

  - ` code `: type ` integer ` — The HTTP status.

  - ` message `: type ` string `

Response header ` x-request-id ` — The request ID (`req_…`). It is the `instance` of any problem and the key for `GET /v1/requests/{request_id}`.

- ` value `: type ` string `

  - pattern: ` "^req_[0-9a-hjkmnp-tv-z]{26}$" `

Response header ` Server-Timing ` — Phase durations in milliseconds (W3C Server Timing); the handler's phases break the request down. For a
response whose body size is known, `total` runs from reading the request head to writing the response head.
Streaming responses (event streams, WebSockets, chunked bodies) carry no `total` here: they report their
final phases in the terminal event (`job.succeeded`, `job.failed`, `job.canceled`) or the final job. The
time from the first request byte to the last response byte is recorded in the node's metrics and request
log (`GET /v1/requests/{request_id}`). The edge prepends `edge_auth` and `edge_upstream`.


- ` value `: type ` string `

Example:

```json
{
  "code": 401,
  "message": "unknown key"
}
```

### ` 404 ` — No such live sandbox, template or file (`sandbox_not_found`, `template_not_found`, `file_not_found`).

Content type: ` application/json `

- ` value `: type ` object ` — E2B's error body.

  - Required fields: ` code `, ` message `

  - ` code `: type ` integer ` — The HTTP status.

  - ` message `: type ` string `

Response header ` x-request-id ` — The request ID (`req_…`). It is the `instance` of any problem and the key for `GET /v1/requests/{request_id}`.

- ` value `: type ` string `

  - pattern: ` "^req_[0-9a-hjkmnp-tv-z]{26}$" `

Response header ` Server-Timing ` — Phase durations in milliseconds (W3C Server Timing); the handler's phases break the request down. For a
response whose body size is known, `total` runs from reading the request head to writing the response head.
Streaming responses (event streams, WebSockets, chunked bodies) carry no `total` here: they report their
final phases in the terminal event (`job.succeeded`, `job.failed`, `job.canceled`) or the final job. The
time from the first request byte to the last response byte is recorded in the node's metrics and request
log (`GET /v1/requests/{request_id}`). The edge prepends `edge_auth` and `edge_upstream`.


- ` value `: type ` string `

Example:

```json
{
  "code": 404,
  "message": "No sandbox sbx_01m5t68q1b590rj801nbzsqzkk in this project"
}
```

## Request examples

### cURL

```curl
curl -X POST 'https://beta-api.b3os.org/compat/e2b/sandboxes/string/timeout' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "timeout": 600
}'
```

### JavaScript

```javascript
const response = await fetch('https://beta-api.b3os.org/compat/e2b/sandboxes/string/timeout', {
  method: 'POST',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "timeout": 600
  })
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.post('https://beta-api.b3os.org/compat/e2b/sandboxes/string/timeout', headers=headers, json={
  "timeout": 600
})
print(response.json())
```