# Sandbox API reference

Source: `@socra/sandbox-api@0.0.4` (SandboxContract).

Project-scoped durable environments and isolated compute sessions.

## API surface

Base URL: `https://sandbox.socra.cloud`

## Sandboxes

A durable project-scoped environment with replaceable isolated Sessions.

### Resource schema

- `id` custom, required
- `project_id` custom, required
- `image` string, required
- `command` string[] | null, required
- `persistent` boolean, required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `storage_size_gib` integer | null, required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `active_session_id` custom | null, required
- `latest_snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "image": {
      "type": "string"
    },
    "command": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "persistent": {
      "type": "boolean"
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "storage_size_gib": {
      "anyOf": [
        {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "active_session_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "latest_snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "image",
    "command",
    "persistent",
    "timeout_seconds",
    "storage_size_gib",
    "status",
    "active_session_id",
    "latest_snapshot_id",
    "error",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Create sandbox

`POST /v1/sandboxes`

#### Request body

- `project_id` custom, required
- `image` string (min length: 1), required
- `command` string[] (min items: 1), optional
- `persistent` boolean (default: true), optional
- `timeout_seconds` integer (default: 3600; min: 60; max: 86400), optional
- `storage_size_gib` integer (default: 20; min: 1; max: 16384), optional
- `start` boolean (default: true), optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "project_id": {},
    "image": {
      "type": "string",
      "minLength": 1
    },
    "command": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "persistent": {
      "default": true,
      "type": "boolean"
    },
    "timeout_seconds": {
      "default": 3600,
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "storage_size_gib": {
      "default": 20,
      "type": "integer",
      "minimum": 1,
      "maximum": 16384
    },
    "start": {
      "default": true,
      "type": "boolean"
    }
  },
  "required": [
    "project_id",
    "image"
  ]
}
```

#### Response

- `id` custom, required
- `project_id` custom, required
- `image` string, required
- `command` string[] | null, required
- `persistent` boolean, required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `storage_size_gib` integer | null, required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `active_session_id` custom | null, required
- `latest_snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "image": {
      "type": "string"
    },
    "command": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "persistent": {
      "type": "boolean"
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "storage_size_gib": {
      "anyOf": [
        {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "active_session_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "latest_snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "image",
    "command",
    "persistent",
    "timeout_seconds",
    "storage_size_gib",
    "status",
    "active_session_id",
    "latest_snapshot_id",
    "error",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### List sandboxes

`GET /v1/sandboxes`

#### Query parameters

- `limit` integer (min: 1; max: 100), optional
- `after` string, optional
- `project_id` custom, required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "after": {
      "type": "string"
    },
    "project_id": {},
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    }
  },
  "required": [
    "project_id"
  ]
}
```

#### Response

- `data` object[], required
  - `id` custom, required
  - `project_id` custom, required
  - `image` string, required
  - `command` string[] | null, required
  - `persistent` boolean, required
  - `timeout_seconds` integer (min: 60; max: 86400), required
  - `storage_size_gib` integer | null, required
  - `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
  - `active_session_id` custom | null, required
  - `latest_snapshot_id` custom | null, required
  - `error` string | null, required
  - `created_at` custom, required
  - `updated_at` custom, required
- `has_more` boolean, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {},
          "project_id": {},
          "image": {
            "type": "string"
          },
          "command": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "persistent": {
            "type": "boolean"
          },
          "timeout_seconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400
          },
          "storage_size_gib": {
            "anyOf": [
              {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "starting",
              "running",
              "stopping",
              "stopped",
              "failed"
            ]
          },
          "active_session_id": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ]
          },
          "latest_snapshot_id": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ]
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {},
          "updated_at": {}
        },
        "required": [
          "id",
          "project_id",
          "image",
          "command",
          "persistent",
          "timeout_seconds",
          "storage_size_gib",
          "status",
          "active_session_id",
          "latest_snapshot_id",
          "error",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false
      }
    },
    "has_more": {
      "type": "boolean"
    }
  },
  "required": [
    "data",
    "has_more"
  ],
  "additionalProperties": false
}
```

### Get sandbox

`GET /v1/sandboxes/{id}`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

