N
Novu7d ago
Endy_

Cannot update the email layout through API

I am trying to update the email layout using
PUT /v1/workflows
PUT /v1/workflows
to update
steps.template._layoutId
steps.template._layoutId
but it always falls back to the default layout. The same thing happens when I create a new workflow via the API. Is there a way to specify a different layout through the API?
3 Replies
Pawan Jain
Pawan Jain7d ago
@Endy_ You will need to use mongodb id of layout as _layoutId
Endy_
Endy_OP6d ago
Yes. I’m using the MongoDB layout _id from the
/v1/layouts
/v1/layouts
data._id
data._id
but it still isn’t working For example, the current email layout is set to “A.” I’m passing the template layout ID for “B,” but it still falls back to the default layout.
workflow = {
"name": template_name,
"steps": [
{
"template": {
"type": "email",
"subject": subject,
"preheader": display_header,
"content": html,
"contentType": "customHtml",
"_layoutId": layout_id,
},
}
],
}

response = requests.put(
url=f"{NOVU_WORKFLOW_URL}/{workflow_id}",
json=workflow,
headers=headers,
)
workflow = {
"name": template_name,
"steps": [
{
"template": {
"type": "email",
"subject": subject,
"preheader": display_header,
"content": html,
"contentType": "customHtml",
"_layoutId": layout_id,
},
}
],
}

response = requests.put(
url=f"{NOVU_WORKFLOW_URL}/{workflow_id}",
json=workflow,
headers=headers,
)
Oops. I found the issue. It shouldn’t be _layoutId, it should be layoutId. Sorry for the confusion.
Pawan Jain
Pawan Jain6d ago
thanks for the update @Endy_

Did you find this page helpful?