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

# Kenso TypeScript SDK

> **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 https://ken.so/api/docs-feedback` 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 official TypeScript and JavaScript client for the [Kenso API](/docs). Every path, parameter, request body and response is typed from Kenso's public OpenAPI document, and the client handles the parts every integration otherwise writes by hand: the key, version and workspace headers, paging through lists, safe retries, typed errors and webhook signature checks. Writing Python? Use the [Kenso Python SDK](/docs/sdks/python).

## Install

```bash
npm install kenso-sdk
```

Node 20.3 or newer. The package is ESM and ships its own types. It is [`kenso-sdk` on npm](https://www.npmjs.com/package/kenso-sdk).

## Quickstart

Create an API key in Kenso under [Settings > API keys](https://app.ken.so/settings/api-keys). Keys start with `kenso_live_` or, in the older format, `ken_`.

```typescript
import { Kenso } from "kenso-sdk";

const kenso = new Kenso({ apiKey: "your_api_key", workspaceId: 812 });

const me = await kenso.GET("/v1/me");
const page = await kenso.GET("/v1/campaigns", { params: { query: { limit: 20 } } });
const campaign = await kenso.GET("/v1/campaigns/{campaignId}", { params: { path: { campaignId: 4518 } } });
```

`GET`, `POST`, `PUT`, `PATCH` and `DELETE` take a path written as in the [API reference](/docs/api) and an `init` with its `params.path`, `params.query` and `body`. Your editor completes the paths and checks every field. A call resolves to the response body (`{ success, data }`, and `pagination` on a list), or to `undefined` for a `204`.

`workspaceId` is sent as `X-Ken-Workspace-Id`. Leave it out when your key reaches only one workspace.

## Pagination

`paginate` requests a list page by page and yields every item. It accepts only the paths that page with a cursor, and the item type is the list's own.

```typescript
for await (const campaign of kenso.paginate("/v1/campaigns", { params: { query: { status: "active" } } })) {
  console.log(campaign.id, campaign.name);
}
```

It sends each page's `nextCursor` as `cursor` and stops when `hasMore` is false.

## Errors

A response with a 4xx or 5xx status rejects with a `KensoError`. Branch on the class, or on `code`, the API's stable `error.code`.

```typescript
import { KensoError, NotFoundError, RateLimitError } from "kenso-sdk";

try {
  await kenso.GET("/v1/campaigns/{campaignId}", { params: { path: { campaignId: 4518 } } });
} catch (error) {
  if (error instanceof NotFoundError) {
    // the campaign does not exist, or it is in a workspace this key cannot reach
  } else if (error instanceof RateLimitError) {
    console.log("retry in", error.retryAfter, "seconds");
  } else if (error instanceof KensoError) {
    console.log(error.status, error.code, error.message, error.requestId);
  } else {
    throw error;
  }
}
```

| Class | `error.code` |
| --- | --- |
| `ValidationError` | `validation_failed` (`details` names the field) |
| `WorkspaceRequiredError` | `workspace_required` |
| `VersionError` | `unsupported_version`, `version_retired` |
| `AuthenticationError` | `unauthenticated`, and any 401 |
| `PlanLimitError` | `plan_limit_reached` |
| `PermissionDeniedError` | `permission_denied`, `forbidden` |
| `NotFoundError` | `not_found` |
| `ConflictError` | `conflict`, `invalid_state` |
| `IdempotencyKeyReusedError` | `idempotency_key_reused` |
| `RateLimitError` | `rate_limited`, `quota_exceeded`, and any 429 |
| `ServiceUnavailableError` | `service_unavailable`, and any 503 |
| `InternalServerError` | `internal_error`, and any other 5xx |

A code with no class of its own rejects with the class for its status (a `409 import_running` is a `ConflictError`), or with `KensoError` itself; `ERROR_CODES` lists every code the reference names. Quote `requestId` when you write to support. A request that never gets a response rejects with `KensoConnectionError`, which keeps the failure as `cause`.

## Retries and idempotency

The client retries up to 2 times (`maxRetries`), waiting the `Retry-After` seconds when the response carries them and otherwise 0.5 s, then 1 s, with jitter. `timeoutMs` (60 seconds) ends one attempt, the download of its response included, and a timeout before the response starts counts as a connection failure. Raise it for a large export.

- `429` is always retried, because Kenso refused the request before running it. When `Retry-After` is over 60 seconds (a daily quota) it is not: the `RateLimitError` reaches you at once, with `retryAfter`.
- A `5xx`, a timeout or a connection failure is retried on a `GET`, and on a write only when you pass an `Idempotency-Key` on an operation [the API reference lists it for](/docs/idempotency#operations), because the key makes the repeat safe: when the first attempt did complete, Kenso answers with the response it stored and does not run the request again, and when it failed with a `5xx` it was not completed, so the retry runs it under the same key. Any other write is sent once: after a `503` on a reply send, for example, the message may already have gone out.

The client never makes up an `Idempotency-Key`, because a new key on each run would turn off Kenso's own check for a LinkedIn, WhatsApp or Instagram reply sent again shortly after with the same text. Pass your own in `params.header` on an operation the API reference lists it for, and the same one when your code runs a failed call again: Kenso answers the repeat instead of doing it twice, and the client's own retries reuse it. Kenso ignores the header on every other operation, so adding it there does not make a write safe to repeat, and the client does not retry it:

```typescript
await kenso.POST("/v1/threads/mark-all-read", {
  params: { header: { "Idempotency-Key": "mark-read-2026-11-15" } },
});
```

## Webhooks

`verifyWebhook` checks a delivery's signature and age, and returns the parsed payload. Pass the raw request body and the request headers, with the signing secret (`whsec_...`). It reads a webhook endpoint's `svix-id`, `svix-timestamp` and `svix-signature` headers, and the `webhook-id`, `webhook-timestamp` and `webhook-signature` headers an event subscription or a Studio webhook step sends.

```typescript
import { verifyWebhook, WebhookVerificationError } from "kenso-sdk";

try {
  const event = verifyWebhook({ payload: rawBody, headers: request.headers, secret: "whsec_your_signing_secret" });
  console.log(event.eventType);
} catch (error) {
  if (!(error instanceof WebhookVerificationError)) throw error;
  // answer 400
}
```

It rejects a delivery whose timestamp is more than 5 minutes from now (`toleranceSeconds`), and it rejects every delivery when the secret is empty, so an unset secret never verifies anything. Events and their payloads: [Webhooks](/docs/webhooks).

## Versions

The client sends `Ken-Version` with the API version it was generated against (`API_VERSION`), so a new API version never changes the shapes this package types. Pass `version` to send another. See [Versioning](/docs/versioning).

## Good to know

- Pass `signal` in `init` to cancel a call: `kenso.GET(path, { signal })`. It also ends a wait between retries.
- The types are generated on every build from the same OpenAPI document as the [API reference](/docs/api), so they match the reference of the day the version was built. `paths`, `components` and `operations` are exported for your own helpers: `components["schemas"]["Campaign"]`.
- Enum fields are typed as their known values. Kenso adds enum values over time, so handle a value you do not know in a `default` branch.

## More SDKs and guides

- [Kenso Python SDK](/docs/sdks/python.md)
- [Authentication](/docs/authentication.md)
- [Workspaces](/docs/workspaces.md)
- [Versioning](/docs/versioning.md)
- [Pagination](/docs/pagination.md)
- [Errors](/docs/errors.md)
- [Rate limits](/docs/rate-limits.md)
- [Idempotency](/docs/idempotency.md)
- [Webhooks](/docs/webhooks.md)
- [Changelog](/docs/changelog.md)
- [API reference](/docs.md)