- `id` custom, required
- `project_id` custom, required
- `image` string, required
- `command` string[] | null, required
- `persistent` boolean, required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `storage_size_gib` integer | null, required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `active_session_id` custom | null, required
- `latest_snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "image": {
      "type": "string"
    },
    "command": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "persistent": {
      "type": "boolean"
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "storage_size_gib": {
      "anyOf": [
        {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "active_session_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "latest_snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "image",
    "command",
    "persistent",
    "timeout_seconds",
    "storage_size_gib",
    "status",
    "active_session_id",
    "latest_snapshot_id",
    "error",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Update sandbox

`PATCH /v1/sandboxes/{id}`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Request body

- `timeout_seconds` integer (min: 60; max: 86400), optional
- `image` string (min length: 1), optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "image": {
      "type": "string",
      "minLength": 1
    }
  }
}
```

#### Response

- `id` custom, required
- `project_id` custom, required
- `image` string, required
- `command` string[] | null, required
- `persistent` boolean, required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `storage_size_gib` integer | null, required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `active_session_id` custom | null, required
- `latest_snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "image": {
      "type": "string"
    },
    "command": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "persistent": {
      "type": "boolean"
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "storage_size_gib": {
      "anyOf": [
        {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "active_session_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "latest_snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "image",
    "command",
    "persistent",
    "timeout_seconds",
    "storage_size_gib",
    "status",
    "active_session_id",
    "latest_snapshot_id",
    "error",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Start sandbox

`POST /v1/sandboxes/{id}/start`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

- `id` custom, required
- `project_id` custom, required
- `image` string, required
- `command` string[] | null, required
- `persistent` boolean, required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `storage_size_gib` integer | null, required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `active_session_id` custom | null, required
- `latest_snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "image": {
      "type": "string"
    },
    "command": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "persistent": {
      "type": "boolean"
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "storage_size_gib": {
      "anyOf": [
        {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "active_session_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "latest_snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "image",
    "command",
    "persistent",
    "timeout_seconds",
    "storage_size_gib",
    "status",
    "active_session_id",
    "latest_snapshot_id",
    "error",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Stop sandbox

`POST /v1/sandboxes/{id}/stop`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

- `id` custom, required
- `project_id` custom, required
- `image` string, required
- `command` string[] | null, required
- `persistent` boolean, required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `storage_size_gib` integer | null, required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `active_session_id` custom | null, required
- `latest_snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "image": {
      "type": "string"
    },
    "command": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "persistent": {
      "type": "boolean"
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "storage_size_gib": {
      "anyOf": [
        {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "active_session_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "latest_snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "image",
    "command",
    "persistent",
    "timeout_seconds",
    "storage_size_gib",
    "status",
    "active_session_id",
    "latest_snapshot_id",
    "error",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Restart sandbox

`POST /v1/sandboxes/{id}/restart`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

- `id` custom, required
- `project_id` custom, required
- `image` string, required
- `command` string[] | null, required
- `persistent` boolean, required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `storage_size_gib` integer | null, required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `active_session_id` custom | null, required
- `latest_snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "image": {
      "type": "string"
    },
    "command": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "persistent": {
      "type": "boolean"
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "storage_size_gib": {
      "anyOf": [
        {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "active_session_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "latest_snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "image",
    "command",
    "persistent",
    "timeout_seconds",
    "storage_size_gib",
    "status",
    "active_session_id",
    "latest_snapshot_id",
    "error",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Execute command in sandbox

`POST /v1/sandboxes/{id}/exec`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Request body

- `command` string[] (min items: 1), required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "command": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "command"
  ]
}
```

#### Response

- `session_id` custom, required
- `resumed` boolean, required
- `exit_code` integer (min: -9007199254740991; max: 9007199254740991), required
- `stdout` string, required
- `stderr` string, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "session_id": {},
    "resumed": {
      "type": "boolean"
    },
    "exit_code": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "stdout": {
      "type": "string"
    },
    "stderr": {
      "type": "string"
    }
  },
  "required": [
    "session_id",
    "resumed",
    "exit_code",
    "stdout",
    "stderr"
  ],
  "additionalProperties": false
}
```

### Delete sandbox

`DELETE /v1/sandboxes/{id}`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

No response body.

## Sessions

One observable Kata microVM incarnation of a Sandbox.

### Resource schema

- `id` custom, required
- `sandbox_id` custom, required
- `project_id` custom, required
- `number` integer (greater than: 0; max: 9007199254740991), required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `expires_at` custom, required
- `stop_reason` "requested" | "timeout" | "restart" | "failure" | "replaced" | null, required
- `snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required
- `started_at` custom | null, required
- `stopped_at` custom | null, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "sandbox_id": {},
    "project_id": {},
    "number": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "expires_at": {},
    "stop_reason": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "requested",
            "timeout",
            "restart",
            "failure",
            "replaced"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {},
    "started_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "stopped_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "id",
    "sandbox_id",
    "project_id",
    "number",
    "status",
    "timeout_seconds",
    "expires_at",
    "stop_reason",
    "snapshot_id",
    "error",
    "created_at",
    "updated_at",
    "started_at",
    "stopped_at"
  ],
  "additionalProperties": false
}
```

### Create session

`POST /v1/sessions`

#### Request body

- `sandbox_id` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "sandbox_id": {}
  },
  "required": [
    "sandbox_id"
  ]
}
```

#### Response

- `id` custom, required
- `sandbox_id` custom, required
- `project_id` custom, required
- `number` integer (greater than: 0; max: 9007199254740991), required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `expires_at` custom, required
- `stop_reason` "requested" | "timeout" | "restart" | "failure" | "replaced" | null, required
- `snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required
- `started_at` custom | null, required
- `stopped_at` custom | null, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "sandbox_id": {},
    "project_id": {},
    "number": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "expires_at": {},
    "stop_reason": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "requested",
            "timeout",
            "restart",
            "failure",
            "replaced"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {},
    "started_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "stopped_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "id",
    "sandbox_id",
    "project_id",
    "number",
    "status",
    "timeout_seconds",
    "expires_at",
    "stop_reason",
    "snapshot_id",
    "error",
    "created_at",
    "updated_at",
    "started_at",
    "stopped_at"
  ],
  "additionalProperties": false
}
```

### List sessions

`GET /v1/sessions`

#### Query parameters

- `limit` integer (min: 1; max: 100), optional
- `after` string, optional
- `project_id` custom, required
- `sandbox_id` custom, optional
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "after": {
      "type": "string"
    },
    "project_id": {},
    "sandbox_id": {},
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    }
  },
  "required": [
    "project_id"
  ]
}
```

#### Response

- `data` object[], required
  - `id` custom, required
  - `sandbox_id` custom, required
  - `project_id` custom, required
  - `number` integer (greater than: 0; max: 9007199254740991), required
  - `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
  - `timeout_seconds` integer (min: 60; max: 86400), required
  - `expires_at` custom, required
  - `stop_reason` "requested" | "timeout" | "restart" | "failure" | "replaced" | null, required
  - `snapshot_id` custom | null, required
  - `error` string | null, required
  - `created_at` custom, required
  - `updated_at` custom, required
  - `started_at` custom | null, required
  - `stopped_at` custom | null, required
- `has_more` boolean, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {},
          "sandbox_id": {},
          "project_id": {},
          "number": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "status": {
            "type": "string",
            "enum": [
              "starting",
              "running",
              "stopping",
              "stopped",
              "failed"
            ]
          },
          "timeout_seconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400
          },
          "expires_at": {},
          "stop_reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "requested",
                  "timeout",
                  "restart",
                  "failure",
                  "replaced"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "snapshot_id": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ]
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {},
          "updated_at": {},
          "started_at": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ]
          },
          "stopped_at": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "sandbox_id",
          "project_id",
          "number",
          "status",
          "timeout_seconds",
          "expires_at",
          "stop_reason",
          "snapshot_id",
          "error",
          "created_at",
          "updated_at",
          "started_at",
          "stopped_at"
        ],
        "additionalProperties": false
      }
    },
    "has_more": {
      "type": "boolean"
    }
  },
  "required": [
    "data",
    "has_more"
  ],
  "additionalProperties": false
}
```

### Get session

`GET /v1/sessions/{id}`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

- `id` custom, required
- `sandbox_id` custom, required
- `project_id` custom, required
- `number` integer (greater than: 0; max: 9007199254740991), required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `expires_at` custom, required
- `stop_reason` "requested" | "timeout" | "restart" | "failure" | "replaced" | null, required
- `snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required
- `started_at` custom | null, required
- `stopped_at` custom | null, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "sandbox_id": {},
    "project_id": {},
    "number": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "expires_at": {},
    "stop_reason": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "requested",
            "timeout",
            "restart",
            "failure",
            "replaced"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {},
    "started_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "stopped_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "id",
    "sandbox_id",
    "project_id",
    "number",
    "status",
    "timeout_seconds",
    "expires_at",
    "stop_reason",
    "snapshot_id",
    "error",
    "created_at",
    "updated_at",
    "started_at",
    "stopped_at"
  ],
  "additionalProperties": false
}
```

### Update session timeout

`PATCH /v1/sessions/{id}`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Request body

- `timeout_seconds` integer (min: 60; max: 86400), required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    }
  },
  "required": [
    "timeout_seconds"
  ]
}
```

#### Response

- `id` custom, required
- `sandbox_id` custom, required
- `project_id` custom, required
- `number` integer (greater than: 0; max: 9007199254740991), required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `expires_at` custom, required
- `stop_reason` "requested" | "timeout" | "restart" | "failure" | "replaced" | null, required
- `snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required
- `started_at` custom | null, required
- `stopped_at` custom | null, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "sandbox_id": {},
    "project_id": {},
    "number": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "expires_at": {},
    "stop_reason": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "requested",
            "timeout",
            "restart",
            "failure",
            "replaced"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {},
    "started_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "stopped_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "id",
    "sandbox_id",
    "project_id",
    "number",
    "status",
    "timeout_seconds",
    "expires_at",
    "stop_reason",
    "snapshot_id",
    "error",
    "created_at",
    "updated_at",
    "started_at",
    "stopped_at"
  ],
  "additionalProperties": false
}
```

### Stop session

`POST /v1/sessions/{id}/stop`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

- `id` custom, required
- `sandbox_id` custom, required
- `project_id` custom, required
- `number` integer (greater than: 0; max: 9007199254740991), required
- `status` "starting" | "running" | "stopping" | "stopped" | "failed", required
- `timeout_seconds` integer (min: 60; max: 86400), required
- `expires_at` custom, required
- `stop_reason` "requested" | "timeout" | "restart" | "failure" | "replaced" | null, required
- `snapshot_id` custom | null, required
- `error` string | null, required
- `created_at` custom, required
- `updated_at` custom, required
- `started_at` custom | null, required
- `stopped_at` custom | null, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "sandbox_id": {},
    "project_id": {},
    "number": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "status": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopping",
        "stopped",
        "failed"
      ]
    },
    "timeout_seconds": {
      "type": "integer",
      "minimum": 60,
      "maximum": 86400
    },
    "expires_at": {},
    "stop_reason": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "requested",
            "timeout",
            "restart",
            "failure",
            "replaced"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "snapshot_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {},
    "updated_at": {},
    "started_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "stopped_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "id",
    "sandbox_id",
    "project_id",
    "number",
    "status",
    "timeout_seconds",
    "expires_at",
    "stop_reason",
    "snapshot_id",
    "error",
    "created_at",
    "updated_at",
    "started_at",
    "stopped_at"
  ],
  "additionalProperties": false
}
```

