I am working with SMS campaigns and using the aggregation API with the following filter:
"by": ["$message"]
In the API response, I received a dimension ID, which I initially assumed to be the campaign ID.
{
"dimensions": [
"RK77F6"
],
"measurements": {
"unique": [
1.0
],
"sum_value": [
0.0
],
"count": [
1.0
]
}
}
However, when I retrieve all my campaigns from the endpoint:
https://a.klaviyo.com/api/campaigns/
I noticed that the ID I received from the aggregation API is not the actual campaign ID(“01HTF4Q020NERWDJ0V0J39MQ35”) it campaign's relationship data.
{
"type": "campaign",
"id": "01HTF4Q020NERWDJ0V0J39MQ35",
"attributes": {
"name": "20240403 human >> sms20240402-dead-humir-interest-prom",
"status": "Sent",
"audiences": {
"included": [
"Tt28es",
"UFuWZy",
],
"excluded": [
"12345",
"23456"
]
},
"updated_at": "2024-04-02T18:59:49.085525+00:00",
"created_at": "2024-04-02T10:12:11.968942+00:00",
"send_time": "2024-04-02T09:00:00+00:00",
"send_strategy": {
"method": "static",
"options_static": {
"datetime": "2024-04-02T09:00:00+00:00",
"is_local": true,
"send_past_recipients_immediately": true
},
"options_throttled": null,
"options_sto": null
},
"send_options": {
"use_smart_sending": false
}
},
"relationships": {
"campaign-messages": {
"data": [
{
"type": "campaign-message",
"id": "RK77F6"
}
],
"links": {
"self": "https://a.klaviyo.com/api/campaigns/01HTF4Q020NERWDJ0V0J39MQ35/relationships/campaign-messages/",
"related": "https://a.klaviyo.com/api/campaigns/01HTF4Q020NERWDJ0V0J39MQ35/campaign-messages/"
}
},
"tags": {
"links": {
"self": "https://a.klaviyo.com/api/campaigns/01HTF4Q020NERWDJ0V0J39MQ35/relationships/tags/",
"related": "https://a.klaviyo.com/api/campaigns/01HTF4Q020NERWDJ0V0J39MQ35/tags/"
}
}
},
"links": {
"self": "https://a.klaviyo.com/api/campaigns/01HTF4Q020NERWDJ0V0J39MQ35/"
}
}
Based on my understanding, when I request the aggregation API with BY "$message"
, it should return the campaign ID. However, it seems to return a relationship to the campaign ID.
How can I retrieve the actual campaign ID from the results I get in the aggregation API?