Skip to main content

Hi Klaviyo Developers,

We're building a revenue attribution analytics platform using Klaviyo's API, and we're running into some challenges with the metrics aggregation and campaign data retrieval. We'd appreciate some guidance on proper API implementation.

Current Issues:

  1. Campaign API calls failing with invalid filter parameters:
 

Error: 400 Client Error: Bad Request

Detail: "Invalid filter provided."

Endpoint: /api/campaigns?filter=status+ne+%27draft%27

 

  1. Metrics Timeline API calls failing with incorrect data parameters:
 

Error: 400 Client Error: Bad Request

Detail: "'data' is not an allowed query parameter."

Endpoint: /api/metrics/timeline

 

Specific Questions:

  1. What's the correct filter syntax for retrieving non-draft campaigns with their revenue metrics?
  2. How should we structure the metrics timeline API request for revenue attribution data?
  3. What's the recommended approach for tracking attribution across different campaign types?

We're using Python with the requests library for API integration. Any code examples or best practices would be incredibly helpful!

Thanks in advance for your help!

As per the API docs: https://developers.klaviyo.com/en/reference/get_campaigns


A channel filter is required to list campaigns. Please provide either:
?filter=equals(messages.channel,'email') to list email campaigns, or
?filter=equals(messages.channel,'sms') to list SMS campaigns.
?filter=equals(messages.channel,'mobile_push') to list mobile push campaigns.

in your case to query for draft status it would look something like:

https://a.klaviyo.com/api/campaigns?fieldsecampaign-message]=&filter=equals%28status%2C%27draft%27%29

using: equals(status,'draft')