# Attach terminal

`GET /v1/projects/{project}/environments/{environment}/terminals/{terminal}/attach`, operation `environments.AttachTerminal`

Upgrades to a WebSocket attached to an interactive shell in a running environment.

Authenticates with the ticket from OpenTerminal sent in Sec-WebSocket-Protocol as kosem.terminal.v1, kosem.auth.<token>. Binary frames carry terminal input and offset-prefixed output; text JSON frames carry resize, status, ready, exit and error messages.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `project` | path | Yes | `string` | The project's ID. |
| `environment` | path | Yes | `string` | The environment's ID. |
| `terminal` | path | Yes | `string` | The terminal session ID. |
| `cols` | query | No | `integer (int32)` | Initial terminal width in columns. Defaults to 80 when 0. |
| `rows` | query | No | `integer (int32)` | Initial terminal height in rows. Defaults to 24 when 0. |
| `after` | query | No | `integer (int64)` | Last output byte offset already received, for lossless replay on reattach. |
| `create` | query | No | `boolean` | Start a new shell session if this ID doesn't exist yet. |

## Responses

### 101

Switching Protocols: the connection speaks the protocol that the request asked for from here on.

### default

Error

Base URL: `https://api.kosem.ai`. See [API conventions](https://docs.kosem.ai/reference/api-conventions.md) for authentication, pagination and errors, and [https://docs.kosem.ai/openapi.yaml](https://docs.kosem.ai/openapi.yaml) for the full OpenAPI document.