### Execute command in session

`POST /v1/sessions/{id}/exec`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Request body

- `command` string[] (min items: 1), required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "command": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "command"
  ]
}
```

#### Response

- `session_id` custom, required
- `resumed` boolean, required
- `exit_code` integer (min: -9007199254740991; max: 9007199254740991), required
- `stdout` string, required
- `stderr` string, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "session_id": {},
    "resumed": {
      "type": "boolean"
    },
    "exit_code": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "stdout": {
      "type": "string"
    },
    "stderr": {
      "type": "string"
    }
  },
  "required": [
    "session_id",
    "resumed",
    "exit_code",
    "stdout",
    "stderr"
  ],
  "additionalProperties": false
}
```

## Snapshots

An immutable checkpoint of a persistent Sandbox home.

### Resource schema

- `id` custom, required
- `sandbox_id` custom, required
- `session_id` custom | null, required
- `project_id` custom, required
- `status` "creating" | "ready" | "failed", required
- `volume_snapshot_name` string, required
- `ready_at` custom | null, required
- `error` string | null, required
- `created_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "sandbox_id": {},
    "session_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "project_id": {},
    "status": {
      "type": "string",
      "enum": [
        "creating",
        "ready",
        "failed"
      ]
    },
    "volume_snapshot_name": {
      "type": "string"
    },
    "ready_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {}
  },
  "required": [
    "id",
    "sandbox_id",
    "session_id",
    "project_id",
    "status",
    "volume_snapshot_name",
    "ready_at",
    "error",
    "created_at"
  ],
  "additionalProperties": false
}
```

