Skip to main content
Solved

Using the latest API to get data about each email send

  • December 14, 2023
  • 2 replies
  • 122 views

Forum|alt.badge.img+2
  • Contributor II
  • 4 replies

I’m migrating from an old version of the API to the latest (2023-10-15). I would like to query for all of the individual email sends that have happened over a time period, including data about the recipients of the email. Previously, I was doing this in Ruby like this:

 

 metrics = Klaviyo::Metrics.get_metric_timeline(

   "TTP7r5",

   count: 50,

   since: 1.week.ago,

   sort: "desc"

 )

 

In the new API, I see that there is an endpoint for getting metrics, but it seems to only return data about the metric itself. And then there is the metric aggregates endpoint, but I don’t want an aggregate, I’d like the individual events. The only thing I’ve been able to figure out that this endpoint will return is counts of emails sent. Is there a way to get the individual email events now?

Best answer by saulblum

Get Events is your friend. You’d use a filter param such as:

equals(metric_id,"TTP7r5"),less-than(datetime,2023-12-14T00:00:00Z),greater-than(datetime,2023-12-07T00:00:00Z)

This will return the properties of each event.

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

2 replies

Forum|alt.badge.img+7
  • Klaviyo Employee
  • 169 replies
  • Answer
  • December 14, 2023

Get Events is your friend. You’d use a filter param such as:

equals(metric_id,"TTP7r5"),less-than(datetime,2023-12-14T00:00:00Z),greater-than(datetime,2023-12-07T00:00:00Z)

This will return the properties of each event.


Forum|alt.badge.img+2
  • Author
  • Contributor II
  • 4 replies
  • December 15, 2023

Thanks so much @saulblum! I’m not sure I would have ever figured that out.