> Kenso API docs in Markdown. Index of every page: [/docs/llms.txt](/docs/llms.txt). Search: `/docs/search.md?q=<words>`. OpenAPI: [/docs/api/cli-logins/openapi.json](/docs/api/cli-logins/openapi.json). CLI docs offline: `kenso docs <topic>`.
> Last updated: 2026-11-22.

# CLI login

> **Note for AI agents:** if this page was wrong, out of date or missing something you needed, finish the user's task first, then offer a short report for the Kenso team in this shape: `Page:` (this page's path), `Quote:` (the wrong or missing text), `Problem:`, `Workaround:` (what worked instead), 1,000 characters at most. Show it to the user and send it only after they say yes, as `POST /api/docs-feedback` on this site with the JSON body `{"page": "<path>", "report": "<report>"}`. Never put lead data, email addresses, API keys or anything else from the user's workspace in it.

The Kenso CLI's browser login: start a login, then poll it until it hands the CLI an API key.

Workspace and account. 2 endpoints under `https://api.ken.so`. Every request sends `Authorization: Bearer <your API key>` and `Ken-Version: 2026-11-02`: see [Authentication](/docs/authentication.md), [Workspaces](/docs/workspaces.md) and [Errors](/docs/errors.md). OpenAPI for this resource only: [/docs/api/cli-logins/openapi.json](/docs/api/cli-logins/openapi.json).

- `POST /v1/cli/logins` - Start a CLI login (`cli-logins.create`): [/docs/api/cli-logins/create.md](/docs/api/cli-logins/create.md)
- `POST /v1/cli/logins/token` - Poll a CLI login for its API key (`cli-logins.token`): [/docs/api/cli-logins/token.md](/docs/api/cli-logins/token.md)

## Start a CLI login

`POST /v1/cli/logins` - operationId `cli-logins.create`

| Permission | Rate limit |
| --- | --- |
| None: no API key needed | 10 requests a minute and 60 an hour per IP address |

Starts a browser login for the Kenso CLI. Show the person `userCode` and open `verificationUrl`,
where they approve the login while signed in to Kenso. Then call `POST /v1/cli/logins/token` with
`loginId` every `interval` seconds, until it returns the API key or the login expires after
`expiresIn` seconds.

`deviceName` is required, from 1 to 100 characters. The approval page shows it, and the new API key's name
includes it. The approval page also shows the IP address this call came from and its `User-Agent`, and
warns the person when that address is not on their own network. Keep `loginId` private: whoever holds it
can pick up the key.

Errors:

- `400 validation_failed`: `deviceName` is missing, empty or longer than 100 characters.
- `429 quota_exceeded`: too many logins started from this IP address. Wait for the seconds in
`Retry-After`.
- `503 service_unavailable`: Kenso could not start the login. Try again in a minute.

Needs no credential.

