Skip to main content

Python SDK for the AHS CTI Platform

Project description

AHS CTI Python SDK

Python SDK for the AHS CTI Platform — initiate and control outbound calls via REST API.

Requirements: Python ≥ 3.9 · httpx ≥ 0.25


Installation

pip install ahs-cti-api-sdk

Quick Start

API-Key Authentication (recommended for server integrations)

from ahs_cti import CtiClient

with CtiClient(base_url="https://cti.example.com", api_key="ctsk_...", tenant_id=1) as client:
    result = client.calls.dial("+919876543210")
    print(result.call_id)   # save this for end_call

    end = client.calls.end_call(
        result.call_id,
        disposition="INTERESTED",
        list_comments="Customer wants a demo next week",
    )
    print(end.duration)

Credential Authentication

from ahs_cti import CtiClient

with CtiClient(base_url="https://cti.example.com", user_id="agent1", password="secret") as client:
    result = client.calls.dial("+919876543210", caller_id="AH2007C")

Async Client

import asyncio
from ahs_cti import AsyncCtiClient

async def main():
    async with AsyncCtiClient(base_url="https://cti.example.com", api_key="ctsk_...") as client:
        result = await client.calls.dial("+919876543210")
        print(result.call_id)

asyncio.run(main())

ClientConfig Reference

For full control over transport settings, use ClientConfig:

from ahs_cti import CtiClient, ClientConfig

config = ClientConfig(
    base_url="https://cti.example.com",
    timeout=15.0,
    verify_ssl=False,   # for self-signed certificates
    max_retries=5,
)

with CtiClient(config=config, api_key="ctsk_...") as client:
    result = client.calls.dial("+919876543210")
Parameter Type Default Description
base_url str required Root URL of the CTI platform
timeout float 30.0 Request timeout in seconds
verify_ssl bool True Set False for self-signed certs
max_retries int 3 Retry attempts on 5xx / network errors

Error Handling

from ahs_cti import CtiClient, CtiAuthError, CtiApiError, CtiRetryExhaustedError

with CtiClient(...) as client:
    try:
        result = client.calls.dial("+919876543210")
    except CtiAuthError:
        # Invalid or expired API key / credentials
        print("Authentication failed")
    except CtiRetryExhaustedError as e:
        # All retry attempts failed (5xx or network)
        print(f"Failed after {e.attempts} attempts: {e.last_exc}")
    except CtiApiError as e:
        # Any other API error (400, 404, 422 …)
        print(f"API error [{e.status_code}]: {e}")

Exception Hierarchy

CtiError
├── CtiAuthError          — 401 / login failure
└── CtiApiError           — 4xx / 5xx from the platform
    └── CtiRetryExhaustedError  — all retries exhausted

Retry Behaviour

The SDK automatically retries on 500, 502, 503, 504 responses and transient network errors (ConnectError, TimeoutException). Retries use exponential backoff:

Attempt Delay
1st (initial) none
2nd retry 2 s
3rd retry 4 s
4th retry 8 s

Set max_retries=0 in ClientConfig to disable retries entirely.


Self-Signed Certificates

Internal / staging servers often use self-signed TLS certificates. Pass verify_ssl=False:

client = CtiClient(base_url="https://192.168.1.10:8082", api_key="ctsk_...", verify_ssl=False)

Do not disable SSL verification in production.

Project details


Download files

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

Source Distribution

ahs_cti_api_sdk-0.1.0a3.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

ahs_cti_api_sdk-0.1.0a3-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file ahs_cti_api_sdk-0.1.0a3.tar.gz.

File metadata

  • Download URL: ahs_cti_api_sdk-0.1.0a3.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ahs_cti_api_sdk-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 0ea96fe349286a674f38ea7ff3d88bccfbefc6e0292b64bb37d148d6f88d0213
MD5 9fade826fd2cd6cc2fb57790f2d10e1e
BLAKE2b-256 e8ed2afa9a36e97e7ea7bf0df59159659a7b750c1274095a5ea0dca9b373d711

See more details on using hashes here.

Provenance

The following attestation bundles were made for ahs_cti_api_sdk-0.1.0a3.tar.gz:

Publisher: publish-python.yml on Achala-CTI/ahs-cti-api-sdks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ahs_cti_api_sdk-0.1.0a3-py3-none-any.whl.

File metadata

File hashes

Hashes for ahs_cti_api_sdk-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 c0cc2f2f34fd24e555bf562e5982b8197af0bb445dafed664b3e3ecbf9ca268c
MD5 1dd683c8a767635dbe7d1b4d1fd83a22
BLAKE2b-256 100dffc674eedae148cd1145f02a85ce8fee0e75e6b27b840da01cddd7fb827b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ahs_cti_api_sdk-0.1.0a3-py3-none-any.whl:

Publisher: publish-python.yml on Achala-CTI/ahs-cti-api-sdks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page