Skip to main content
Solved

Creating a campaign with API (where does template go?)


Forum|alt.badge.img+1

Hey guys,

We would love to be able to be able to create email campaigns and attach templates to the campaigns using the Klaviyo API.

My understanding is that we would have to add the html code to create a template first and then use the templateID to create a Campaign.

However, the latest documentation I’m looking at (v2023-02-22), it doesn’t seem like the ‘Create Campaign’ POST accepts a templateID as an optional field.

We were wondering if there was a way to create an email campaign with a template with the current API, if not, would we be able to do this in the near future?

Best answer by chloe.strange

Hi @khaledkb

Thanks for being a part of our community! To be able to create email campaigns and attach templates to the campaigns using the Klaviyo API, you would need to make the campaign, and then use this endpoint to assign a template to it. This documentation will provide you with the details needed: https://developers.klaviyo.com/en/reference/create_campaign_message_assign_template. I hope this helps. Let me know if you have other questions. 

~Chloe

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

4 replies

Forum|alt.badge.img
  • Contributor I
  • 1 reply
  • March 27, 2023

Following


chloe.strange
Community Manager
Forum|alt.badge.img+42
  • Community Manager
  • 430 replies
  • Answer
  • March 27, 2023

Hi @khaledkb

Thanks for being a part of our community! To be able to create email campaigns and attach templates to the campaigns using the Klaviyo API, you would need to make the campaign, and then use this endpoint to assign a template to it. This documentation will provide you with the details needed: https://developers.klaviyo.com/en/reference/create_campaign_message_assign_template. I hope this helps. Let me know if you have other questions. 

~Chloe


Forum|alt.badge.img
  • Contributor I
  • 1 reply
  • April 25, 2023

Hi @chloe.strange 

I saw the api documentation, could you please tell where can I get the message ID in the payload ? for this api https://developers.klaviyo.com/en/reference/create_campaign_message_assign_template

Regards,

Rohan


  • Contributor I
  • 1 reply
  • September 19, 2024

Hey Rohan, 
I just figured it out, the Message ID is returned in the response of Create Campaign as 
 

"relationships": {

"campaign-messages": {

"data": [

{

"type": "campaign-message",

"id": "122344"

}

]

Regards,
Umar