### Create snapshot

`POST /v1/snapshots`

#### Request body

- `sandbox_id` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "sandbox_id": {}
  },
  "required": [
    "sandbox_id"
  ]
}
```

#### Response

- `id` custom, required
- `sandbox_id` custom, required
- `session_id` custom | null, required
- `project_id` custom, required
- `status` "creating" | "ready" | "failed", required
- `volume_snapshot_name` string, required
- `ready_at` custom | null, required
- `error` string | null, required
- `created_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "sandbox_id": {},
    "session_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "project_id": {},
    "status": {
      "type": "string",
      "enum": [
        "creating",
        "ready",
        "failed"
      ]
    },
    "volume_snapshot_name": {
      "type": "string"
    },
    "ready_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {}
  },
  "required": [
    "id",
    "sandbox_id",
    "session_id",
    "project_id",
    "status",
    "volume_snapshot_name",
    "ready_at",
    "error",
    "created_at"
  ],
  "additionalProperties": false
}
```

### List snapshots

`GET /v1/snapshots`

#### Query parameters

- `limit` integer (min: 1; max: 100), optional
- `after` string, optional
- `project_id` custom, required
- `sandbox_id` custom, optional
- `status` "creating" | "ready" | "failed", optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "after": {
      "type": "string"
    },
    "project_id": {},
    "sandbox_id": {},
    "status": {
      "type": "string",
      "enum": [
        "creating",
        "ready",
        "failed"
      ]
    }
  },
  "required": [
    "project_id"
  ]
}
```

