Skip to main content

CDPClient

The CDPClient class is the primary interface for interacting with the OpenCDP. It handles authentication, connection management, and optional dual-writing to Customer.io.

Initialization​

from cdp_client.client import CDPClient
from cdp_client.models import CDPConfig

config = CDPConfig(cdp_api_key="your_api_key")
client = CDPClient(config)

Parameters​

  • config (CDPConfig): A configuration object containing the API key and other settings.

Methods​

identify​

Identifies a user and sets their specific traits.

await client.identify(user_id: str, traits: Dict[str, Any])

Read more about identify


track​

Tracks a custom event with associated properties.

await client.track(user_id: str, event_name: str, properties: Dict[str, Any])

Read more about track


register_device​

Registers a device token for push notifications.

await client.register_device(
user_id: str,
device_id: str,
platform: str,
token: str,
attributes: Optional[Dict[str, Any]] = None
)

Read more about register_device


send_email​

Sends a transactional email.

await client.send_email(payload: EmailPayload)

Read more about send_email


send_push​

Sends a transactional push notification.

await client.send_push(payload: PushPayload)

Read more about send_push


send_sms​

Sends a transactional SMS.

await client.send_sms(payload: SmsPayload)

Read more about send_sms


close​

Closes the underlying HTTP client. This should be called before your application shuts down.

await client.close()