The Klaviyo Python SDK provides a convenient way to interact with the Klaviyo API for marketing automation, customer data management, and more. It offers full coverage of the Klaviyo API, including profiles, events, campaigns, flows, and more. The library is actively maintained with monthly releases, often aligned with new Klaviyo API revisions.
pip install klaviyo-apiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Klaviyo API client using a private API key from an environment variable and make a simple request to retrieve account information. Ensure your API key has the necessary scopes (e.g., 'Accounts' read scope) for the endpoints you wish to use.
Remove `anonymous_id` from any profile creation or update payloads. Use other identifiers like `email`, `phone_number`, or `external_id`.
Always use a Private API Key for server-side SDK interactions. Verify that the generated Private API Key has all the necessary scopes (e.g., 'Profiles' write, 'Events' write, etc.) for the API calls you intend to make.
Implement exponential backoff and retry logic for API calls. Consult the Klaviyo API documentation for specific rate limits per endpoint. Distribute requests over time or use bulk endpoints where available.
Double-check your `KLAVIYO_PRIVATE_API_KEY` value. Ensure it's a Private API Key, not a Public API Key. Go to Klaviyo Settings -> API Keys to generate a new key with appropriate scopes for your needs.
Before sending data to Klaviyo API, ensure all values in your payload are JSON serializable. Convert `UUID` objects to strings (`str(my_uuid_object)`) and `datetime` objects to ISO 8601 strings.
No dependency data recorded yet.