# App pairing API

How `npx @clipmux/node init` gets an app's credentials without anyone copying a secret.

Source: https://clipmux.com/docs/reference/api/app-pairing

None of these routes needs a key.

## Start an app pairing (npx @clipmux/node init) [#start-an-app-pairing-npx-clipmuxnode-init]

`POST /v1/app-pairings`

Starts a pairing: show the `code` and open `verify_url`, where the owner checks the code and approves. The code works for 10 minutes. `429 too_many_pairings` while 10 wait for the owner.

**Authentication:** None.

### Request body [#request-body]

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | no |  |
| `hostname` | string | no |  |
| `client` | string | no |  |

```json
{
  "name": "Course site",
  "hostname": "laptop.local",
  "client": "@clipmux/node 0.1.0"
}
```

### Response 201 [#response-201]

Show code; open verify_url; poll

```json
{
  "code": "KXFT-9M2Q",
  "poll_token": "K4M2QX7R3VZ6W5TYBJ2C3DNF7G",
  "verify_url": "https://video.example.com/connect?code=KXFT-9M2Q",
  "expires_at": "2026-11-18T09:40:00Z",
  "interval_seconds": 2
}
```

### Errors [#errors]

| Status | Code |
| --- | --- |
| 400 | [`invalid_request`](/docs/reference/errors#invalid_request) |
| 429 | [`rate_limited`](/docs/reference/errors#rate_limited) |
| 429 | [`too_many_pairings`](/docs/reference/errors#too_many_pairings) |

## Poll an app pairing [#poll-an-app-pairing]

`POST /v1/app-pairings/poll`

Poll every `interval_seconds`. The first poll after approval carries `credentials`, and is the only one that ever does: they are deleted as they are returned, so a later poll is `404 pairing_not_found`.

**Authentication:** None.

### Request body [#request-body-1]

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `poll_token` | string | yes |  |

```json
{
  "poll_token": "K4M2QX7R3VZ6W5TYBJ2C3DNF7G"
}
```

### Response 200 [#response-200]

The first poll after approval carries credentials, once

```json
{
  "status": "pending"
}
```

### Errors [#errors-1]

| Status | Code |
| --- | --- |
| 400 | [`invalid_request`](/docs/reference/errors#invalid_request) |
| 404 | [`pairing_not_found`](/docs/reference/errors#pairing_not_found) |
| 429 | [`rate_limited`](/docs/reference/errors#rate_limited) |
