# Connect to sandbox (/docs/api-reference/sandboxes/connect-to-sandbox)

<!-- agent-signals: reading_time_min: 3 · est_tokens: 1861 · updated: 2026-07-30 -->
Related: [List sandboxes](/docs/api-reference/sandboxes/list-sandboxes.md), [Create sandbox](/docs/api-reference/sandboxes/create-sandbox.md), [List sandboxes (v2)](/docs/api-reference/sandboxes/list-sandboxes-v2.md), [List sandbox metrics](/docs/api-reference/sandboxes/list-sandbox-metrics.md), [Get sandbox logs](/docs/api-reference/sandboxes/get-sandbox-logs.md), [Get sandbox logs (v2)](/docs/api-reference/sandboxes/get-sandbox-logs-v2.md)

# Connect to sandbox

`POST /sandboxes/{sandboxID}/connect`

Returns sandbox details. If the sandbox is paused, it will be resumed. TTL is only extended.

## OpenAPI

```json
{
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "parameters": [
    {
      "name": "sandboxID",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "timeout"
          ],
          "properties": {
            "timeout": {
              "description": "Timeout in seconds from the current time after which the sandbox should expire",
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "The sandbox was already running",
      "content": {
        "application/json": {
          "schema": {
            "required": [
              "templateID",
              "sandboxID",
              "clientID",
              "envdVersion"
            ],
            "properties": {
              "templateID": {
                "type": "string",
                "description": "Identifier of the template from which is the sandbox created"
              },
              "sandboxID": {
                "type": "string",
                "description": "Identifier of the sandbox"
              },
              "alias": {
                "type": "string",
                "description": "Alias of the template"
              },
              "clientID": {
                "type": "string",
                "deprecated": true,
                "description": "Identifier of the client"
              },
              "envdVersion": {
                "type": "string",
                "description": "Version of the envd running in the sandbox"
              },
              "envdAccessToken": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Access token for authenticating envd requests to this sandbox. Only returned when the sandbox is created with `secure: true`. Null for non-secure sandboxes (envd endpoints work without auth)."
              },
              "trafficAccessToken": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Token required for accessing sandbox via proxy."
              },
              "domain": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Deprecated: always null. Construct sandbox URLs as `https://{port}-{sandboxID}.e2b.app`.",
                "deprecated": true
              }
            },
            "type": "object"
          }
        }
      }
    },
    "201": {
      "description": "The sandbox was resumed successfully",
      "content": {
        "application/json": {
          "schema": {
            "required": [
              "templateID",
              "sandboxID",
              "clientID",
              "envdVersion"
            ],
            "properties": {
              "templateID": {
                "type": "string",
                "description": "Identifier of the template from which is the sandbox created"
              },
              "sandboxID": {
                "type": "string",
                "description": "Identifier of the sandbox"
              },
              "alias": {
                "type": "string",
                "description": "Alias of the template"
              },
              "clientID": {
                "type": "string",
                "deprecated": true,
                "description": "Identifier of the client"
              },
              "envdVersion": {
                "type": "string",
                "description": "Version of the envd running in the sandbox"
              },
              "envdAccessToken": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Access token for authenticating envd requests to this sandbox. Only returned when the sandbox is created with `secure: true`. Null for non-secure sandboxes (envd endpoints work without auth)."
              },
              "trafficAccessToken": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Token required for accessing sandbox via proxy."
              },
              "domain": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Deprecated: always null. Construct sandbox URLs as `https://{port}-{sandboxID}.e2b.app`.",
                "deprecated": true
              }
            },
            "type": "object"
          }
        }
      }
    },
    "400": {
      "description": "Bad request",
      "content": {
        "application/json": {
          "schema": {
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer",
                "format": "int32",
                "description": "Error code"
              },
              "message": {
                "type": "string",
                "description": "Error"
              }
            },
            "type": "object"
          }
        }
      }
    },
    "401": {
      "description": "Authentication error",
      "content": {
        "application/json": {
          "schema": {
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer",
                "format": "int32",
                "description": "Error code"
              },
              "message": {
                "type": "string",
                "description": "Error"
              }
            },
            "type": "object"
          }
        }
      }
    },
    "404": {
      "description": "Not found",
      "content": {
        "application/json": {
          "schema": {
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer",
                "format": "int32",
                "description": "Error code"
              },
              "message": {
                "type": "string",
                "description": "Error"
              }
            },
            "type": "object"
          }
        }
      }
    },
    "500": {
      "description": "Server error",
      "content": {
        "application/json": {
          "schema": {
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer",
                "format": "int32",
                "description": "Error code"
              },
              "message": {
                "type": "string",
                "description": "Error"
              }
            },
            "type": "object"
          }
        }
      }
    }
  }
}
```
