Skip to main content
Contributor II
December 14, 2023
Solved

Using the latest API to get data about each email send

  • December 14, 2023
  • 2 replies
  • 204 views

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?

    This topic has been closed for replies.
    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.

    2 replies

    saulblumAnswer
    Klaviyo Employee
    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.

    aubAuthor
    Contributor II
    December 15, 2023

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