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

# Connect to a workspace

> Attaches to the workspace, or with start=true starts it first when a start would, and answers running with the attach transport or connecting with a retry delay.

Use this tool when you need to:
- Attach to a ready workspace's terminal, agent and files over its WebSocket
- Start an idle, stopped or suspended workspace and follow it until it runs
- Learn, without starting anything, why a workspace cannot be attached and what to do next

Examples:
- POST /workspaces/{workspaceID}/connect
- POST /workspaces/6f1c2a9e-3b7d-4c55-9a2e-0d8b1f4e7c21/connect?start=true

Hints:
- workspaceID is the workspace's uuid (422 otherwise); start is an optional boolean, false by default: without it the call only attaches, so it never boots or bills a machine. Takes no body.
- Answers 200 with a union on state: running (a ready workspace) carries transport, its websocket_path (the workspace's /ws WebSocket) and 32-character preview_token; connecting (starting or preparing) carries retry_after_ms, 1000, and the lifecycle operation driving it: call again after the delay.
- start=true starts an idle, stopped or suspended workspace that still has its machine, attributed to its one bound task (the server picks it), and answers connecting; on a workspace that is ready or coming up it attaches as without it.
- A workspace that cannot be attached is refused with 409 and one conflict whose kind says what to do: transitional (a stop, suspend or other lifecycle operation is settling: ask again after retry_after_ms), startable (offer a start: call again with start=true), not_connectable (nothing the caller does helps, with its display_state: an errored workspace, or one without a machine or a bound task) or creator_deleted (the bound task's creator was deleted, so only a re-created task can start); each also carries its code (workspace_transitional, workspace_startable, workspace_not_connectable, task_creator_deleted) and workspace_id.
- A start that runtime admission refuses is a 402 whose code is the refusal kind (user_suspended, org_suspended, billing_blocked, org_task_concurrency_exceeded, credits_exhausted or workspace_run_unavailable), with tier, vm_size and org_id.
- Use getWorkspace instead to read display_state and startable without attaching; use stopWorkspace instead to stop it.
- The workspace's creator, or an owner or admin of its organization; another member is refused with 403 control_forbidden, a viewer or billing member with 403 org_role_insufficient, a suspended organization with 403 org_suspended, a workspace the caller cannot see is 404, and 503 when the membership check is unavailable. An agent host's grant is refused with 403 agent_host_route_not_allowed.



## OpenAPI

````yaml api-reference/openapi.json POST /workspaces/{workspaceID}/connect
openapi: 3.1.0
info:
  title: Aether API
  version: 0.1.0
servers:
  - url: https://api.runaether.dev
security:
  - bearerAuth: []
paths:
  /workspaces/{workspaceID}/connect:
    post:
      tags:
        - workspaces
      summary: Connect to a workspace
      description: >-
        Attaches to the workspace, or with start=true starts it first when a
        start would, and answers running with the attach transport or connecting
        with a retry delay.


        Use this tool when you need to:

        - Attach to a ready workspace's terminal, agent and files over its
        WebSocket

        - Start an idle, stopped or suspended workspace and follow it until it
        runs

        - Learn, without starting anything, why a workspace cannot be attached
        and what to do next


        Examples:

        - POST /workspaces/{workspaceID}/connect

        - POST
        /workspaces/6f1c2a9e-3b7d-4c55-9a2e-0d8b1f4e7c21/connect?start=true


        Hints:

        - workspaceID is the workspace's uuid (422 otherwise); start is an
        optional boolean, false by default: without it the call only attaches,
        so it never boots or bills a machine. Takes no body.

        - Answers 200 with a union on state: running (a ready workspace) carries
        transport, its websocket_path (the workspace's /ws WebSocket) and
        32-character preview_token; connecting (starting or preparing) carries
        retry_after_ms, 1000, and the lifecycle operation driving it: call again
        after the delay.

        - start=true starts an idle, stopped or suspended workspace that still
        has its machine, attributed to its one bound task (the server picks it),
        and answers connecting; on a workspace that is ready or coming up it
        attaches as without it.

        - A workspace that cannot be attached is refused with 409 and one
        conflict whose kind says what to do: transitional (a stop, suspend or
        other lifecycle operation is settling: ask again after retry_after_ms),
        startable (offer a start: call again with start=true), not_connectable
        (nothing the caller does helps, with its display_state: an errored
        workspace, or one without a machine or a bound task) or creator_deleted
        (the bound task's creator was deleted, so only a re-created task can
        start); each also carries its code (workspace_transitional,
        workspace_startable, workspace_not_connectable, task_creator_deleted)
        and workspace_id.

        - A start that runtime admission refuses is a 402 whose code is the
        refusal kind (user_suspended, org_suspended, billing_blocked,
        org_task_concurrency_exceeded, credits_exhausted or
        workspace_run_unavailable), with tier, vm_size and org_id.

        - Use getWorkspace instead to read display_state and startable without
        attaching; use stopWorkspace instead to stop it.

        - The workspace's creator, or an owner or admin of its organization;
        another member is refused with 403 control_forbidden, a viewer or
        billing member with 403 org_role_insufficient, a suspended organization
        with 403 org_suspended, a workspace the caller cannot see is 404, and
        503 when the membership check is unavailable. An agent host's grant is
        refused with 403 agent_host_route_not_allowed.
      operationId: connectWorkspace
      parameters:
        - in: path
          name: workspaceID
          required: true
          schema:
            format: uuid
            type: string
        - description: >-
            Permit this connect to start the workspace. Omitted or false
            attaches only: a workspace that is not already usable answers 409
            with the conflict union, discriminated by kind.
          explode: false
          in: query
          name: start
          schema:
            description: >-
              Permit this connect to start the workspace. Omitted or false
              attaches only: a workspace that is not already usable answers 409
              with the conflict union, discriminated by kind.
            type: boolean
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspaceConnection'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Unauthorized
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspaceRuntimeAdmissionError'
          description: Payment Required
        '403':
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/OrgAuthorizationErrorResponse'
                  - $ref: '#/components/schemas/ControlForbiddenErrorResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspaceConnectConflictResponse'
          description: Conflict
        '410':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Gone
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Internal Server Error
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Service Unavailable
components:
  schemas:
    WorkspaceConnection:
      discriminator:
        mapping:
          connecting: '#/components/schemas/WorkspaceConnectConnecting'
          running: '#/components/schemas/WorkspaceConnectRunning'
        propertyName: state
      oneOf:
        - $ref: '#/components/schemas/WorkspaceConnectRunning'
        - $ref: '#/components/schemas/WorkspaceConnectConnecting'
    WorkspacesErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - account_deleting
            - bad_gateway
            - bad_request
            - cli_upgrade_required
            - client_outdated
            - conflict
            - control_forbidden
            - forbidden
            - gateway_timeout
            - gone
            - internal_error
            - method_not_allowed
            - not_acceptable
            - not_found
            - not_implemented
            - org_role_insufficient
            - org_suspended
            - payment_required
            - precondition_failed
            - preview_auth_command_failed
            - preview_auth_invalid_output
            - preview_auth_not_auto
            - preview_auth_not_declared
            - preview_auth_output_too_large
            - preview_auth_rate_limited
            - preview_auth_timeout
            - preview_auth_workspace_upgrade_required
            - rate_limited
            - request_canceled
            - request_timeout
            - request_too_large
            - service_unavailable
            - task_creator_deleted
            - unauthenticated
            - unsupported_media_type
            - validation_failed
            - workspace_not_connectable
            - workspace_not_resizable
            - workspace_not_running
            - workspace_preview_auth_service_not_ready
            - workspace_startable
            - workspace_transitional
          minLength: 1
          type: string
        error:
          minLength: 1
          type: string
        errors:
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type: array
      required:
        - error
        - code
      type: object
    WorkspaceRuntimeAdmissionError:
      additionalProperties: false
      properties:
        code:
          enum:
            - user_suspended
            - org_suspended
            - billing_blocked
            - org_task_concurrency_exceeded
            - credits_exhausted
            - workspace_run_unavailable
          type: string
        error:
          minLength: 1
          type: string
        org_id:
          format: uuid
          type: string
        tier:
          enum:
            - free
            - starter
            - pro
            - max
            - team
          type:
            - string
            - 'null'
        vm_size:
          enum:
            - small
            - medium
            - large
            - xl
          type: string
      required:
        - error
        - code
        - tier
        - vm_size
        - org_id
      type: object
    OrgAuthorizationErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - org_membership_required
            - org_role_insufficient
            - org_suspended
            - account_deleting
            - agent_host_route_not_allowed
            - credential_kind_not_admitted
            - grant_scope_insufficient
          type: string
        error:
          minLength: 1
          type: string
      required:
        - error
        - code
      type: object
    ControlForbiddenErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - control_forbidden
          type: string
        error:
          minLength: 1
          type: string
      required:
        - error
        - code
      type: object
    WorkspaceConnectConflictResponse:
      discriminator:
        mapping:
          creator_deleted: '#/components/schemas/WorkspaceConnectConflictCreatorDeleted'
          not_connectable: '#/components/schemas/WorkspaceConnectConflictNotConnectable'
          startable: '#/components/schemas/WorkspaceConnectConflictStartable'
          transitional: '#/components/schemas/WorkspaceConnectConflictTransitional'
        propertyName: kind
      oneOf:
        - $ref: '#/components/schemas/WorkspaceConnectConflictTransitional'
        - $ref: '#/components/schemas/WorkspaceConnectConflictStartable'
        - $ref: '#/components/schemas/WorkspaceConnectConflictNotConnectable'
        - $ref: '#/components/schemas/WorkspaceConnectConflictCreatorDeleted'
    WorkspaceConnectConnecting:
      additionalProperties: false
      properties:
        display_state:
          enum:
            - deleted
            - idle
            - starting
            - stopping
            - suspending
            - ready
            - preparing
            - error
            - stopped
            - suspended
          type: string
        last_started_at:
          format: date-time
          type: string
        operation:
          $ref: '#/components/schemas/WorkspaceOperationSummary'
        retry_after_ms:
          format: int64
          minimum: 1
          type: integer
        state:
          enum:
            - connecting
          type: string
        workspace_id:
          format: uuid
          type: string
      required:
        - workspace_id
        - state
        - display_state
        - retry_after_ms
      type: object
    WorkspaceConnectRunning:
      additionalProperties: false
      properties:
        display_state:
          enum:
            - deleted
            - idle
            - starting
            - stopping
            - suspending
            - ready
            - preparing
            - error
            - stopped
            - suspended
          type: string
        last_started_at:
          format: date-time
          type: string
        operation:
          $ref: '#/components/schemas/WorkspaceOperationSummary'
        state:
          enum:
            - running
          type: string
        transport:
          $ref: '#/components/schemas/WorkspaceConnectTransport'
        workspace_id:
          format: uuid
          type: string
      required:
        - workspace_id
        - state
        - display_state
        - transport
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
    WorkspaceConnectConflictCreatorDeleted:
      additionalProperties: false
      properties:
        code:
          enum:
            - task_creator_deleted
          type: string
        error:
          minLength: 1
          type: string
        kind:
          enum:
            - creator_deleted
          type: string
        workspace_id:
          format: uuid
          type: string
      required:
        - kind
        - code
        - error
        - workspace_id
      type: object
    WorkspaceConnectConflictNotConnectable:
      additionalProperties: false
      properties:
        code:
          enum:
            - workspace_not_connectable
          type: string
        display_state:
          enum:
            - deleted
            - idle
            - error
            - stopped
            - suspended
          type: string
        error:
          minLength: 1
          type: string
        kind:
          enum:
            - not_connectable
          type: string
        workspace_id:
          format: uuid
          type: string
      required:
        - kind
        - code
        - error
        - workspace_id
        - display_state
      type: object
    WorkspaceConnectConflictStartable:
      additionalProperties: false
      properties:
        code:
          enum:
            - workspace_startable
          type: string
        error:
          minLength: 1
          type: string
        kind:
          enum:
            - startable
          type: string
        workspace_id:
          format: uuid
          type: string
      required:
        - kind
        - code
        - error
        - workspace_id
      type: object
    WorkspaceConnectConflictTransitional:
      additionalProperties: false
      properties:
        code:
          enum:
            - workspace_transitional
          type: string
        error:
          minLength: 1
          type: string
        kind:
          enum:
            - transitional
          type: string
        retry_after_ms:
          format: int64
          minimum: 1
          type: integer
        workspace_id:
          format: uuid
          type: string
      required:
        - kind
        - code
        - error
        - workspace_id
        - retry_after_ms
      type: object
    WorkspaceOperationSummary:
      additionalProperties: false
      properties:
        completed_at:
          format: date-time
          type: string
        created_at:
          format: date-time
          type: string
        error_message:
          minLength: 1
          type: string
        id:
          format: uuid
          type: string
        status:
          enum:
            - queued
            - running
            - reconciling
            - succeeded
            - failed
            - cancelled
          type: string
        type:
          enum:
            - start
            - suspend
            - stop
            - recover
          type: string
        updated_at:
          format: date-time
          type: string
      required:
        - id
        - type
        - status
        - created_at
        - updated_at
      type: object
    WorkspaceConnectTransport:
      additionalProperties: false
      properties:
        preview_token:
          maxLength: 32
          minLength: 32
          pattern: ^[a-z0-9]{32}$
          type: string
        websocket_path:
          minLength: 1
          type: string
      required:
        - websocket_path
        - preview_token
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.