Hello @jason.brooks ,
Thank you for reaching out! You can include Universal Content Blocks in an email template via API by dynamically inserting the block’s ID into the html or mjml fields when creating the template. However, Klaviyo’s API doesn’t natively support referencing Universal Content Blocks directly in the payload. Instead, you need to fetch the block’s content, merge it into your template, and upload the final HTML.
For dynamic variables, you can use template tags ({{ variable_name }}) within the block content and pass data through campaign or flow parameters. If you need help implementing this efficiently, feel free to reach out.
Hi @MANSIR2094 - thanks for the suggestion. Do you know how to fetch the block’s content? I attempted to use the API, but it’s not returning any content for the block, just metadata. For example:
curl --request GET \
--url 'https://a.klaviyo.com/api/template-universal-content?=&page%5Bsize%5D=20' \
--header 'Authorization: Klaviyo-API-Key pk_xxx' \
--header 'Content-Type: application/json' \
--header 'accept: application/json' \
--header 'revision: 2024-10-15'
Response:
{
"data": "
{
"type": "template-universal-content",
"id": "xxx",
"attributes": {
"name": "Products",
"definition": {
"content_type": "block",
"type": "product",
"data": null
},
"created": "2025-02-06T12:52:13.422807+00:00",
"updated": "2025-02-06T12:52:16.070859+00:00",
"screenshot_status": "completed",
"screenshot_url": "https://klaviyo-template-thumbnails.s3.amazonaws.com/saved_content/xxx"
},
"links": {
"self": "https://a.klaviyo.com/api/template-universal-content/xxx/"
}
}
],
"links": {
"self": "https://a.klaviyo.com/api/template-universal-content?page%5Bsize%5D=20",
"next": null,
"prev": null
}
}
`data` appears to be null.
Hello @jason.brooks , sorry for late response …...
You're correct—the API currently returns only metadata and not the actual content of Universal Content Blocks. Unfortunately, Klaviyo’s API doesn’t provide a direct endpoint to fetch block content dynamically. The workaround is to manually extract the content from the Klaviyo editor and store it externally (e.g., in a database or CMS). Then, you can inject it into your template via API when needed.
For dynamic variables, you can use template tags ({{ variable_name }}
) within the block content and pass data through campaign or flow parameters. Let me know if you need help setting this up efficiently!
Hi @jason.brooks,
I believe that you can retrieve the actual content of Universal Content blocks via the Get Universal Content call, but the reason you’re not seeing it in the response body you sent over is because you used the GET request on a product block. Right now, you can only get the actual content of text and HTML blocks. But in those cases, you should be able to get that content, and retrieve it. Let me know if this doesn’t work when attempting to do this for text/html blocks!
-Byrne