# Open terminal

`POST /v1/projects/{project}/environments/{environment}/terminals`, operation `environments.OpenTerminal`

Issues a short-lived ticket to connect to an interactive shell in a running environment.

For environments owned by an agent, also requires agents.agents.send on that agent. Pass the returned token to AttachTerminal in Sec-WebSocket-Protocol as kosem.auth.<token>.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `project` | path | Yes | `string` | The project's ID. |
| `environment` | path | Yes | `string` | The environment's ID. |

## Request body

Content-Type: `application/json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `sessionId` | `string` | No | Existing terminal session ID to reattach to; leave empty to start a new session. |

## Responses

### 200

OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `expireTime` | `string (date-time)` | Yes | When the ticket expires. |
| `sessionId` | `string` | Yes | Terminal session ID to pass to AttachTerminal. |
| `token` | `string` | Yes | Short-lived attach ticket. Pass it in Sec-WebSocket-Protocol as kosem.auth.<token> (don't pass it in the URL). |

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