Hi there @ch1ptune,
Welcome to the Community! Happy to help!
I would recommend double checking our API documentation on this step , however, the issue might be that you have multiple id inserts in your code! This is the example code they give in dev portal doc below.
curl --request POST \
--url https://a.klaviyo.com/api/campaign-message-assign-template/ \
--header 'Authorization: Klaviyo-API-Key your-private-api-key' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'revision: 2023-10-15' \
--data '
{
"data": {
"type": "campaign-message",
"relationships": {
"template": {
"data": {
"type": "template",
"id": "RipRmi"
}
}
}
}
}
'
Hope this helps!
-Taylor
I have the same issue, Here is my body code:
{
"data": {
"type": "campaign-message",
"relationships": {
"template": {
"data": {
"type": "template",
"id": "WqhfLq"
}
}
},
"id": "01HHW4RNTRX45AJB6W76AKGV7B"
}
}
And the error: The operation failed with an error. T400] 'template' is not an allowed relation on the campaign-messages resource.
Hi there @hectoragusin,
I would recommend checking out the documentation I linked above as it would be helpful to see the correct request. However, looking at your code it seems that you have an additional ID. The only ID you need is the first ID with six letters.
Hope this helps!
-Taylor
Also having the same issues. @Taylor Tarpley per the documentation, the ID of the campaign is required, in addition to the ID of the template. https://developers.klaviyo.com/en/reference/create_campaign_message_assign_template
Without the ID of the campaign, how would the API know which campaign to assign the template to?
In the sample documentation, when you fill out the data with the API explorer, the body looks identical to what we all have:
{
"data": {
"type": "campaign-message",
"relationships": {
"template": {
"data": {
"type": "template",
"id": "RipRmi"
}
}
},
"id": "4564654654654"
}
}
@ch1ptune by chance, are you trying to use make.com?
I find that using the “Klaviyo” app on make.com for a generic API request causes this error. However using Postman to test the endpoint, and using the standard HTTP API Request app on make.com do get a valid response on this endpoint.
Also, make sure you’re passing the campaign-message ID, and not the campaign ID.