# Laptop

> The device bridge (M4): the person's desktop app (and, later, browser extension) registers as a device and keeps a WebSocket open at `/v1/devices/ws`; agents' laptop calls are routed to it and run inside the folders the person granted on the laptop: 7 endpoints of the Teemli API.

Source: https://docs.teemli.com/developers/reference/laptop/

Generated from [`api/openapi.yaml`](/developers/api/) (OpenAPI 3.1). Base URL: `https://api.teemli.com`. Auth: `Authorization: Bearer <token or tml_ API key>`. Errors are `application/problem+json`; writes accept an `Idempotency-Key` header.

The device bridge (M4): the person's desktop app (and, later, browser extension) registers as a device and keeps
a WebSocket open at `/v1/devices/ws`; agents' laptop calls are routed to it and run inside the folders the person
granted on the laptop. Connection status, granted folders (shown, managed on the laptop), and the "laptop access"
admin switch. Per-agent Always/Ask/Never is the agent's `laptop_access` (PATCH the agent).

## My devices, with live status

```http
GET /v1/orgs/{org}/devices
```

Only the caller's own devices (row-level security: never anyone else's, not even an admin's view).
`online` = the device's socket is open and it pinged within 90 s. Also returns the organisation's
"laptop access" switch and whether the caller may change it.

**API keys:** not available (needs a person signed in to the app).

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Responses**

- `200` Devices — DeviceList
- `401` Missing, invalid or expired token — Problem

## Register this device (the desktop app on first sign-in)

```http
POST /v1/orgs/{org}/devices
```

Returns the device; the app keeps its `id` and opens `/v1/devices/ws`. At most 20 per person.

**API keys:** not available (needs a person signed in to the app).

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `kind` (required) | `desktop`, `extension` |  |
| `platform` (required) | `macos`, `windows`, `linux`, `chrome`, `edge` |  |
| `name` (required) | string | e.g. the computer's name, "Priya's MacBook Pro" |
| `app_version` | string |  |
| `os_version` | string |  |

**Responses**

- `201` Registered — Device
- `401` Missing, invalid or expired token — Problem
- `409` Conflicting state (card already answered, duplicate in flight, name taken) — Problem
- `422` Invalid input — Problem

## Rename a device

```http
PATCH /v1/orgs/{org}/devices/{device}
```

**API keys:** not available (needs a person signed in to the app).

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `device` (required) | path | string (uuid) |  |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `name` (required) | string |  |

**Responses**

- `200` Renamed — Device
- `401` Missing, invalid or expired token — Problem
- `404` Not found (also returned for rows the caller may not see, and for disabled features) — Problem

## Disconnect a device (e.g. a lost laptop)

```http
DELETE /v1/orgs/{org}/devices/{device}
```

Revokes it: its socket closes with 4403 and the app signs out; it can't reconnect with this id. Laptop calls
that were on their way to it go back to waiting for a laptop. Live: `device.updated {device_id, revoked: true}`.

**API keys:** not available (needs a person signed in to the app).

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `device` (required) | path | string (uuid) |  |

**Responses**

- `200` Deleted — object
- `401` Missing, invalid or expired token — Problem
- `404` Not found (also returned for rows the caller may not see, and for disabled features) — Problem

## The organisation's "laptop access" switch

```http
GET /v1/orgs/{org}/settings/laptop
```

**API keys:** not available (needs a person signed in to the app).

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Responses**

- `200` Switch — LaptopSettings
- `401` Missing, invalid or expired token — Problem

## Turn laptop access on or off (admins)

```http
PUT /v1/orgs/{org}/settings/laptop
```

Off = no agent in the organisation gets laptop tools; calls already waiting fail with a clear reason.

**API keys:** not available (needs a person signed in to the app).

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `enabled` (required) | boolean |  |

**Responses**

- `200` Switch — LaptopSettings
- `401` Missing, invalid or expired token — Problem
- `403` Authenticated but not allowed (e.g. unverified email, not the agent's controller, card routed to someone else) — Problem

## The device's own WebSocket (desktop app, extension)

```http
GET /v1/devices/ws
```

Upgrade to a WebSocket. The first message must be `hello` within 10 s
(`{type: "hello", access_token, device_id, app_version, os_version, granted_folders, allow_shell}`;
the token may instead be sent as `Authorization: Bearer`). The server answers `ready`, then forwards laptop
calls (`request`, `cancel`) routed to this device and accepts `ping`, `auth`, `folders`, `asking`, `running`,
`result` and `set_agent_access`. Full message schemas: `api/asyncapi.yaml` (channel `deviceSocket`).
Close codes: 4401 token missing/invalid/expired (refresh and reconnect), 4403 device disconnected (sign out),
4404 unknown device (register again).

**Auth:** none (public endpoint).

**Responses**

- `101` Switching protocols