#### Response

- `data` object[], required
  - `id` custom, required
  - `sandbox_id` custom, required
  - `session_id` custom | null, required
  - `project_id` custom, required
  - `status` "creating" | "ready" | "failed", required
  - `volume_snapshot_name` string, required
  - `ready_at` custom | null, required
  - `error` string | null, required
  - `created_at` custom, required
- `has_more` boolean, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {},
          "sandbox_id": {},
          "session_id": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ]
          },
          "project_id": {},
          "status": {
            "type": "string",
            "enum": [
              "creating",
              "ready",
              "failed"
            ]
          },
          "volume_snapshot_name": {
            "type": "string"
          },
          "ready_at": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ]
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {}
        },
        "required": [
          "id",
          "sandbox_id",
          "session_id",
          "project_id",
          "status",
          "volume_snapshot_name",
          "ready_at",
          "error",
          "created_at"
        ],
        "additionalProperties": false
      }
    },
    "has_more": {
      "type": "boolean"
    }
  },
  "required": [
    "data",
    "has_more"
  ],
  "additionalProperties": false
}
```

### Get snapshot

`GET /v1/snapshots/{id}`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

- `id` custom, required
- `sandbox_id` custom, required
- `session_id` custom | null, required
- `project_id` custom, required
- `status` "creating" | "ready" | "failed", required
- `volume_snapshot_name` string, required
- `ready_at` custom | null, required
- `error` string | null, required
- `created_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "sandbox_id": {},
    "session_id": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "project_id": {},
    "status": {
      "type": "string",
      "enum": [
        "creating",
        "ready",
        "failed"
      ]
    },
    "volume_snapshot_name": {
      "type": "string"
    },
    "ready_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {}
  },
  "required": [
    "id",
    "sandbox_id",
    "session_id",
    "project_id",
    "status",
    "volume_snapshot_name",
    "ready_at",
    "error",
    "created_at"
  ],
  "additionalProperties": false
}
```

### Delete snapshot

`DELETE /v1/snapshots/{id}`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

No response body.

---

Company: Socra — Multiply Your Judgment
Canonical URL: https://cloud.socra.com/docs/sandbox/reference/api
