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

# Start Sandcastle

> Start a new Python sandcastle, or restart a specific one

<Note>
  Omit the body (or send `{}`) to create a new sandcastle. To **restart** an existing one, pass back the `sandbox_id` you got from create or [list](/api-reference/v2/sandbox/list-sandboxes): `{"sandbox_id": "..."}`. You can only restart your own sandcastles.
</Note>


## OpenAPI

````yaml POST /v2/sandcastles
openapi: 3.1.0
info:
  title: TextQL v2 API
  version: '2.0'
  description: >
    REST API for TextQL platform operations. All endpoints require Bearer token
    authentication.
servers:
  - url: https://app.textql.com
security:
  - bearerAuth: []
tags:
  - name: Chat
    description: Create and manage AI chat sessions
  - name: Connectors
    description: List available data connectors
  - name: Playbooks
    description: Create, configure, and run automated playbooks
  - name: Sandcastles
    description: Manage Python sandbox environments for code execution
  - name: Changes
    description: Review, approve, and deny Context Library changes
paths:
  /v2/sandcastles:
    post:
      tags:
        - Sandcastles
      summary: Start Sandcastle
      description: >-
        Start a Python sandcastle for code execution. Omit the body to create a
        new sandcastle, or pass back a sandbox_id from create/list to restart
        that one.
      operationId: v2.startSandbox
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                sandbox_id:
                  type: string
                  description: >-
                    Restart an existing sandcastle by passing back the
                    sandbox_id returned by create or list; omit to create a new
                    sandcastle. You can only restart your own sandcastles.
      responses:
        '201':
          description: Started sandbox
          content:
            application/json:
              schema:
                type: object
                properties:
                  sandbox_id:
                    type: string
                    description: Unique sandbox identifier
                  created_at:
                    type: string
                    format: date-time
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: >-
            The sandbox_id to restart is malformed or does not belong to your
            organization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  responses:
    Unauthorized:
      description: Missing or invalid authentication
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: unauthenticated
              message: Authentication required
    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: permission_denied
              message: Insufficient permissions
    RateLimited:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: rate_limit_exceeded
              message: Rate limit exceeded
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: internal
              message: Internal server error
  schemas:
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code
              enum:
                - invalid_request
                - unauthenticated
                - permission_denied
                - not_found
                - conflict
                - rate_limit_exceeded
                - internal
                - timeout
                - cancelled
                - execution_failed
                - no_report
            message:
              type: string
              description: Human-readable error message
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key or JWT token

````