> ## 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.

# Create an authenticated preview

> Runs the repository-owned preview auth hook for one preview port inside the running workspace and answers 201 with the authenticated preview it created.

Use this tool when you need to:
- Open a workspace preview that needs a signed-in session without signing in by hand
- Get the URL, or the local storage entries, that authenticate a preview in the browser

Examples:
- POST /workspaces/{workspaceID}/preview-auth {"port": 3000}
- POST /workspaces/6f1c2a9e-3b7d-4c55-9a2e-0d8b1f4e7c21/preview-auth {"port": 3000, "sibling_ports": [8080]}

Hints:
- port is required, 1 to 65535; sibling_ports is optional, at most 128 ports of 1 to 65535; the schema answers a plain 422 otherwise, and no body is 400. The hook gets the preview origin of port plus those of the sibling ports and of every preview the workspace declares.
- The hook is the auth_command declared for the port under previews in the repository's .aether/environment.json; it may run for 30 seconds.
- URL results can be opened directly: kind url with url, requires_client_application false. local_storage results require explicit client-side application: kind local_storage with local_storage entries and reload, requires_client_application true.
- Refused with 404 preview_auth_not_declared when the port declares no auth_command, and 422 when the hook fails, with its code (preview_auth_command_failed, preview_auth_timeout, preview_auth_output_too_large for stdout over 64 KiB, preview_auth_invalid_output) and stderr_tail, the last 8 KiB of its stderr at most.
- Refused with 409 workspace_not_running when its machine is not running, 409 preview_auth_workspace_upgrade_required for a workspace that predates preview auth (restart it), 503 workspace_preview_auth_service_not_ready when the workspace service still refuses connections after 90 seconds, and 502 when it cannot be reached or the workspace has no machine.
- Use connectWorkspace instead to start or attach to the workspace first; use getWorkspace to read its declared previews.
- Owners, admins and members of the workspace's organization, whichever organization the caller selected; a viewer or billing member is refused 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}/preview-auth
openapi: 3.1.0
info:
  title: Aether API
  version: 0.1.0
servers:
  - url: https://api.runaether.dev
security:
  - bearerAuth: []
paths:
  /workspaces/{workspaceID}/preview-auth:
    post:
      tags:
        - workspaces
      summary: Create an authenticated preview
      description: >-
        Runs the repository-owned preview auth hook for one preview port inside
        the running workspace and answers 201 with the authenticated preview it
        created.


        Use this tool when you need to:

        - Open a workspace preview that needs a signed-in session without
        signing in by hand

        - Get the URL, or the local storage entries, that authenticate a preview
        in the browser


        Examples:

        - POST /workspaces/{workspaceID}/preview-auth {"port": 3000}

        - POST /workspaces/6f1c2a9e-3b7d-4c55-9a2e-0d8b1f4e7c21/preview-auth
        {"port": 3000, "sibling_ports": [8080]}


        Hints:

        - port is required, 1 to 65535; sibling_ports is optional, at most 128
        ports of 1 to 65535; the schema answers a plain 422 otherwise, and no
        body is 400. The hook gets the preview origin of port plus those of the
        sibling ports and of every preview the workspace declares.

        - The hook is the auth_command declared for the port under previews in
        the repository's .aether/environment.json; it may run for 30 seconds.

        - URL results can be opened directly: kind url with url,
        requires_client_application false. local_storage results require
        explicit client-side application: kind local_storage with local_storage
        entries and reload, requires_client_application true.

        - Refused with 404 preview_auth_not_declared when the port declares no
        auth_command, and 422 when the hook fails, with its code
        (preview_auth_command_failed, preview_auth_timeout,
        preview_auth_output_too_large for stdout over 64 KiB,
        preview_auth_invalid_output) and stderr_tail, the last 8 KiB of its
        stderr at most.

        - Refused with 409 workspace_not_running when its machine is not
        running, 409 preview_auth_workspace_upgrade_required for a workspace
        that predates preview auth (restart it), 503
        workspace_preview_auth_service_not_ready when the workspace service
        still refuses connections after 90 seconds, and 502 when it cannot be
        reached or the workspace has no machine.

        - Use connectWorkspace instead to start or attach to the workspace
        first; use getWorkspace to read its declared previews.

        - Owners, admins and members of the workspace's organization, whichever
        organization the caller selected; a viewer or billing member is refused
        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: createWorkspacePreviewAuth
      parameters:
        - in: path
          name: workspaceID
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                port:
                  maximum: 65535
                  minimum: 1
                  type: integer
                sibling_ports:
                  items:
                    maximum: 65535
                    minimum: 1
                    type: integer
                  maxItems: 128
                  type: array
              required:
                - port
              type: object
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacePreviewAuth'
          description: Created
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/WorkspacesErrorResponse'
                  - $ref: '#/components/schemas/OrgAuthorizationErrorResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacePreviewAuthError'
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacePreviewAuthError'
          description: Conflict
        '410':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Gone
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacePreviewAuthError'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Internal Server Error
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Bad Gateway
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacesErrorResponse'
          description: Service Unavailable
components:
  schemas:
    WorkspacePreviewAuth:
      additionalProperties: false
      properties:
        kind:
          enum:
            - url
            - local_storage
          type: string
        local_storage:
          additionalProperties:
            type: string
          type: object
        reload:
          type: boolean
        requires_client_application:
          type: boolean
        url:
          format: uri
          type: string
      required:
        - kind
        - requires_client_application
      type: object
    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
    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
    WorkspacePreviewAuthError:
      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
        stderr_tail:
          type: string
      required:
        - error
        - code
      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
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````

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