Skip to main content
Solved

Include campaign messages

  • September 11, 2023
  • 2 replies
  • 44 views

Forum|alt.badge.img+1
  • Contributor I
  • 1 reply

Hi,

I’m migrating our calls to the v2 API, previously we used the endpoint /api/v1/campaigns which includes the subject of the campaign and all of its related attributes.

 

It seems, it has been migrated to a relationship called “campaign-messages”, except I can’t find in your API how to directly embed them in the /api/campaigns call.

 

I don’t want to be forced to call /api/campaigns/{id}/campaign-messages/ on each campaign, which is not perfect for performance reasons.

 

Thank you

Best answer by Kim Strauch

This is where relationships come into play. You can use an `?include=campaign-messages` query parameter to include details about the related campaign message(s) for each campaign. Each campaign will include its related campaign message(s) under the relationships key, and you can see the full data for each campaign is included under the `included` key.

 

In this way, you can get the details about the campaign and its message in one call. Check out more details in our Guide on Relationships. 

 

Here’s an example of this in action:

 

 

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

2 replies

Kim Strauch
Klaviyo Employee
Forum|alt.badge.img+9
  • Klaviyo Employee
  • 91 replies
  • Answer
  • September 11, 2023

This is where relationships come into play. You can use an `?include=campaign-messages` query parameter to include details about the related campaign message(s) for each campaign. Each campaign will include its related campaign message(s) under the relationships key, and you can see the full data for each campaign is included under the `included` key.

 

In this way, you can get the details about the campaign and its message in one call. Check out more details in our Guide on Relationships. 

 

Here’s an example of this in action:

 

 


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 1 reply
  • September 13, 2023

Thank you, it’s the best answer!