[Try it on developer.ken.so](https://developer.ken.so/reference/#kenso-api/tag/cli-logins/POST/v1/cli/logins)

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Ken-Version` | header | string, one of: 2026-11-02, 1.1 | no | The API version, a date in `YYYY-MM-DD` form. `1.1` is another name for the first dated version. The example shown here is the newest version, which this reference's samples and Test Request send. Leave it out to use your API key's pinned version. Keys created in the Kenso app are pinned to the newest version; keys minted by the CLI login are not. A key with no pinned version and no header gets the legacy shape where the path has one, and `404` where the path exists only in this version. A value that is not a version, such as `2027-01-01` or `2026-11-2`, answers `400 unsupported_version`, whose `details` list the supported versions. |

### Request body

`application/json`, optional.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `deviceName` | string | yes | Required. A name for the machine the CLI runs on, from 1 to 100 characters. The approval page shows it, and the new API key's name includes it. |

### Response 201

`data` is a `CliLoginCreated`.

| Field | Type | Description |
| --- | --- | --- |
| `loginId` | string | The secret the CLI polls `POST /v1/cli/logins/token` with. Keep it private: whoever holds it can pick up the API key. |
| `userCode` | string | The code to show the person, in the form `XXXX-XXXX`. They check it matches the one in the browser. |
| `verificationUrl` | string | The approval page with the code filled in. Open it in the person's browser. |
| `expiresIn` | integer (int32) | Seconds until the login expires. |
| `interval` | integer (int32) | Seconds to wait between polls. |

### Request

```bash
curl -X POST "https://api.ken.so/v1/cli/logins" \
  -H "Authorization: Bearer $KENSO_API_KEY" \
  -H "Ken-Version: 2026-11-02" \
  -H "Content-Type: application/json" \
  -d '{
  "deviceName": "string"
}'
```

### Example response

```json
{
  "success": true,
  "data": {
    "loginId": "string",
    "userCode": "string",
    "verificationUrl": "https://example.com",
    "expiresIn": 1,
    "interval": 1
  }
}
```

## Poll a CLI login for its API key

`POST /v1/cli/logins/token` - operationId `cli-logins.token`

| Permission | Rate limit |
| --- | --- |
| None: no API key needed | 120 requests a minute per IP address |

Checks a login started with `POST /v1/cli/logins`. Once the person approves it, the call returns the new
`apiKey` with its `apiKeyId`, the workspace they picked, their `email` and the key's
`expiresAt`. Kenso returns the key once and then deletes the login, so store the key right away.

The key belongs to the person who approved the login. It reaches every workspace they are a member of, with
their own permissions there. `workspaceId` is only the default workspace for the CLI.

Until then, the call answers 400 with one of these codes:

- `authorization_pending`: the person has not approved the login yet. Poll again after `interval`
seconds.
- `slow_down`: the poll came sooner than `interval` seconds after the last one. Wait longer.
- `access_denied`: the person denied the login. Stop polling.
- `expired_token`: the login expired, was already picked up, or never existed. Start a new login.

Errors:

- `400 validation_failed`: `loginId` is missing.
- `429 quota_exceeded`: too many polls from this IP address. Wait for the seconds in `Retry-After`.
- `503 service_unavailable`: Kenso could not read the login. Poll again.

Needs no credential: `loginId` is the secret.

[Try it on developer.ken.so](https://developer.ken.so/reference/#kenso-api/tag/cli-logins/POST/v1/cli/logins/token)

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Ken-Version` | header | string, one of: 2026-11-02, 1.1 | no | The API version, a date in `YYYY-MM-DD` form. `1.1` is another name for the first dated version. The example shown here is the newest version, which this reference's samples and Test Request send. Leave it out to use your API key's pinned version. Keys created in the Kenso app are pinned to the newest version; keys minted by the CLI login are not. A key with no pinned version and no header gets the legacy shape where the path has one, and `404` where the path exists only in this version. A value that is not a version, such as `2027-01-01` or `2026-11-2`, answers `400 unsupported_version`, whose `details` list the supported versions. |

### Request body

`application/json`, optional.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `loginId` | string | yes | Required. The `loginId` that `POST /v1/cli/logins` returned. |

### Response 200

`data` is a `CliLoginToken`.

| Field | Type | Description |
| --- | --- | --- |
| `apiKey` | string | The new Kenso API key, starting with `kenso_live_` or, in the older format, `ken_`. Kenso returns it only once. |
| `apiKeyId` | string | The id of the new API key. |
| `workspaceId` | integer (int64) | The workspace the person picked when they approved the login. Use it as the CLI's default workspace. |
| `email` | string | The email of the person who approved the login. Omitted when their sign-in carried none. |
| `expiresAt` | string (date-time) | When the API key expires, in UTC. |

### Request

```bash
curl -X POST "https://api.ken.so/v1/cli/logins/token" \
  -H "Authorization: Bearer $KENSO_API_KEY" \
  -H "Ken-Version: 2026-11-02" \
  -H "Content-Type: application/json" \
  -d '{
  "loginId": "string"
}'
```

### Example response

```json
{
  "success": true,
  "data": {
    "apiKey": "ken_2bX9kq4LmR7tW3vY",
    "apiKeyId": "string",
    "workspaceId": 812,
    "email": "jane@example.com",
    "expiresAt": "2026-09-23T15:02:11Z"
  }
}
```

All resources: [/docs.md](/docs.md).
