> For the complete documentation index, see [llms.txt](https://docs.release.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.release.com/reference-documentation/release-api/ai-sandbox-api/sessions.md).

# Sessions

The Sessions API lets you manage sandbox sessions, their backing templates and classes, and the resources attached to each session. A session is a running sandbox environment provisioned from a template and class, with optional file, repository, and memory-store resources mounted into it.

To obtain your authentication credentials, [install the Release CLI](/cli/installation.md) and run `release auth login`. The CLI stores credentials in `~/.release.yaml`.

***

## Sandbox Classes

Sandbox classes define the compute shape (CPU, memory, GPU) available to a session.

### List Sandbox Classes

#### Endpoint

<mark style="color:green;">`GET`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_classes`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header | Value              |
| ------ | ------------------ |
| Accept | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Returns array of sandbox classes              |
| 401  | Unauthorized — invalid or missing credentials |

#### Response Body

Returns an array of sandbox class objects.

| Field       | Type              | Description                             |
| ----------- | ----------------- | --------------------------------------- |
| id          | string (hashid)   | Unique identifier for the sandbox class |
| name        | string            | Display name of the class               |
| created\_at | string (ISO 8601) | When the class was created              |
| updated\_at | string (ISO 8601) | When the class was last updated         |

#### Example Responses

**200 OK**

```json
[
  {
    "id": "xK9mP2",
    "name": "gpu-large",
    "created_at": "2026-05-01T12:00:00Z",
    "updated_at": "2026-05-01T12:00:00Z"
  }
]
```

**401 Unauthorized**

```json
{
  "errors": [
    {
      "code": "unauthorized",
      "message": "Invalid or missing authentication credentials"
    }
  ]
}
```

***

### Get Sandbox Class

#### Endpoint

<mark style="color:green;">`GET`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_classes/{id}`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header | Value              |
| ------ | ------------------ |
| Accept | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |
| id        | string (hashid) | Yes      | The sandbox class ID   |

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Returns the sandbox class                     |
| 401  | Unauthorized — invalid or missing credentials |
| 404  | Sandbox class not found                       |

#### Response Body

| Field       | Type              | Description                             |
| ----------- | ----------------- | --------------------------------------- |
| id          | string (hashid)   | Unique identifier for the sandbox class |
| name        | string            | Display name of the class               |
| created\_at | string (ISO 8601) | When the class was created              |
| updated\_at | string (ISO 8601) | When the class was last updated         |

#### Example Responses

**200 OK**

```json
{
  "id": "xK9mP2",
  "name": "gpu-large",
  "created_at": "2026-05-01T12:00:00Z",
  "updated_at": "2026-05-01T12:00:00Z"
}
```

**404 Not Found**

```json
{
  "errors": [
    {
      "code": "not_found",
      "message": "Sandbox class not found"
    }
  ]
}
```

***

## Sandbox Templates

Templates define the default configuration for a session, including which sandbox class to use and which resources to attach.

### List Sandbox Templates

#### Endpoint

<mark style="color:green;">`GET`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_templates`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header | Value              |
| ------ | ------------------ |
| Accept | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Returns array of sandbox templates            |
| 401  | Unauthorized — invalid or missing credentials |

#### Response Body

Returns an array of sandbox template objects.

| Field              | Type              | Description                             |
| ------------------ | ----------------- | --------------------------------------- |
| id                 | string (hashid)   | Unique identifier for the template      |
| name               | string            | Display name of the template            |
| sandbox\_class\_id | string (hashid)   | The sandbox class used by this template |
| created\_at        | string (ISO 8601) | When the template was created           |
| updated\_at        | string (ISO 8601) | When the template was last updated      |

#### Example Responses

**200 OK**

```json
[
  {
    "id": "tMp3Rq",
    "name": "default-workspace",
    "sandbox_class_id": "xK9mP2",
    "created_at": "2026-05-10T08:30:00Z",
    "updated_at": "2026-05-10T08:30:00Z"
  }
]
```

***

### Get Sandbox Template

#### Endpoint

<mark style="color:green;">`GET`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_templates/{id}`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header | Value              |
| ------ | ------------------ |
| Accept | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description             |
| --------- | --------------- | -------- | ----------------------- |
| accountId | string (hashid) | Yes      | The Release account ID  |
| id        | string (hashid) | Yes      | The sandbox template ID |

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Returns the sandbox template                  |
| 401  | Unauthorized — invalid or missing credentials |
| 404  | Template not found                            |

#### Response Body

| Field              | Type              | Description                             |
| ------------------ | ----------------- | --------------------------------------- |
| id                 | string (hashid)   | Unique identifier for the template      |
| name               | string            | Display name of the template            |
| sandbox\_class\_id | string (hashid)   | The sandbox class used by this template |
| created\_at        | string (ISO 8601) | When the template was created           |
| updated\_at        | string (ISO 8601) | When the template was last updated      |

#### Example Responses

**200 OK**

```json
{
  "id": "tMp3Rq",
  "name": "default-workspace",
  "sandbox_class_id": "xK9mP2",
  "created_at": "2026-05-10T08:30:00Z",
  "updated_at": "2026-05-10T08:30:00Z"
}
```

**404 Not Found**

```json
{
  "errors": [
    {
      "code": "not_found",
      "message": "Sandbox template not found"
    }
  ]
}
```

***

### Create Sandbox Template

#### Endpoint

<mark style="color:green;">`POST`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_templates`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header       | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| Accept       | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |

#### Request Body

| Field              | Type            | Required | Description                   |
| ------------------ | --------------- | -------- | ----------------------------- |
| name               | string          | Yes      | Display name for the template |
| sandbox\_class\_id | string (hashid) | Yes      | The sandbox class to use      |

**Example**

```json
{
  "name": "default-workspace",
  "sandbox_class_id": "xK9mP2"
}
```

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 201  | Template created                              |
| 401  | Unauthorized — invalid or missing credentials |
| 422  | Validation error                              |

#### Response Body

| Field              | Type              | Description                             |
| ------------------ | ----------------- | --------------------------------------- |
| id                 | string (hashid)   | Unique identifier for the template      |
| name               | string            | Display name of the template            |
| sandbox\_class\_id | string (hashid)   | The sandbox class used by this template |
| created\_at        | string (ISO 8601) | When the template was created           |
| updated\_at        | string (ISO 8601) | When the template was last updated      |

#### Example Responses

**201 Created**

```json
{
  "id": "tMp3Rq",
  "name": "default-workspace",
  "sandbox_class_id": "xK9mP2",
  "created_at": "2026-05-10T08:30:00Z",
  "updated_at": "2026-05-10T08:30:00Z"
}
```

**422 Unprocessable Entity**

```json
{
  "errors": [
    {
      "code": "validation_error",
      "message": "Name can't be blank"
    }
  ]
}
```

***

### Update Sandbox Template

#### Endpoint

<mark style="color:green;">`PATCH`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_templates/{id}`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header       | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| Accept       | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description             |
| --------- | --------------- | -------- | ----------------------- |
| accountId | string (hashid) | Yes      | The Release account ID  |
| id        | string (hashid) | Yes      | The sandbox template ID |

#### Request Body

| Field              | Type            | Required | Description           |
| ------------------ | --------------- | -------- | --------------------- |
| name               | string          | No       | Updated display name  |
| sandbox\_class\_id | string (hashid) | No       | Updated sandbox class |

**Example**

```json
{
  "name": "gpu-workspace"
}
```

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Template updated                              |
| 401  | Unauthorized — invalid or missing credentials |
| 404  | Template not found                            |
| 422  | Validation error                              |

#### Response Body

| Field              | Type              | Description                             |
| ------------------ | ----------------- | --------------------------------------- |
| id                 | string (hashid)   | Unique identifier for the template      |
| name               | string            | Display name of the template            |
| sandbox\_class\_id | string (hashid)   | The sandbox class used by this template |
| created\_at        | string (ISO 8601) | When the template was created           |
| updated\_at        | string (ISO 8601) | When the template was last updated      |

#### Example Responses

**200 OK**

```json
{
  "id": "tMp3Rq",
  "name": "gpu-workspace",
  "sandbox_class_id": "xK9mP2",
  "created_at": "2026-05-10T08:30:00Z",
  "updated_at": "2026-06-01T14:00:00Z"
}
```

***

### Delete Sandbox Template

#### Endpoint

<mark style="color:green;">`DELETE`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_templates/{id}`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Path Parameters

| Name      | Type            | Required | Description             |
| --------- | --------------- | -------- | ----------------------- |
| accountId | string (hashid) | Yes      | The Release account ID  |
| id        | string (hashid) | Yes      | The sandbox template ID |

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 204  | Template deleted (no content)                 |
| 401  | Unauthorized — invalid or missing credentials |
| 404  | Template not found                            |

#### Example Responses

**404 Not Found**

```json
{
  "errors": [
    {
      "code": "not_found",
      "message": "Sandbox template not found"
    }
  ]
}
```

***

## Sessions

Sessions represent running sandbox environments. Each session is provisioned from a template and progresses through a defined state lifecycle.

**State lifecycle:** `pending` -> `running` -> `suspended` -> `terminating` -> `terminated` | `errored`

### List Sessions

#### Endpoint

<mark style="color:green;">`GET`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_sessions`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header | Value              |
| ------ | ------------------ |
| Accept | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Returns array of sessions                     |
| 401  | Unauthorized — invalid or missing credentials |

#### Response Body

Returns an array of session objects. See [session fields](#session-response-fields) below.

#### Example Responses

**200 OK**

```json
[
  {
    "id": "sN4kL7",
    "title": "dev-session-1",
    "state": "running",
    "sandbox_template_id": "tMp3Rq",
    "environment_id": null,
    "sandbox_claim_name": "sandbox-sn4kl7",
    "metadata": {},
    "started_at": "2026-06-01T10:05:00Z",
    "completed_at": null,
    "created_at": "2026-06-01T10:00:00Z",
    "updated_at": "2026-06-01T10:05:00Z",
    "resources": []
  }
]
```

***

### Create Session

#### Endpoint

<mark style="color:green;">`POST`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_sessions`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header       | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| Accept       | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |

#### Request Body

| Field                 | Type            | Required | Description                                                 |
| --------------------- | --------------- | -------- | ----------------------------------------------------------- |
| sandbox\_template\_id | string (hashid) | Yes      | The template to provision from                              |
| title                 | string          | No       | Human-readable session name                                 |
| cluster\_id           | string (hashid) | No       | Target cluster for the session                              |
| environment\_id       | string (hashid) | No       | Bind to a Release environment                               |
| metadata              | object          | No       | Arbitrary key-value metadata                                |
| resources             | array           | No       | Resources to attach (see [Resource Types](#resource-types)) |

**Example**

```json
{
  "sandbox_template_id": "tMp3Rq",
  "title": "feature-branch-test",
  "metadata": {
    "team": "backend"
  },
  "resources": [
    {
      "resource_type": "github_repository",
      "config": {
        "repo_url": "https://github.com/acme/api-server",
        "checkout": {
          "type": "branch",
          "value": "main"
        }
      },
      "mount_path": "/mnt/session/repos/api-server"
    }
  ]
}
```

#### Status Codes

| Code | Description                                                                 |
| ---- | --------------------------------------------------------------------------- |
| 201  | Session created                                                             |
| 401  | Unauthorized — invalid or missing credentials                               |
| 422  | Validation error (invalid template, environment, or resource configuration) |

#### Response Body

See [session fields](#session-response-fields) below.

#### Example Responses

**201 Created**

```json
{
  "id": "sN4kL7",
  "title": "feature-branch-test",
  "state": "pending",
  "sandbox_template_id": "tMp3Rq",
  "environment_id": null,
  "sandbox_claim_name": "sandbox-sn4kl7",
  "metadata": {
    "team": "backend"
  },
  "started_at": null,
  "completed_at": null,
  "created_at": "2026-06-01T10:00:00Z",
  "updated_at": "2026-06-01T10:00:00Z",
  "resources": [
    {
      "id": "rC8wQ1",
      "resource_type": "github_repository",
      "state": "pending",
      "mount_path": "/mnt/session/repos/api-server",
      "config": {
        "repo_url": "https://github.com/acme/api-server",
        "checkout": {
          "type": "branch",
          "value": "main"
        }
      },
      "status": {}
    }
  ]
}
```

**422 Unprocessable Entity**

```json
{
  "errors": [
    {
      "code": "validation_error",
      "message": "environment_id does not belong to this account"
    }
  ]
}
```

***

### Get Session

#### Endpoint

<mark style="color:green;">`GET`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_sessions/{id}`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header | Value              |
| ------ | ------------------ |
| Accept | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |
| id        | string (hashid) | Yes      | The session ID         |

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Returns the session                           |
| 401  | Unauthorized — invalid or missing credentials |
| 404  | Session not found                             |

#### Response Body

| Field                 | Type                      | Description                                                                       |
| --------------------- | ------------------------- | --------------------------------------------------------------------------------- |
| id                    | string (hashid)           | Unique identifier for the session                                                 |
| title                 | string or null            | Human-readable session name                                                       |
| state                 | string                    | One of: `pending`, `running`, `suspended`, `terminating`, `terminated`, `errored` |
| sandbox\_template\_id | string (hashid)           | The template this session was created from                                        |
| environment\_id       | string (hashid) or null   | Bound Release environment, if any                                                 |
| sandbox\_claim\_name  | string                    | Internal claim name for the sandbox                                               |
| metadata              | object                    | Arbitrary key-value metadata                                                      |
| started\_at           | string (ISO 8601) or null | When the session began running                                                    |
| completed\_at         | string (ISO 8601) or null | When the session finished                                                         |
| created\_at           | string (ISO 8601)         | When the session was created                                                      |
| updated\_at           | string (ISO 8601)         | When the session was last updated                                                 |
| resources             | array                     | List of attached resource objects (see [Resource Types](#resource-types))         |

#### Example Responses

**200 OK**

```json
{
  "id": "sN4kL7",
  "title": "feature-branch-test",
  "state": "running",
  "sandbox_template_id": "tMp3Rq",
  "environment_id": null,
  "sandbox_claim_name": "sandbox-sn4kl7",
  "metadata": {
    "team": "backend"
  },
  "started_at": "2026-06-01T10:05:00Z",
  "completed_at": null,
  "created_at": "2026-06-01T10:00:00Z",
  "updated_at": "2026-06-01T10:05:00Z",
  "resources": [
    {
      "id": "rC8wQ1",
      "resource_type": "github_repository",
      "state": "ready",
      "mount_path": "/mnt/session/repos/api-server",
      "config": {
        "repo_url": "https://github.com/acme/api-server",
        "checkout": {
          "type": "branch",
          "value": "main"
        }
      },
      "status": {}
    }
  ]
}
```

**404 Not Found**

```json
{
  "errors": [
    {
      "code": "not_found",
      "message": "Session not found"
    }
  ]
}
```

***

### Update Session

Updates a session's mutable fields. Which fields can be updated depends on the current session state.

**State-based edit rules:**

| Session State                | Allowed Fields                                     |
| ---------------------------- | -------------------------------------------------- |
| pending, creating, suspended | `title`, `metadata`, `environment_id`, `resources` |
| running                      | `title`, `metadata`                                |
| terminated, errored          | None (read-only, returns 422)                      |

#### Endpoint

<mark style="color:green;">`PATCH`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_sessions/{id}`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header       | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| Accept       | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |
| id        | string (hashid) | Yes      | The session ID         |

#### Request Body

| Field           | Type            | Required | Description                                            |
| --------------- | --------------- | -------- | ------------------------------------------------------ |
| title           | string          | No       | Updated session name                                   |
| metadata        | object          | No       | Updated metadata                                       |
| environment\_id | string (hashid) | No       | Updated environment binding (not allowed when running) |

**Example**

```json
{
  "title": "renamed-session",
  "metadata": {
    "team": "backend",
    "priority": "high"
  }
}
```

#### Status Codes

| Code | Description                                                    |
| ---- | -------------------------------------------------------------- |
| 200  | Session updated                                                |
| 401  | Unauthorized — invalid or missing credentials                  |
| 404  | Session not found                                              |
| 422  | State conflict — session cannot be edited in its current state |

#### Response Body

Returns the updated session object. See [session fields](#session-response-fields).

#### Example Responses

**200 OK**

```json
{
  "id": "sN4kL7",
  "title": "renamed-session",
  "state": "running",
  "sandbox_template_id": "tMp3Rq",
  "environment_id": null,
  "sandbox_claim_name": "sandbox-sn4kl7",
  "metadata": {
    "team": "backend",
    "priority": "high"
  },
  "started_at": "2026-06-01T10:05:00Z",
  "completed_at": null,
  "created_at": "2026-06-01T10:00:00Z",
  "updated_at": "2026-06-01T14:30:00Z",
  "resources": []
}
```

**422 Session State Conflict**

```json
{
  "errors": [
    {
      "code": "session_state_conflict",
      "message": "Cannot edit a terminated session",
      "current_state": "terminated",
      "allowed_fields": []
    }
  ]
}
```

***

### Suspend Session

Suspends a running session, preserving its state for later resumption.

#### Endpoint

<mark style="color:green;">`POST`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_sessions/{id}/suspend`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |
| id        | string (hashid) | Yes      | The session ID         |

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Session suspended                             |
| 401  | Unauthorized — invalid or missing credentials |
| 404  | Session not found                             |
| 422  | Invalid state transition                      |

#### Response Body

Returns the updated session object. See [session fields](#session-response-fields).

#### Example Responses

**200 OK**

```json
{
  "id": "sN4kL7",
  "title": "feature-branch-test",
  "state": "suspended",
  "sandbox_template_id": "tMp3Rq",
  "environment_id": null,
  "sandbox_claim_name": "sandbox-sn4kl7",
  "metadata": {},
  "started_at": "2026-06-01T10:05:00Z",
  "completed_at": null,
  "created_at": "2026-06-01T10:00:00Z",
  "updated_at": "2026-06-01T15:00:00Z",
  "resources": []
}
```

***

### Resume Session

Resumes a previously suspended session.

#### Endpoint

<mark style="color:green;">`POST`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_sessions/{id}/resume`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |
| id        | string (hashid) | Yes      | The session ID         |

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Session resumed                               |
| 401  | Unauthorized — invalid or missing credentials |
| 404  | Session not found                             |
| 422  | Invalid state transition                      |

#### Response Body

Returns the updated session object. See [session fields](#session-response-fields).

#### Example Responses

**200 OK**

```json
{
  "id": "sN4kL7",
  "title": "feature-branch-test",
  "state": "running",
  "sandbox_template_id": "tMp3Rq",
  "environment_id": null,
  "sandbox_claim_name": "sandbox-sn4kl7",
  "metadata": {},
  "started_at": "2026-06-01T10:05:00Z",
  "completed_at": null,
  "created_at": "2026-06-01T10:00:00Z",
  "updated_at": "2026-06-01T16:00:00Z",
  "resources": []
}
```

***

### Terminate Session

Permanently terminates a session. This action cannot be undone.

#### Endpoint

<mark style="color:green;">`POST`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_sessions/{id}/terminate`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |
| id        | string (hashid) | Yes      | The session ID         |

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Session terminating                           |
| 401  | Unauthorized — invalid or missing credentials |
| 404  | Session not found                             |
| 422  | Invalid state transition                      |

#### Response Body

Returns the updated session object. See [session fields](#session-response-fields).

#### Example Responses

**200 OK**

```json
{
  "id": "sN4kL7",
  "title": "feature-branch-test",
  "state": "terminating",
  "sandbox_template_id": "tMp3Rq",
  "environment_id": null,
  "sandbox_claim_name": "sandbox-sn4kl7",
  "metadata": {},
  "started_at": "2026-06-01T10:05:00Z",
  "completed_at": null,
  "created_at": "2026-06-01T10:00:00Z",
  "updated_at": "2026-06-01T18:00:00Z",
  "resources": []
}
```

***

## Session Resources

Resources are files, repositories, or memory stores mounted into a session. Resources can only be added, updated, or removed when the session is in `pending`, `creating`, or `suspended` state. Attempting to modify resources in any other state returns a 422 `session_state_conflict` error.

**Resource state lifecycle:** `pending` -> `cloning` -> `ready` | `failed`

### Resource Types

Each resource has a `resource_type` that determines which fields are available in its `config` object.

#### github\_repository

| Field          | Type   | Required | Description                                                  |
| -------------- | ------ | -------- | ------------------------------------------------------------ |
| repo\_url      | string | Yes      | GitHub repository URL                                        |
| auth\_mode     | string | No       | One of: `github_app`, `github_token`. Default: `github_app`  |
| token          | string | No       | Required when `auth_mode` is `github_token`. Never persisted |
| checkout       | object | No       | `{"type": "branch\|tag\|commit\|none", "value": "main"}`     |
| branch         | string | No       | Legacy checkout field (backward compatible)                  |
| repo\_name     | string | No       | Directory name for the cloned repository                     |
| repository\_id | string | No       | Platform repository ID                                       |
| mount\_path    | string | No       | Mount location, e.g. `/mnt/session/repos/repo-name`          |

#### file

| Field         | Type    | Required | Description                                                         |
| ------------- | ------- | -------- | ------------------------------------------------------------------- |
| s3\_uri       | string  | Yes      | S3 URI (`s3://bucket/path`), must belong to account's upload prefix |
| filename      | string  | Yes      | Name of the file                                                    |
| content\_type | string  | Yes      | MIME type of the file                                               |
| size\_bytes   | integer | Yes      | File size in bytes (max 100 MB)                                     |
| checksum      | string  | No       | File checksum for integrity verification                            |
| mount\_path   | string  | Yes      | Mount location within the session                                   |

#### memory\_store

| Field             | Type            | Required | Description                       |
| ----------------- | --------------- | -------- | --------------------------------- |
| memory\_store\_id | string (hashid) | Yes      | ID of the memory store to attach  |
| namespace         | string          | No       | Namespace within the memory store |
| mode              | string          | No       | One of: `read_write`, `read_only` |
| mount\_path       | string          | Yes      | Mount location within the session |

### Validations

* All mount paths must start with `/mnt/session`
* File resources have a maximum size of 100 MB
* S3 URIs must start with `s3://` and belong to the account's upload prefix
* When using `github_token` auth mode, a `token` must be provided and the `repo_url` must be an HTTPS github.com URL
* `environment_id` must belong to the same account (returns 422 if not found)

***

### Add Resource to Session

#### Endpoint

<mark style="color:green;">`POST`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_sessions/{id}/resources`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header       | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| Accept       | `application/json` |

#### Path Parameters

| Name      | Type            | Required | Description            |
| --------- | --------------- | -------- | ---------------------- |
| accountId | string (hashid) | Yes      | The Release account ID |
| id        | string (hashid) | Yes      | The session ID         |

#### Request Body

| Field          | Type   | Required | Description                                                         |
| -------------- | ------ | -------- | ------------------------------------------------------------------- |
| resource\_type | string | Yes      | One of: `github_repository`, `file`, `memory_store`                 |
| mount\_path    | string | Yes      | Mount location (must start with `/mnt/session`)                     |
| config         | object | Yes      | Type-specific configuration (see [Resource Types](#resource-types)) |

**Example — GitHub repository**

```json
{
  "resource_type": "github_repository",
  "mount_path": "/mnt/session/repos/frontend",
  "config": {
    "repo_url": "https://github.com/acme/frontend",
    "checkout": {
      "type": "branch",
      "value": "develop"
    }
  }
}
```

**Example — File**

```json
{
  "resource_type": "file",
  "mount_path": "/mnt/session/data/dataset.csv",
  "config": {
    "s3_uri": "s3://release-uploads/acme/dataset.csv",
    "filename": "dataset.csv",
    "content_type": "text/csv",
    "size_bytes": 1048576
  }
}
```

**Example — Memory store**

```json
{
  "resource_type": "memory_store",
  "mount_path": "/mnt/session/memory/main",
  "config": {
    "memory_store_id": "mS5tR9",
    "mode": "read_write"
  }
}
```

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 201  | Resource added                                |
| 401  | Unauthorized — invalid or missing credentials |
| 404  | Session not found                             |
| 422  | Validation error or session state conflict    |

#### Response Body

| Field          | Type            | Description                                         |
| -------------- | --------------- | --------------------------------------------------- |
| id             | string (hashid) | Unique identifier for the resource                  |
| resource\_type | string          | One of: `github_repository`, `file`, `memory_store` |
| state          | string          | One of: `pending`, `cloning`, `ready`, `failed`     |
| mount\_path    | string          | Mount location within the session                   |
| config         | object          | Type-specific configuration                         |
| status         | object          | Current status information                          |

#### Example Responses

**201 Created**

```json
{
  "id": "rC8wQ1",
  "resource_type": "github_repository",
  "state": "pending",
  "mount_path": "/mnt/session/repos/frontend",
  "config": {
    "repo_url": "https://github.com/acme/frontend",
    "checkout": {
      "type": "branch",
      "value": "develop"
    }
  },
  "status": {}
}
```

**422 Session State Conflict**

```json
{
  "errors": [
    {
      "code": "session_state_conflict",
      "message": "Cannot modify resources for a running session",
      "current_state": "running",
      "allowed_fields": []
    }
  ]
}
```

***

### Update Resource

#### Endpoint

<mark style="color:green;">`PATCH`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_sessions/{id}/resources/{resourceId}`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Headers

| Header       | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| Accept       | `application/json` |

#### Path Parameters

| Name       | Type            | Required | Description            |
| ---------- | --------------- | -------- | ---------------------- |
| accountId  | string (hashid) | Yes      | The Release account ID |
| id         | string (hashid) | Yes      | The session ID         |
| resourceId | string (hashid) | Yes      | The resource ID        |

#### Request Body

| Field       | Type   | Required | Description                                                          |
| ----------- | ------ | -------- | -------------------------------------------------------------------- |
| mount\_path | string | No       | Updated mount path (must start with `/mnt/session`)                  |
| branch      | string | No       | Updated branch (github\_repository only)                             |
| namespace   | string | No       | Updated namespace (memory\_store only)                               |
| mode        | string | No       | Updated mode (memory\_store only). One of: `read_write`, `read_only` |

**Example**

```json
{
  "mount_path": "/mnt/session/repos/frontend-v2",
  "branch": "release/v2"
}
```

#### Status Codes

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Resource updated                              |
| 401  | Unauthorized — invalid or missing credentials |
| 404  | Session or resource not found                 |
| 422  | Validation error or session state conflict    |

#### Response Body

| Field          | Type            | Description                                         |
| -------------- | --------------- | --------------------------------------------------- |
| id             | string (hashid) | Unique identifier for the resource                  |
| resource\_type | string          | One of: `github_repository`, `file`, `memory_store` |
| state          | string          | One of: `pending`, `cloning`, `ready`, `failed`     |
| mount\_path    | string          | Mount location within the session                   |
| config         | object          | Type-specific configuration                         |
| status         | object          | Current status information                          |

#### Example Responses

**200 OK**

```json
{
  "id": "rC8wQ1",
  "resource_type": "github_repository",
  "state": "pending",
  "mount_path": "/mnt/session/repos/frontend-v2",
  "config": {
    "repo_url": "https://github.com/acme/frontend",
    "checkout": {
      "type": "branch",
      "value": "release/v2"
    }
  },
  "status": {}
}
```

***

### Remove Resource

#### Endpoint

<mark style="color:green;">`DELETE`</mark> `https://backend-{handle}-envs.gcp.release.com/ai/accounts/{accountId}/sandbox_sessions/{id}/resources/{resourceId}`

#### Authentication

| Header       | Type   | Description                                      |
| ------------ | ------ | ------------------------------------------------ |
| X-User-Email | string | Email associated with your Release account       |
| X-User-Token | string | User authentication token from `~/.release.yaml` |

#### Path Parameters

| Name       | Type            | Required | Description            |
| ---------- | --------------- | -------- | ---------------------- |
| accountId  | string (hashid) | Yes      | The Release account ID |
| id         | string (hashid) | Yes      | The session ID         |
| resourceId | string (hashid) | Yes      | The resource ID        |

#### Status Codes

| Code | Description                                                            |
| ---- | ---------------------------------------------------------------------- |
| 204  | Resource removed (no content)                                          |
| 401  | Unauthorized — invalid or missing credentials                          |
| 404  | Session or resource not found                                          |
| 422  | Session state conflict — resources cannot be modified in current state |

#### Example Responses

**422 Session State Conflict**

```json
{
  "errors": [
    {
      "code": "session_state_conflict",
      "message": "Cannot modify resources for a running session",
      "current_state": "running",
      "allowed_fields": []
    }
  ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.release.com/reference-documentation/release-api/ai-sandbox-api/sessions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
