Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

kasookoo-server-sdk (Python)

Python SDK for Kasookoo's server-side API. Server-only — it holds your organization's secret key, which must never reach a browser.

PyPI package

This SDK only creates call intents — it doesn't place calls itself. That half happens on the frontend, in either of two places:

  • kasookoo-sdk's initSipCall({ phoneNumber, intentId, clientSecret }) (readme.io: Calls) — for a custom call UI you build yourself.
  • kasookoo-click-to-call-widget (readme.io docs)'s <kasookoo-dialer> — a drop-in call button/dial pad. It doesn't call initSipCall() directly itself; instead, it fetches an intent on its own from a route you give it (intentEndpoint, passed to its init()), then dials with what that route returns.

Either way, the shape is the same: your frontend asks your backend for a call intent, your backend creates it with this SDK, and your route must respond with the two fields the frontend needs to actually place the call: intent_id and client_secret. Nothing else you put in that response matters to either integration.

Install

pip install kasookoo-server-sdk

Usage

import os
from kasookoo_server_sdk import Kasookoo

kasookoo = Kasookoo(secret_key=os.environ["KASOOKOO_SECRET_KEY"])

intent = kasookoo.call_intents.create(
    subject="Website visitor",  # must match the `subject` your frontend passes to init() — see below
    phone_number="+18005551234",
    max_duration_seconds=300,  # optional
)

call_intents.create() sends your secret key to Kasookoo and returns:

@dataclass
class CallIntent:
    intent_id: str        # unique id for this call intent
    client_secret: str    # short-lived secret for the frontend — hand this off, never the org secret key
    subject: str
    phone_number: str
    expires_in: int       # seconds until client_secret expires if unused
    max_duration_seconds: int
    status: str            # "requires_dial", or any other status string the API returns

Respond from your route with at least intent_id and client_secret — that's the whole contract, whichever frontend integration is consuming it (see above): kasookoo-sdk's initSipCall(), or kasookoo-click-to-call-widget's intentEndpoint. Your org's secret key never needs to leave the server.

Keep subject in sync with the frontend's init()

The subject you pass here must be the exact same value the frontend passed to init()kasookoo-sdk's KasookooClient.init({ subject }) or kasookoo-click-to-call-widget's KasookooClickToCall.init({ subject }). Kasookoo checks the two against each other and rejects the call intent if they don't match (surfaced as a KasookooApiError — see Error handling below), so always pass subject here explicitly, kept identical to whatever your frontend's init() call used — don't assume it's implied or optional just because the frontend already sent one.

Configuration

Option Type Default Description
secret_key str required Your organization's secret key.
base_url str https://sdk-test.kasookoo.ai API base URL.
timeout_seconds float 10.0 Request timeout in seconds.

All three are keyword-only arguments to Kasookoo(...).

Error handling

from kasookoo_server_sdk import Kasookoo, KasookooApiError, KasookooConfigError

try:
    kasookoo.call_intents.create(subject="Visitor", phone_number="+18005551234")
except KasookooApiError as err:
    # err.status  — HTTP status code (0 for network errors/timeouts)
    # err.code    — API-provided error code, if any
    # err.details — full parsed error response, if any
    ...
except KasookooConfigError:
    # invalid SDK usage — missing/empty field, bad config — raised before any network call
    ...

Example

import os

from kasookoo_server_sdk import Kasookoo, KasookooApiError

kasookoo = Kasookoo(
    secret_key=os.environ["KASOOKOO_SECRET_KEY"],
    base_url=os.environ.get("KASOOKOO_BASE_URL", "https://sdk-test.kasookoo.ai"),
)


def main() -> None:
    try:
        intent = kasookoo.call_intents.create(
            subject="Website visitor",
            phone_number="+18005551234",
            max_duration_seconds=300,
        )
        print("Call intent created:", intent)
        # Hand `intent.client_secret` (and `intent.intent_id`) to the frontend —
        # never the org's secret key itself.
    except KasookooApiError as err:
        print(f"Kasookoo API error [{err.status}]{f' {err.code}' if err.code else ''}: {err}")


if __name__ == "__main__":
    main()

Requirements

  • Python 3.9+. No runtime dependencies.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kasookoo_server_sdk-0.1.0b0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kasookoo_server_sdk-0.1.0b0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file kasookoo_server_sdk-0.1.0b0.tar.gz.

File metadata

  • Download URL: kasookoo_server_sdk-0.1.0b0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.4

File hashes

Hashes for kasookoo_server_sdk-0.1.0b0.tar.gz
Algorithm Hash digest
SHA256 eac1008429d430417507cd1c620f5dbf1da9817215659252b0a627b262eba246
MD5 640db909bd29fc919e932fb19d5d1604
BLAKE2b-256 3759df72805ce36abeb8b842998744c7880c19f970d1558dec59b5338f7d0003

See more details on using hashes here.

File details

Details for the file kasookoo_server_sdk-0.1.0b0-py3-none-any.whl.

File metadata

File hashes

Hashes for kasookoo_server_sdk-0.1.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe8f9bd1d608c6ec7f178decad344047676c2f182decf04fbde498bfef6c446d
MD5 05346d86bf06fac8d7c26ef5ec4881cf
BLAKE2b-256 822f8cb374c47d606675da1b63fdbe9dc28d5d803767d024a735e54415121b19

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0b0 This release

2 files

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