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

# Connect to terminal WebSocket stream

> Upgrades to a WebSocket connection for interactive terminal I/O. Clients send JSON `TerminalClientEvent` messages and receive JSON `TerminalServerEvent` messages. Terminal byte streams are base64-encoded inside `input` and `output` events; `resize` events use integer `width` and `height` fields.



## OpenAPI

````yaml /dcs-openapi.json get /v1/machines/{machine_id}/terminals/{terminal_id}/stream
openapi: 3.1.0
info:
  description: Controlplane API for Dedalus Cloud Services (DCS).
  title: Dedalus Cloud Services API
  version: v1
servers:
  - description: Official DCS API
    url: https://dcs.dedaluslabs.ai
security:
  - ApiKeyAuth: []
  - BearerAuth: []
paths:
  /v1/machines/{machine_id}/terminals/{terminal_id}/stream:
    get:
      tags:
        - Machine Lifecycle
        - Machine Terminals
      summary: Connect to terminal WebSocket stream
      description: >-
        Upgrades to a WebSocket connection for interactive terminal I/O. Clients
        send JSON `TerminalClientEvent` messages and receive JSON
        `TerminalServerEvent` messages. Terminal byte streams are base64-encoded
        inside `input` and `output` events; `resize` events use integer `width`
        and `height` fields.
      operationId: connectMachineTerminal
      parameters:
        - description: Organization ID header applied to all DCS requests.
          in: header
          name: X-Dedalus-Org-Id
          schema:
            format: uuid
            type: string
        - description: Machine identifier.
          in: path
          name: machine_id
          required: true
          schema:
            $ref: '#/components/schemas/MachineIDPathSegment'
        - description: Terminal identifier.
          in: path
          name: terminal_id
          required: true
          schema:
            $ref: '#/components/schemas/PublicPathSegment'
      responses:
        '101':
          description: Switching Protocols to WebSocket
        '401':
          content:
            application/json:
              examples:
                invalid_key:
                  value:
                    error_code: AUTH_INVALID
                    message: invalid Dedalus API key
                    retryable: false
                missing_key:
                  value:
                    error_code: AUTH_REQUIRED
                    message: missing Dedalus API key
                    retryable: false
              schema:
                additionalProperties: false
                properties:
                  details:
                    additionalProperties:
                      type: string
                    type: object
                  error_code:
                    type: string
                  message:
                    type: string
                  retry_after_ms:
                    format: int64
                    type: integer
                  retryable:
                    type: boolean
                required:
                  - error_code
                  - message
                  - retryable
                type: object
          description: Authentication required
        '403':
          content:
            application/json:
              examples:
                org_mismatch:
                  value:
                    error_code: AUTH_ORG_MISMATCH
                    message: org scope does not match API key ownership
                    retryable: false
                scope_forbidden:
                  value:
                    error_code: AUTH_SCOPE_FORBIDDEN
                    message: internal service authorization is required
                    retryable: false
              schema:
                additionalProperties: false
                properties:
                  details:
                    additionalProperties:
                      type: string
                    type: object
                  error_code:
                    type: string
                  message:
                    type: string
                  retry_after_ms:
                    format: int64
                    type: integer
                  retryable:
                    type: boolean
                required:
                  - error_code
                  - message
                  - retryable
                type: object
          description: Forbidden
        '409':
          content:
            application/json:
              examples:
                terminal_closed:
                  value:
                    error_code: INVALID_STATE
                    message: terminal is not ready for streaming
                    retryable: false
                    details:
                      current_status: closed
                      expected_status: ready
                terminal_not_ready:
                  value:
                    error_code: INVALID_STATE
                    message: terminal is not ready for streaming
                    retryable: true
                    retry_after_ms: 1000
                    details:
                      current_status: wake_in_progress
                      expected_status: ready
              schema:
                additionalProperties: false
                properties:
                  details:
                    additionalProperties:
                      type: string
                    type: object
                  error_code:
                    type: string
                  message:
                    type: string
                  retry_after_ms:
                    format: int64
                    type: integer
                  retryable:
                    type: boolean
                required:
                  - error_code
                  - message
                  - retryable
                type: object
          description: Terminal is not ready for streaming
        '429':
          content:
            application/json:
              examples:
                idempotency_in_flight:
                  value:
                    error_code: RATE_LIMITED
                    message: idempotency key is already in-flight
                    retryable: true
                    retry_after_ms: 250
                mutation_rate_limited:
                  value:
                    error_code: RATE_LIMITED
                    message: mutation rate limit exceeded
                    retryable: true
                    retry_after_ms: 84
                    details:
                      rate_limit_scope: read_lifecycle_routes
              schema:
                additionalProperties: false
                properties:
                  details:
                    additionalProperties:
                      type: string
                    type: object
                  error_code:
                    type: string
                  message:
                    type: string
                  retry_after_ms:
                    format: int64
                    type: integer
                  retryable:
                    type: boolean
                required:
                  - error_code
                  - message
                  - retryable
                type: object
          description: Rate limited
        '503':
          content:
            application/json:
              examples:
                mutation_limiter_unavailable:
                  value:
                    error_code: DEPENDENCY_UNAVAILABLE
                    message: mutation rate limiter unavailable
                    retryable: true
                    details:
                      rate_limit_backend: redis
                      rate_limit_scope: read_lifecycle_routes
                runtime_unavailable:
                  value:
                    error_code: DEPENDENCY_UNAVAILABLE
                    message: runtime unavailable
                    retryable: true
              schema:
                additionalProperties: false
                properties:
                  details:
                    additionalProperties:
                      type: string
                    type: object
                  error_code:
                    type: string
                  message:
                    type: string
                  retry_after_ms:
                    format: int64
                    type: integer
                  retryable:
                    type: boolean
                required:
                  - error_code
                  - message
                  - retryable
                type: object
          description: Dependency unavailable
components:
  schemas:
    MachineIDPathSegment:
      maxLength: 253
      minLength: 4
      pattern: ^dm-[a-z0-9]([a-z0-9-]*[a-z0-9])?$
      type: string
    PublicPathSegment:
      maxLength: 253
      minLength: 1
      pattern: ^[A-Za-z0-9]([A-Za-z0-9._-]*[A-Za-z0-9])?$
      type: string
  securitySchemes:
    ApiKeyAuth:
      description: Dedalus API key. Alternative to Bearer token.
      in: header
      name: x-api-key
      type: apiKey
    BearerAuth:
      bearerFormat: Dedalus API key
      description: 'Dedalus API key in Authorization: Bearer <key>.'
      scheme: bearer
      type: http

````