Skip to main content
Solved

Help Needed: Implementing Revenue Attribution & Metrics Aggregation with Klaviyo API

  • February 21, 2025
  • 1 reply
  • 19 views

Forum|alt.badge.img

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!

Best answer by hani

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?fields[campaign-message]=&filter=equals%28status%2C%27draft%27%29

using: equals(status,'draft')

View original
Did this topic or the replies in the thread help you find an answer to your question?

1 reply

hani
Problem Solver I
Forum|alt.badge.img
  • 2025 Champion
  • 11 replies
  • Answer
  • February 21, 2025

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?fields[campaign-message]=&filter=equals%28status%2C%27draft%27%29

using: equals(status,'draft')