> 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: Poll a CLI login for its API key

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

One endpoint of [CLI login](/docs/api/cli-logins.md). Authentication, workspaces and errors: [/docs.md](/docs.md).

## 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"
  }
}
```
