Kenso Python SDK
The official Python client for the Kenso API. It has one typed function per API operation, generated from Kenso's public OpenAPI document, and it 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.
pip install kenso
Python 3.10 or newer. This version is sync only.
Quickstart
Create an API key in Kenso under Settings > Integrations > API Keys. Keys start with kenso_live_ or, in the older format, ken_.
from kenso import Kenso
from kenso.api.campaigns import campaigns_list
from kenso.api.me import me_get
with Kenso("your_api_key", workspace_id=812) as kenso:
me = me_get.sync(client=kenso)
page = campaigns_list.sync(client=kenso, limit=20)
Every operation is a module under kenso.api.<section> with a sync function that returns the parsed response, and a sync_detailed function that also returns the status code and headers. Models are in kenso.models. Pass the Kenso client as client=.
workspace_id is sent as X-Ken-Workspace-Id. Leave it out when your key reaches only one workspace.
Pagination
paginate calls a list function page by page and yields every item. The arguments after the function are the function's own, and a type checker checks them.
from kenso import paginate
for campaign in paginate(campaigns_list.sync, client=kenso, status="active"):
print(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 raises a KensoError. Branch on the class, or on code, the API's stable error.code.
from kenso import KensoError, NotFoundError, RateLimitError
from kenso.api.campaigns import campaigns_get
try:
campaign = campaigns_get.sync(4518, client=kenso)
except NotFoundError:
campaign = None
except RateLimitError as error:
print("retry in", error.retry_after, "seconds")
except KensoError as error:
print(error.status, error.code, error.message, error.request_id)
| 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 raises the class for its status (a 409 import_running is a ConflictError), or KensoError itself; kenso.ERROR_CODES lists every code the reference names. Quote request_id when you write to support. A request that never gets a response raises KensoConnectionError.
Retries and idempotency
The client retries up to 2 times (max_retries), waiting the Retry-After seconds when the response carries them and otherwise 0.5 s, then 1 s, with jitter.
429is always retried, because Kenso refused the request before running it. WhenRetry-Afteris over 60 seconds (a daily quota) it is not: theRateLimitErrorreaches you at once, withretry_after.- A
5xx, a timeout or a connection failure is retried on aGET, and on a write only when you pass anIdempotency-Keyon an operation the API reference lists it for, 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 a5xxit was not completed, so the retry runs it under the same key. Any other write is sent once: after a503on 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 as idempotency_key= to a function whose 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:
from kenso.api.threads import threads_mark_all_read
threads_mark_all_read.sync(client=kenso, idempotency_key="mark-read-2026-11-15")
Webhooks
verify_webhook 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.
from kenso import WebhookVerificationError, verify_webhook
try:
event = verify_webhook(raw_body, request_headers, "whsec_your_signing_secret")
except WebhookVerificationError:
event = None # answer 400
It rejects a delivery whose timestamp is more than 5 minutes from now (tolerance_seconds), and it rejects every delivery when the secret is empty, so an unset secret never verifies anything.
Versions
The client sends Ken-Version with the API version it was generated against (kenso.API_VERSION), so a new API version never changes the shapes this package parses. Pass version= to send another.
Good to know
- Enum fields are plain
str. Kenso adds enum values over time, and a closed enum would reject a value this package has not seen. Each field's docstring lists the values known when the package was built. - The client uses
HTTPS_PROXY,HTTP_PROXYandNO_PROXYfrom the environment, as httpx does. - Fields the API leaves out are
UNSET(kenso.types.UNSET), notNone. kenso.apiandkenso.modelsare generated on every build from the same OpenAPI document as the API reference, so they match the reference of the day the version was built.
Metadata
Release files for kenso 0.1.84
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kenso-0.1.84.tar.gz | 1.4 MB | Without provenance | Details for kenso-0.1.84.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kenso-0.1.84-py3-none-any.whl | Python 3 | none | any | Details for kenso-0.1.84-py3-none-any.whl |
Total release size: 4.6 MB
Release files / kenso-0.1.84.tar.gz
| Download URL | kenso-0.1.84.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8853b096f7f51e4765503335bb774c7860147c46d94deaaa2070157d5a4c794
|
|
BLAKE2b-256 checksum How to use checksums |
d23ab06c203537e1f9d5beaaab299480c204feab7880c7cb883a495de621f45d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / kenso-0.1.84-py3-none-any.whl
| Download URL | kenso-0.1.84-py3-none-any.whl |
|---|---|
| Size | 3.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e78964c72ca3ceda7800d8a7b012bbc6e21ec0e9e4a7459d67439a2c4c0f85d
|
|
BLAKE2b-256 checksum How to use checksums |
5dbd57b7e366e15cc611812db1b6540cffca3b37f44d8b929415857303b46bd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for kenso 0.1.84
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.