Skip to main content
Solved

Potential Bug in Metric Aggregates API

  • October 1, 2025
  • 2 replies
  • 64 views

Larry
Contributor I
Forum|alt.badge.img+2

Hi Team,

 

Looking at the following documentation:

https://developers.klaviyo.com/en/docs/using_the_query_metric_aggregates_endpoint#unique-opens-unique_opens-for-all-sent-messages

The  Metric Aggregates API is used with a GROUP BY `$message`. According to the documentation:

 

> The results will be grouped by message ID (using "by": ["$message"] as an attribute).

 

However, when doing some local tests using my own data, it seems to be that the campaign ID is returned, and not the message ID. This means, either the document is wrong, or the API response is wrong.

 

Would it be possible to get some clarity on this? Knowing which ID is being returned is crucial in our data pipelines.

 

All the best,

Louis
 

Best answer by Byrne C

Back with an update! 

For legacy campaigns (not the new Omnichannel campaigns feature), $message will give the campaign id  depending on send channel and A/B test state.

  • Email and push will always populate the EmailCampaign id in the $message field
  • SMS will populate the EmailCampaign id there if it's an A/B test
  • SMS will populate the ScheduledMessage id if it isn't an A/B test

For Omnichannel campaigns, all channels will now use the following:

  • $message will be populated by the OmniMessage Id

For these reasons, we recommend using the Query Campaign Values endpoint when you’re trying to gather campaign data like this. Let me know if this helps.

2 replies

Byrne C
Community Manager
Forum|alt.badge.img+27
  • Community Manager
  • October 3, 2025

Hi ​@Larry,

Just reached out to our team that writes these API docs. I’ll get back to you as soon as possible with more information on this article, and to let you know what the source of truth here should be.


Byrne C
Community Manager
Forum|alt.badge.img+27
  • Community Manager
  • Answer
  • October 7, 2025

Back with an update! 

For legacy campaigns (not the new Omnichannel campaigns feature), $message will give the campaign id  depending on send channel and A/B test state.

  • Email and push will always populate the EmailCampaign id in the $message field
  • SMS will populate the EmailCampaign id there if it's an A/B test
  • SMS will populate the ScheduledMessage id if it isn't an A/B test

For Omnichannel campaigns, all channels will now use the following:

  • $message will be populated by the OmniMessage Id

For these reasons, we recommend using the Query Campaign Values endpoint when you’re trying to gather campaign data like this. Let me know if this helps.