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

# Open terminal session (WebSocket)

> Open an interactive terminal (shell) session to a running application process.

**This is a WebSocket endpoint.** Connect using a WebSocket client with the `Upgrade: websocket` header. Standard HTTP requests return a `426 Upgrade Required` response.

### Connection

```
wscat -c "wss://api.sevalla.com/v3/applications/{id}/processes/{process_id}/terminal?shell=bash" -H "Authorization: Bearer <api_key>"
```

Authentication runs before the WebSocket upgrade - invalid credentials are rejected with a standard HTTP 401/403 response.

### Communication

Once connected, the WebSocket streams stdin/stdout bidirectionally to a shell running inside the container. Send text messages as shell input and receive command output as text messages.

### Close codes

- `4000` - Application or process not found
- `4001` - No running pod available to connect to
- `4002` - Shell stream error
- `4003` - Shell stream closed normally
- `4005` - Failed to connect to the pod
- `4300` - Unexpected server error



## OpenAPI

````yaml https://api.sevalla.com/v3/openapi.json get /applications/{id}/processes/{process_id}/terminal
openapi: 3.1.0
info:
  title: Sevalla API docs
  version: 1.0.0
servers:
  - url: https://api.sevalla.com/v3
security:
  - bearerAuth: []
paths:
  /applications/{id}/processes/{process_id}/terminal:
    get:
      tags:
        - Applications
      summary: Open terminal session (WebSocket)
      description: >-
        Open an interactive terminal (shell) session to a running application
        process.


        **This is a WebSocket endpoint.** Connect using a WebSocket client with
        the `Upgrade: websocket` header. Standard HTTP requests return a `426
        Upgrade Required` response.


        ### Connection


        ```

        wscat -c
        "wss://api.sevalla.com/v3/applications/{id}/processes/{process_id}/terminal?shell=bash"
        -H "Authorization: Bearer <api_key>"

        ```


        Authentication runs before the WebSocket upgrade - invalid credentials
        are rejected with a standard HTTP 401/403 response.


        ### Communication


        Once connected, the WebSocket streams stdin/stdout bidirectionally to a
        shell running inside the container. Send text messages as shell input
        and receive command output as text messages.


        ### Close codes


        - `4000` - Application or process not found

        - `4001` - No running pod available to connect to

        - `4002` - Shell stream error

        - `4003` - Shell stream closed normally

        - `4005` - Failed to connect to the pod

        - `4300` - Unexpected server error
      operationId: openTerminalV3
      parameters:
        - schema:
            default: sh
            type: string
            enum:
              - sh
              - bash
              - dash
              - ksh
              - zsh
              - csh
              - tcsh
          in: query
          name: shell
          required: false
          description: >-
            Shell to use for the terminal session. `sh` - Bourne shell
            (default). `bash` - Bourne Again Shell. `dash` - Debian Almquist
            Shell. `ksh` - KornShell. `zsh` - Z Shell. `csh` - C Shell. `tcsh` -
            TENEX C Shell.
        - schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
            example: fb5e5168-4281-4bec-94c5-0d1584e9e657
          in: path
          name: id
          required: true
          description: Application identifier
        - schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
            example: fb5e5168-4281-4bec-94c5-0d1584e9e657
          in: path
          name: process_id
          required: true
          description: Process identifier
      responses:
        '401':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: Unauthorized
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code
                    example: 401
                  data:
                    type: object
                    properties:
                      code:
                        description: Error tracking code for support reference
                        example: err-abc-123
                        type: string
                      message:
                        description: Additional error details or instructions
                        example: >-
                          If you need assistance, please contact support and
                          provide this error code.
                        type: string
                    additionalProperties: false
                required:
                  - message
                  - status
                additionalProperties: false
        '403':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: Forbidden
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code
                    example: 403
                  data:
                    type: object
                    properties:
                      code:
                        description: Error tracking code for support reference
                        example: err-abc-123
                        type: string
                      message:
                        description: Additional error details or instructions
                        example: >-
                          If you need assistance, please contact support and
                          provide this error code.
                        type: string
                    additionalProperties: false
                required:
                  - message
                  - status
                additionalProperties: false
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: Not found
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code
                    example: 404
                  data:
                    type: object
                    properties:
                      code:
                        description: Error tracking code for support reference
                        example: err-abc-123
                        type: string
                      message:
                        description: Additional error details or instructions
                        example: >-
                          If you need assistance, please contact support and
                          provide this error code.
                        type: string
                    additionalProperties: false
                required:
                  - message
                  - status
                additionalProperties: false
        '426':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message indicating WebSocket upgrade is required
                    example: Upgrade Required
                  status:
                    type: number
                    description: HTTP status code
                    example: 426
                    enum:
                      - 426
                  data:
                    type: object
                    properties: {}
                    additionalProperties: false
                required:
                  - message
                  - status
                additionalProperties: false
        '500':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: Internal Server Error
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code
                    example: 500
                  data:
                    type: object
                    properties:
                      code:
                        description: Error tracking code for support reference
                        example: err-abc-123
                        type: string
                      message:
                        description: Additional error details or instructions
                        example: >-
                          If you need assistance, please contact support and
                          provide this error code.
                        type: string
                    additionalProperties: false
                required:
                  - message
                  - status
                additionalProperties: false
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authentication. Pass your API key as a Bearer token in the
        Authorization header.

````