Skip to content

Client

The main entry point for the SDK. Both clients expose the same resource namespaces — the only difference is sync vs async.

ChatwootClient

ChatwootClient(
    base_url: str, api_token: str, timeout: float = 30.0
)

Synchronous Chatwoot API client.

This is the main entry point for interacting with the Chatwoot API. All API operations are organized into resource-specific namespaces.

Examples:

>>> client = ChatwootClient(
...     base_url="https://app.chatwoot.com",
...     api_token="your_api_token_here"
... )
...
>>> # Fetch user profile
>>> profile = client.profile.get()
>>> print(profile.name)
...
>>> # List conversations
>>> conversations = client.conversations.list(account_id=1, status="open")
...
>>> # Send a message
>>> message = client.messages.create(
...     account_id=1,
...     conversation_id=42,
...     content="Hello from SDK!"
... )
...
>>> # Use as context manager for automatic cleanup
>>> with ChatwootClient(base_url="", api_token="") as client:
...     profile = client.profile.get()

Initialize Chatwoot client.

Parameters:

Name Type Description Default
base_url str

Chatwoot instance URL (e.g., "https://app.chatwoot.com")

required
api_token str

User API access token from profile settings. Get it from: Settings → Profile Settings → Access Token

required
timeout float

Request timeout in seconds (default: 30.0)

30.0

Raises:

Type Description
ChatwootAuthError

If authentication fails on first request

close

close() -> None

Close the HTTP client and release resources.

Call this when you're done with the client to properly clean up connections.


AsyncChatwootClient

AsyncChatwootClient(
    base_url: str, api_token: str, timeout: float = 30.0
)

Asynchronous Chatwoot API client.

This is the async version of the Chatwoot client, using async/await patterns for non-blocking I/O operations.

Examples:

>>> import asyncio
>>>
>>> async def main():
...     client = AsyncChatwootClient(
...         base_url="https://app.chatwoot.com",
...         api_token="your_api_token_here"
...     )
...
...     # Fetch user profile
...     profile = await client.profile.get()
...     print(profile.name)
...
...     # List conversations
...     conversations = await client.conversations.list(
...         account_id=1,
...         status="open"
...     )
...
...     await client.aclose()
...
>>> # Or use as async context manager
>>> async def main():
...     async with AsyncChatwootClient(base_url="", api_token="") as client:
...         profile = await client.profile.get()

Initialize async Chatwoot client.

Parameters:

Name Type Description Default
base_url str

Chatwoot instance URL (e.g., "https://app.chatwoot.com")

required
api_token str

User API access token from profile settings

required
timeout float

Request timeout in seconds (default: 30.0)

30.0

aclose async

aclose() -> None

Close the async HTTP client and release resources.

Call this when you're done with the client to properly clean up connections.