Skip to main content

Hello,

I am trying to create a campaign via the API but I don’t see how to update the template after it’s being assigned to the campaign.

This is what I am doing:

  1. Create a campaign using https://developers.klaviyo.com/en/reference/create_campaign
  2. Assign a message template to the campaign using https://developers.klaviyo.com/en/reference/create_campaign_message_assign_template
  3. Here I get a new template ID and a campaign ID

 

Now how can I modify the template assigned to this campaign without modifying the original template?

 

Hi @Jukka!

 

It is possible to edit HTML templates via API, but it depends on exactly what you’re trying to do. If you modify the template with template ID referenced by the campaign message, that would modify the campaign template only, and not the original template.

 

Best,

Brian


Hi @Brian Turcotte that’s exactly what I am trying to do but the API return 404 Not found with this template ID.

 

If I try to modify the original template_id it works but if I try to modify the template_id I receive during the creating of campaign message (still via the API) it just give me a 404 not found.

 

This is the Template: (Created during assignation)

 

This is when I try to update it:

 


Hi @Jukka!

I’ve been informed that this should have been fixed - are you still experiencing this issue?

Best,

Brian


I just ran into this same exact issue today as well. Getting a 404 when I PATCH the template - GET for the same template ID works just fine.

 

 


Hi @kalenjordan!

I’ll check on this with our API team to see if this happening to others.

 

Best,
Brian


This is definitely still happening. I just created a campaign and assigned an existing template to it. It then returned with a new template id (for the cloned template assigned to the campaign message).

When I make a GET request to get this new template data, everything is ok.

However, if I try to update the template html for example, it returns a 404. Its possible you guys fixed that one endpoint but forgot the other.


@Brian Turcotte do you know if this is fixed?


Any update on this? I am having the same problem as @aguerrero. The GET request returns the template data, but PATCH returns with:

Template with id 'QUrd7f' does not exist

 

If there are no immediate plans to fix this, is there a different way to achieve the same result? I basically have a template with custom variables that I am updating on a per campaign basis. It’s a “question of the day” email so each day’s campaign has a different question in it.


In case anyone else is dealing with this same thing, here’s a workaround that worked for me:

I created a web feed (https://help.klaviyo.com/hc/en-us/articles/115005258768), then used custom variables in the template (like {{ feeds.MyFeedName.fieldName }} ).

Then I created a function on my site that runs once a day that does the following:

  1. Creates a campaign (https://developers.klaviyo.com/en/reference/create_campaign)
  2. Assigns the template to the campaign (https://developers.klaviyo.com/en/reference/create_campaign_message_assign_template)
  3. Sends the campaign (https://developers.klaviyo.com/en/reference/create_campaign_send_job)

This causes the system to use the web feed to populate the variables and properly sends the finalized email campaign.


@Brian Turcotte 

This appears to still be a reproducable error.

Just today I can create a campaign via the API, assign a template to the new campaign’s Campaign Message, and receive a (cloned) template ID back.

The API shows the cloned template in the response for Getting all Templates

The API shows the cloned template in the response to Get that one, cloned Template by ID

When attempting the PATCH to update this cloned template by ID, the response is a 404 error that the template “does not exist”. (It very much does, though)

 

Here’s a Call ID for a valid GET request for this template: 

97118f00-fbc7-48cf-a808-2ab1d0314623

 

Here’s a call ID for a failed PATH request for the same template: 

4bfdf297-8473-4bc4-adce-5dd2be8dbd6d

 

Can this please be remediated?

 

GET success response

PATCH error response

 


Reply