Skip to main content

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

  • 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 retry_after.
  • 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, 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 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_PROXY and NO_PROXY from the environment, as httpx does.
  • Fields the API leaves out are UNSET (kenso.types.UNSET), not None.
  • kenso.api and kenso.models are 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.90

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kenso 0.1.90
File Size Uploaded Provenance Actions
kenso-0.1.90.tar.gz 1.5 MB Without provenance Details for kenso-0.1.90.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kenso 0.1.90
File Interpreter ABI Platform Actions
kenso-0.1.90-py3-none-any.whl Python 3 none any Details for kenso-0.1.90-py3-none-any.whl

Total release size: 4.9 MB

Release files / kenso-0.1.90.tar.gz

Download URL kenso-0.1.90.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
4144e68883a0c8bc47ed17bdf1aee95f761385aaa1705a27ae81914a893ac29a
BLAKE2b-256 checksum
How to use checksums
2eab61b6447fdb14796d2913bc8f08adfcdf6bfac3451f88a099d849b47ee557
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.90-py3-none-any.whl

Download URL kenso-0.1.90-py3-none-any.whl
Size 3.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
3cb8c534bfea3e49d048ab3f5788b0b7b3b5c19493c3f9c5d3d4949b6e2ac4c0
BLAKE2b-256 checksum
How to use checksums
eb8a7479f1b7115597f211e774f823c6ee80783227389a9a8078320272945976
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.90

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page