Skip to content

This page is available as Markdown at https://developers.klaviyo.com/en/v2026-07-15/reference/templates.md. An index of every page is at https://developers.klaviyo.com/llms.txt.

KlaviyoKlaviyoDevelopers
v2026-07-15

You're reading the reference for API revision 2026-07-15. The latest revision is 2026-10-15. See this page in the latest revision.

Templates

Before you begin

Check out our general API overview before getting started with specific endpoints.

Use the Templates API to seamlessly create, update, and manage email templates programmatically. Whether you use fully custom HTML, hybrid templates compatible with Klaviyo’s drag-and-drop editor, or native drag-and-drop templates, the Templates API offers flexibility for tailored email experiences.

Use cases

The Templates API supports the following use cases:

  • Get, create, and manage templates.
  • Create and update HTML, Hybrid and native drag-and-drop templates.
  • Render a template with the given template ID and context.
  • Clone a template.
  • Convert an HTML template into a drag-and-drop template.

Data model

A template has the following:

  • id

    The template ID.

  • attributes

    • name (required)

      The name of the template.

    • editor_type (required)

      The type of editor. Supported values:

      • CODE — custom HTML templates.
      • USER_DRAGGABLE — hybrid templates edited as HTML in the API but compatible with the drag-and-drop editor.
      • SYSTEM_DRAGGABLE — native drag-and-drop templates backed by a structured definition object.
    • html

      The HTML contents of the template. Used for CODE and USER_DRAGGABLE templates. Not used when editor_type is SYSTEM_DRAGGABLE (use definition instead).

    • text

      The plaintext version of the template.

    • definition

      Structured drag-and-drop template content (body, styles, and related metadata) for SYSTEM_DRAGGABLE templates. Required when creating a SYSTEM_DRAGGABLE template. On Get Templates, the definition attribute is omitted by default; pass additional-fields[template]=definition to include it in list responses. Get Template includes definition for SYSTEM_DRAGGABLE templates. For the exact JSON shape, refer to the endpoint schemas in the API reference.

    • amp

      The AMP version of the template. Requires an enabled AMP email to access in-app. Not used when editor_type is SYSTEM_DRAGGABLE.

    • created

      The timestamp of when the template was last created.

    • updated

      The timestamp of when the metric was last updated.

Create a template

When creating a template with the Create Template endpoint, your request payload must include at least a template name and an editor type.

  • For CODE or USER_DRAGGABLE templates, include the appropriate HTML-related fields as described in the API reference.
  • For SYSTEM_DRAGGABLE templates, include a definition to define the template content (body, styles, rows, columns, blocks etc).

Create a HTML template

The example below is a CODE template. It utilizes dynamic variables including first_name, last_name, discount_code, and order_total to tailor the content for each recipient. These variables enable seamless personalization when rendering the template.

Request
{
   "data": {
       "type": "template",
       "attributes": {
           "name": "Personalized Discount Email",
           "editor_type": "CODE",
           "html": "<html>\n  <head>\n    <meta content=\"width=device-width, initial-scale=1.0\" name=\"viewport\" />\n    <title>Special Discount for You</title>\n    <style>\n      body {\n        background-color: #f6f6f6;\n        font-family: sans-serif;\n        margin: 20px;\n      }\n      .main {\n        background: #ffffff;\n        border-radius: 3px;\n        width: 100%;\n      }\n      .container {\n        margin: 0 auto !important;\n        width: 600px;\n      }\n      .wrapper {\n        box-sizing: border-box;\n        padding: 15px;\n      }\n      table {\n        width: 100%;\n      }\n    </style>\n  </head>\n  <body>\n    <div class=\"container\">\n      <table class=\"main\">\n        <tr>\n          <td class=\"wrapper\">\n            <p>Hello {{ first_name }} {{ last_name }},</p>\n            <p>Thank you for your order of ${{ order_total }}!</p>\n            <p>As a thank you, here’s a special discount code just for you: <strong>{{ discount_code }}</strong></p>\n            <p>Use it at checkout to enjoy your discount.</p>\n          </td>\n        </tr>\n        <tr>\n          <td class=\"wrapper\">{% unsubscribe %}</td>\n        </tr>\n      </table>\n    </div>\n  </body>\n</html>"
       }
   }
}
Response
{
    "data": {
        "type": "template",
        "id": "TuG2Zd",
        "attributes": {
            "name": "Personalized Discount Email",
            "editor_type": "CODE",
            "html": "<html>\n<head>\n<meta content=\"width=device-width, initial-scale=1.0\" name=\"viewport\"/>\n<title>Special Discount for You</title>\n<style>body {\n    background-color: #f6f6f6;\n    font-family: sans-serif;\n    margin: 20px\n    }\n.main {\n    background: #fff;\n    border-radius: 3px;\n    width: 100%\n    }\n.container {\n    margin: 0 auto !important;\n    width: 600px\n    }\n.wrapper {\n    box-sizing: border-box;\n    padding: 15px\n    }\ntable {\n    width: 100%\n    }</style></head>\n<body>\n<div class=\"container\">\n<table class=\"main\">\n<tr>\n<td class=\"wrapper\">\n<p>Hello {{ first_name }} {{ last_name }},</p>\n<p>Thank you for your order of ${{ order_total }}!</p>\n<p>As a thank you, here’s a special discount code just for you: <strong>{{ discount_code }}</strong></p>\n<p>Use it at checkout to enjoy your discount.</p>\n</td>\n</tr>\n<tr>\n<td class=\"wrapper\">{% unsubscribe %}</td>\n</tr>\n</table>\n</div>\n</body>\n</html>",
            "text": null,
            "amp": null,
            "created": "2025-02-05T19:12:51.599729+00:00",
            "updated": "2025-02-05T19:12:51.599758+00:00"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/templates/TuG2Zd/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/templates"
    }
}

Create a drag-and-drop template

The example below is a SYSTEM_DRAGGABLE template. The definition in the request below matches the definition object in the Get Template response for SYSTEM_DRAGGABLE templates (see Get a drag-and-drop template under Fetch templates).

Request
{
   "data": {
       "type": "template",
       "attributes": {
           "name": "Spring welcome (DnD)",
           "editor_type": "SYSTEM_DRAGGABLE",
           "text": "Hi there, thanks for subscribing.",
           "definition": {
               "body": {
                   "properties": {},
                   "styles": {},
                   "sections": [
                       {
                           "content_type": "section",
                           "type": "section",
                           "data": {
                               "properties": {},
                               "display_options": {},
                               "styles": {}
                           },
                           "rows": [
                               {
                                   "data": {
                                       "styles": {
                                           "column_layout": "1-column-full-width"
                                       }
                                   },
                                   "columns": [
                                       {
                                           "data": {},
                                           "blocks": [
                                               {
                                                   "content_type": "block",
                                                   "type": "text",
                                                   "data": {
                                                       "content": "<p>Hi {{ person.first_name|default:'there' }}, thanks for subscribing.</p>",
                                                       "display_options": {},
                                                       "styles": {}
                                                   }
                                               }
                                           ]
                                       }
                                   ]
                               }
                           ]
                       }
                   ]
               },
               "styles": [
                   {"style_type": "base-styles", "properties": {}, "styles": {}},
                   {"style_type": "text-styles", "styles": {}},
                   {"style_type": "link-styles", "styles": {}},
                   {"style_type": "heading-1-styles", "styles": {}},
                   {"style_type": "heading-2-styles", "styles": {}},
                   {"style_type": "heading-3-styles", "styles": {}},
                   {"style_type": "heading-4-styles", "styles": {}},
                   {"style_type": "mobile-styles", "properties": {}, "styles": {}}
               ]
           }
       }
   }
}
Response
{
    "data": {
        "type": "template",
        "id": "V2kMn9",
        "attributes": {
            "name": "Spring welcome (DnD)",
            "editor_type": "SYSTEM_DRAGGABLE",
            "html": "<html><head><meta charset=\"utf-8\"/><title>Spring welcome</title></head><body><p>Hi {{ person.first_name|default:'there' }}, thanks for subscribing.</p></body></html>",
            "text": "Hi there, thanks for subscribing.",
            "definition": {
                "body": {
                    "properties": {},
                    "styles": {},
                    "sections": [
                        {
                            "content_type": "section",
                            "type": "section",
                            "data": {
                                "properties": {},
                                "display_options": {},
                                "styles": {}
                            },
                            "rows": [
                                {
                                    "data": {
                                        "styles": {
                                            "column_layout": "1-column-full-width"
                                        }
                                    },
                                    "columns": [
                                        {
                                            "data": {},
                                            "blocks": [
                                                {
                                                    "content_type": "block",
                                                    "type": "text",
                                                    "data": {
                                                        "content": "<p>Hi {{ person.first_name|default:'there' }}, thanks for subscribing.</p>",
                                                        "display_options": {},
                                                        "styles": {}
                                                    }
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                "styles": [
                    {"style_type": "base-styles", "properties": {}, "styles": {}},
                    {"style_type": "text-styles", "styles": {}},
                    {"style_type": "link-styles", "styles": {}},
                    {"style_type": "heading-1-styles", "styles": {}},
                    {"style_type": "heading-2-styles", "styles": {}},
                    {"style_type": "heading-3-styles", "styles": {}},
                    {"style_type": "heading-4-styles", "styles": {}},
                    {"style_type": "mobile-styles", "properties": {}, "styles": {}}
                ]
            },
            "amp": null,
            "created": "2026-04-10T15:30:00+00:00",
            "updated": "2026-04-10T15:30:00+00:00"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/templates/V2kMn9/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/templates"
    }
}

Render a template

Render a template with a given template ID and context attribute (a JSON object with the context the email template is rendered with). A call to Render Template returns the AMP, HTML, and plain text versions of the email template.

Here’s the request and response for rendering the template we created above:

Request
{
   "data": {
       "type": "template",
       "id": "TuG2Zd",
       "attributes": {
           "context": {
               "first_name": "John",
               "last_name": "Doe",
               "discount_code": "WELCOME10",
               "order_total": 49.99
           }
       }
   }
}
Response
{
    "data": {
        "type": "template",
        "id": "TuG2Zd",
        "attributes": {
            "name": "Personalized Discount Email",
            "editor_type": "CODE",
            "html": "<html>\n<head>\n<meta content=\"width=device-width, initial-scale=1.0\" name=\"viewport\"/>\n<title>Special Discount for You</title>\n<style>body {\n    background-color: #f6f6f6;\n    font-family: sans-serif;\n    margin: 20px\n    }\n.main {\n    background: #fff;\n    border-radius: 3px;\n    width: 100%\n    }\n.container {\n    margin: 0 auto !important;\n    width: 600px\n    }\n.wrapper {\n    box-sizing: border-box;\n    padding: 15px\n    }\ntable {\n    width: 100%\n    }</style></head>\n<body>\n<div class=\"container\">\n<table class=\"main\">\n<tr>\n<td class=\"wrapper\">\n<p>Hello John Doe,</p>\n<p>Thank you for your order of $49.99!</p>\n<p>As a thank you, here’s a special discount code just for you: <strong>WELCOME10</strong></p>\n<p>Use it at checkout to enjoy your discount.</p>\n</td>\n</tr>\n<tr>\n<td class=\"wrapper\"><a class=\"unsubscribe-link\" href=\"[unsubscribe_tag]\">Unsubscribe</a></td>\n</tr>\n</table>\n</div>\n</body>\n</html>",
            "text": null,
            "amp": null,
            "created": "2025-02-05T19:12:52+00:00",
            "updated": "2025-02-05T19:12:52+00:00"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/templates/TuG2Zd/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/template-render"
    }
}

Clone a template

To clone the template we created and rendered above, your request payload for Clone Template should look like the following:

Request
{
   "data": {
       "type": "template",
       "id": "TuG2Zd",
       "attributes": {
           "name": "Clone of Personalized Discount Email"
       }
   }
}
Response
{
    "data": {
        "type": "template",
        "id": "XRPRey",
        "attributes": {
            "name": "Clone of Personalized Discount Email",
            "editor_type": "CODE",
            "html": "<html>\n<head>\n<meta content=\"width=device-width, initial-scale=1.0\" name=\"viewport\"/>\n<title>Special Discount for You</title>\n<style>body {\n    background-color: #f6f6f6;\n    font-family: sans-serif;\n    margin: 20px\n    }\n.main {\n    background: #fff;\n    border-radius: 3px;\n    width: 100%\n    }\n.container {\n    margin: 0 auto !important;\n    width: 600px\n    }\n.wrapper {\n    box-sizing: border-box;\n    padding: 15px\n    }\ntable {\n    width: 100%\n    }</style></head>\n<body>\n<div class=\"container\">\n<table class=\"main\">\n<tr>\n<td class=\"wrapper\">\n<p>Hello {{ first_name }} {{ last_name }},</p>\n<p>Thank you for your order of ${{ order_total }}!</p>\n<p>As a thank you, here’s a special discount code just for you: <strong>{{ discount_code }}</strong></p>\n<p>Use it at checkout to enjoy your discount.</p>\n</td>\n</tr>\n<tr>\n<td class=\"wrapper\">{% unsubscribe %}</td>\n</tr>\n</table>\n</div>\n</body>\n</html>",
            "text": null,
            "amp": null,
            "created": "2025-02-05T19:35:59.752156+00:00",
            "updated": "2025-02-05T19:35:59.832098+00:00"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/templates/XRPRey/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/template-clone"
    }
}

Convert an HTML template to drag-and-drop

Convert a CODE template into a new SYSTEM_DRAGGABLE template with Create Template Conversion Job. The conversion runs asynchronously, so the request returns a job instead of the new template. The source template does not change. The new template is named after the source template, followed by (converted).

Starting a conversion requires an account on a paid plan. Requests from other accounts return a 403 error. Any account can still get and list its conversion jobs.

Only CODE templates can be converted. If the source template is a different editor type, the request returns a 400 error. If the source template does not exist, the request returns a 404 error.

Start a conversion

To convert the HTML template we created above, set it as the source-template relationship:

Request
{
   "data": {
       "type": "template-conversion-job",
       "relationships": {
           "source-template": {
               "data": {
                   "type": "template",
                   "id": "TuG2Zd"
               }
           }
       }
   }
}
Response
{
    "data": {
        "type": "template-conversion-job",
        "id": "XyZ123-01JA8ZQ5M0V3T7N6K2H4B9C1DE",
        "attributes": {
            "status": "queued",
            "created_at": "2026-10-15T14:00:00+00:00",
            "error": null,
            "completed_at": null
        },
        "relationships": {
            "source-template": {
                "data": {
                    "type": "template",
                    "id": "TuG2Zd"
                }
            }
        },
        "links": {
            "self": "https://a.klaviyo.com/api/template-conversion-jobs/XyZ123-01JA8ZQ5M0V3T7N6K2H4B9C1DE/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/template-conversion-jobs/"
    }
}

Check the job status

Poll Get Template Conversion Job until the job's status is complete or failed. A job has one of these statuses:

  • queued — the job is waiting to start.
  • processing — the conversion is running.
  • complete — the new template exists. Its ID is in the converted-template relationship.
  • failed — the conversion did not finish. The error attribute says why.

The converted-template relationship is only included when the status is complete.

Request
curl --request GET \
     --url https://a.klaviyo.com/api/template-conversion-jobs/XyZ123-01JA8ZQ5M0V3T7N6K2H4B9C1DE \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/vnd.api+json' \
     --header 'revision: 2026-10-15'
Response
{
    "data": {
        "type": "template-conversion-job",
        "id": "XyZ123-01JA8ZQ5M0V3T7N6K2H4B9C1DE",
        "attributes": {
            "status": "complete",
            "created_at": "2026-10-15T14:00:00+00:00",
            "error": null,
            "completed_at": "2026-10-15T14:03:00+00:00"
        },
        "relationships": {
            "source-template": {
                "data": {
                    "type": "template",
                    "id": "TuG2Zd"
                }
            },
            "converted-template": {
                "data": {
                    "type": "template",
                    "id": "Rw4pLk"
                }
            }
        },
        "links": {
            "self": "https://a.klaviyo.com/api/template-conversion-jobs/XyZ123-01JA8ZQ5M0V3T7N6K2H4B9C1DE/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/template-conversion-jobs/XyZ123-01JA8ZQ5M0V3T7N6K2H4B9C1DE/"
    }
}

Get the new template with Get Template, using the ID from the converted-template relationship.

List conversion jobs

Get Template Conversion Jobs returns the conversion jobs created in the last 7 days, newest first. This endpoint does not support filtering or pagination.

Manage templates

Update and delete templates with the Update Template and Delete Template endpoints, respectively.

Fetch templates

All template types are returned when making a Get Template or Get Templates request.

For SYSTEM_DRAGGABLE templates, the structured definition attribute behaves differently by endpoint:

To include definition on each item in a list response, add ?additional-fields[template]=definition to the URL. Learn more in the guide to additional fields. CODE and USER_DRAGGABLE templates do not use definition.

Get an HTML template

Request
curl --request GET \
     --url https://a.klaviyo.com/api/templates/U7bDHv \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/vnd.api+json' \
     --header 'revision: 2026-04-15'
Response
{
    "data": {
        "type": "template",
        "id": "U7bDHv",
        "attributes": {
            "name": "Clone of Monthly Newsletter Template",
            "editor_type": "CODE",
            "html": "<html><head></head><body>Template HTML content</body></html>",
            "text": null,
            "amp": null,
            "created": "2025-02-04T20:39:18+00:00",
            "updated": "2025-02-04T20:39:18+00:00"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/templates/U7bDHv/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/templates/U7bDHv"
    }
}

Get a drag-and-drop template

For SYSTEM_DRAGGABLE templates, the response includes a structured definition and a rendered html preview. The definition object matches the payload in the Create a drag-and-drop template example earlier in this overview (under Create a template).

Request
curl --request GET \
     --url https://a.klaviyo.com/api/templates/Qw8tRm \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/vnd.api+json' \
     --header 'revision: 2026-04-15'
Response
{
    "data": {
        "type": "template",
        "id": "Qw8tRm",
        "attributes": {
            "name": "Spring welcome (DnD)",
            "editor_type": "SYSTEM_DRAGGABLE",
            "html": "<html><head><meta charset=\"utf-8\"/><title>Spring welcome</title></head><body><p>Hi {{ person.first_name|default:'there' }}, thanks for subscribing.</p></body></html>",
            "text": "Hi there, thanks for subscribing.",
            "definition": {
                "body": {
                    "properties": {},
                    "styles": {},
                    "sections": [
                        {
                            "content_type": "section",
                            "type": "section",
                            "data": {
                                "properties": {},
                                "display_options": {},
                                "styles": {}
                            },
                            "rows": [
                                {
                                    "data": {
                                        "styles": {
                                            "column_layout": "1-column-full-width"
                                        }
                                    },
                                    "columns": [
                                        {
                                            "data": {},
                                            "blocks": [
                                                {
                                                    "content_type": "block",
                                                    "type": "text",
                                                    "data": {
                                                        "content": "<p>Hi {{ person.first_name|default:'there' }}, thanks for subscribing.</p>",
                                                        "display_options": {},
                                                        "styles": {}
                                                    }
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                "styles": [
                    {"style_type": "base-styles", "properties": {}, "styles": {}},
                    {"style_type": "text-styles", "styles": {}},
                    {"style_type": "link-styles", "styles": {}},
                    {"style_type": "heading-1-styles", "styles": {}},
                    {"style_type": "heading-2-styles", "styles": {}},
                    {"style_type": "heading-3-styles", "styles": {}},
                    {"style_type": "heading-4-styles", "styles": {}},
                    {"style_type": "mobile-styles", "properties": {}, "styles": {}}
                ]
            },
            "amp": null,
            "created": "2026-04-10T14:22:00+00:00",
            "updated": "2026-04-10T14:22:00+00:00"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/templates/Qw8tRm/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/templates/Qw8tRm"
    }
}

Querying templates

Querying templates with the Templates API can help you achieve many use cases, such as sorting templates by the date they were created. Check out the supported query parameters below and test them with our latest Postman collection. Note that support for given operators and fields is endpoint-specific. Review the API reference documentation for more information on allowed fields and query operators.

Parameter Description Query example
filter Retrieve a subset of templates, e.g., templates that have been created within a given time frame. Learn about the filter query parameter. GET /api/templates?filter=greater-than(created,"2023-06-05T12:30:00+00:00")
sort Sort templates, e.g., by date created in ascending order (oldest to newest). Learn about the sort query parameter. GET /api/templates?sort=created
fields Request for only specified template data, e.g., name. Learn more about sparse fieldsets. GET /api/templates?fields[template]=name
additional-fields[template] Include the definition attribute for each template in Get Templates responses (needed for SYSTEM_DRAGGABLE templates). Learn more about additional fields. GET /api/templates?additional-fields[template]=definition

Additional resources

Endpoints

Templates

Universal Content

Before you begin

Check out our general API overview before getting started with specific endpoints.

Marketers can utilize universal content to create reusable blocks of content that repeatedly appear in email marketing. Once saved as universal content, blocks can be added to any email from Klaviyo's email template editor. Any changes saved to a universal content block will propagate to all email templates using that block. Use our Universal Content API to streamline the process of creating universal content that can be added to Klaviyo email templates.

Use cases

  • Seamlessly create universal content blocks from HTML blocks present throughout your app and help documentation (e.g., product blocks and images) for repeated use in email templates.
  • Retrieve universal content blocks by content type.
  • Update existing universal content blocks across email templates.
  • Delete universal content blocks.

Data model

A universal content block has the following structure:

  • id

    The ID of the universal content block.

  • attributes

    • name

      The name of the universal content block.

    • definition

      • content_type

        The type of universal content: block, or (as of the 2026-10-15 revision) section.

      • type

        The type of universal content within the block (button, horizontal_rule, drop_shadow, html, image, spacer, or text). As of the 2026-10-15 revision, also supports coupon, header, product, review, social, split, table, and video.

      • data

        • content

          The text or HTML content shown in the universal content block.

        • styles

          A set of style options to apply to the text block (see Supported styles).

        • display_options

          An object of fields that map to display options that can be set in the template editor (See Supported display options).

    • created

      The timestamp of when the universal content block was created.

    • updated

      The timestamp of when the universal content block was last updated.

    • screenshot_status

      The status of a screenshot for generating the universal content block's thumbnail.

    • screenshot_url

      A URL of the universal content block's screenshot.

Creating a universal content block

Use the Create Universal Content endpoint to add a universal content block to the customer's account. Text blocks have some default padding applied; if you are creating a text block with HTML contents, you will likely want to set the block's padding to 0 (See supported styles).

Button
curl --request POST \
     --url https://a.klaviyo.com/api/template-universal-content \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/vnd.api+json' \
     --header 'content-type: application/vnd.api+json' \
     --header 'revision: 2025-04-15' \
     --data '
{
    "data": {
        "type": "template-universal-content",
        "attributes": {
            "name": "Button block name",
            "definition": {
                "content_type": "block",
                "type": "button",
                "data": {
                    "content": "SHOP NOW",
                    "properties": {
                        "href": "http://www.klaviyo.com"
                    },
                    "styles": {
                        "background_color": "#1155CC"
                    },
                    "display_options": {
                        "show_on": "desktop"
                    }
                }
            }
        }
    }
}
'
Divider
curl --request POST \
     --url https://a.klaviyo.com/api/template-universal-content \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/vnd.api+json' \
     --header 'content-type: application/vnd.api+json' \
     --header 'revision: 2025-04-15' \
     --data '
{
    "data": {
        "type": "template-universal-content",
        "attributes": {
            "name": "Divider block name",
            "definition": {
                "content_type": "block",
                "type": "horizontal_rule",
                "data": {
                    "styles": {
                        "block_padding_bottom": 30,
                        "block_padding_left": 30,
                        "block_padding_right": 30,
                        "block_padding_top": 30,
                        "border_color": "#D25959",
                        "border_style": "solid",
                        "border_width": 1
                    },
                    "display_options": {
                        "show_on": "desktop"
                    }
                }
            }
        }
    }
}
'
Drop shadow
curl --request POST \
     --url https://a.klaviyo.com/api/template-universal-content/ \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'revision: 2025-04-15' \
     --data '
{
    "data": {
        "type": "template-universal-content",
        "attributes": {
            "name": "Drop shadow block name",
            "definition": {
                "content_type": "block",
                "type": "drop_shadow",
                "data": {
                    "styles": {
                        "block_background_color": "#FFFFFF",
                        "shadow_color": "dark"
                    },
                    "display_options": {
                        "show_on": "desktop"
                    }
                }
            }
        }
    }
}
'
HTML
curl --request POST \
     --url https://a.klaviyo.com/api/template-universal-content/ \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'revision: 2025-04-15' \
     --data '
{
    "data": {
        "type": "template-universal-content",
        "attributes": {
            "name": "HTML block name",
            "definition": {
                "content_type": "block",
                "type": "html",
                "data": {
                    "content": "INSERT_HTML_CONTENT_HERE",
                    "display_options": {}
                }
            }
        }
    }
}
'
Image
curl --request POST \
     --url https://a.klaviyo.com/api/template-universal-content \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/vnd.api+json' \
     --header 'content-type: application/vnd.api+json' \
     --header 'revision: 2025-04-15' \
     --data '
{
    "data": {
        "type": "template-universal-content",
        "attributes": {
            "name": "Image block name",
            "definition": {
                "content_type": "block",
                "type": "image",
                "data": {
                    "properties": {
                        "dynamic": false,
                        "alt_text": "Our bestselling blue t-shirt.",
                        "asset_id": "193828341"
                    },
                    "styles": {
                        "background_color": "#0057FF",
                        "block_background_color": "#00FF5D",
                        "height": 1000,
                        "width": 888
                    },
                    "display_options": {}
                }
            }
        }
    }
}
'
Spacer
curl --request POST \
     --url https://a.klaviyo.com/api/template-universal-content/ \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'revision: 2025-04-15' \
     --data '
{
    "data": {
        "type": "template-universal-content",
        "attributes": {
            "name": "Spacer block name",
            "definition": {
                "content_type": "block",
                "type": "spacer",
                "data": {
                    "styles": {
                        "background_color": "#0057FF"
                    },
                    "display_options": {
                        "show_on": "desktop"
                    }
                }
            }
        }
    }
}
'
Text
curl --request POST \
     --url https://a.klaviyo.com/api/template-universal-content/ \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'revision: 2025-04-15' \
     --data '
{
    "data": {
        "type": "template-universal-content",
        "attributes": {
            "name": "Text block name",
            "definition": {
                "content_type": "block",
                "type": "text",
                "data": {
                    "content": "INSERT_TEXT_OR_HTML_CONTENT_HERE",
                    "styles": {
                        "block_padding_bottom": 0,
                        "block_padding_top": 0,
                        "block_padding_right": 0,
                        "block_padding_left": 0
                    },
                    "display_options": {}
                }
            }
        }
    }
}
'
Referencing web feed content

You can use the Create Universal Content endpoint to create a universal content block that references a web feed to support use cases with dynamic content, such as including lists of product reviews, blog posts, or user-generated content.

  1. Make a call to Create Web Feed to create a web feed. The example request below creates a web feed of product reviews:
Request
curl --request POST \
     --url https://a.klaviyo.com/api/web-feeds \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/vnd.api+json' \
     --header 'content-type: application/vnd.api+json' \
     --header 'revision: 2025-04-15' \
     --data '
{
  "data": {
    "type": "web-feed",
    "attributes": {
      "name": "REVIEWS",
      "url": "https://test.com/file/product_reviews.json",
      "request_method": "get",
      "content_type": "json"
    }
  }
}
'

Here's what the feed looks like in JSON:

json

{
  "productId": "123456",
  "reviews": [
    {
      "reviewId": "r001",
      "rating": 5,
      "title": "Absolutely love it!",
      "body": "This product exceeded my expectations. Highly recommend to anyone looking for quality and value.",
      "author": "Jane D.",
      "date": "2025-07-10"
    },
    {
      "reviewId": "r002",
      "rating": 4,
      "title": "Very good, just a small issue",
      "body": "Overall great product, though shipping took a bit longer than expected. Still happy with the purchase.",
      "author": "Carlos M.",
      "date": "2025-06-29"
    },
    {
      "reviewId": "r003",
      "rating": 5,
      "title": "Perfect in every way",
      "body": "Works flawlessly and looks even better in person. Would definitely buy again.",
      "author": "Aisha T.",
      "date": "2025-07-01"
    }
  ]
}

As shown above, this web feed contains an array of objects, reviews, where each object represents a product review that contains review details, such as rating and body. These values can be referenced in a universal content block.

  1. Make a call to Create Universal Content to create an HTML universal content block that uses Django variables to fetch and display dynamic content from your web feed. The example below uses the content_repeat object to include the path to the web feed data (repeat_for) and the alias of the repeated item (item_alias) to use in the block's contents.
Request
curl --location 'https://a.klaviyo.com/api/template-universal-content' \
--header 'Authorization: Klaviyo-API-Key YOUR-KEY-HERE' \
--header 'accept: application/vnd.api+json' \
--header 'content-type: application/vnd.api+json' \
--header 'revision: 2025-04-15'
--data '
{
  "data": {
    "type": "template-universal-content",
    "attributes": {
      "definition": {
        "content_type": "block",
        "type": "html",
        "data": {
          "display_options": {
            "content_repeat": {
              "repeat_for": "feeds.REVIEWS.reviews",
              "item_alias": "review_article"
            }
          },
          "content": "  <div class=\"review\" style=\"margin-bottom: 20px;\">     <h3>Title: {{ review_article.title }}</h3>     <p><strong>Rating:</strong> {{ review_article.rating }} star{% if review_article.rating != 1 %}s{% endif %}</p>     <p>{{ review_article.body }}</p>     <p><em>— {{ review_article.author }}, {{ review_article.date }}</em></p>   </div>"
        }
      },
      "name": "All Reviews Universal Content Block"
    }
  }
}
'

Now you can drive value for your customers by creating web feeds for customers with universal content they can quickly drop into their templates.

Retrieving universal content blocks

The Get All Universal Content endpoint is useful for retrieving information such as block content and styling for all universal content blocks.

Use the Get Universal Content endpoint to fetch this information for a specified universal content block ID.

Below are examples of how a universal content block might look in your query response:

Button
{
    "data": {
        "type": "template-universal-content",
        "id": "8d342cbfe638405b91ff49950af1765c",
        "attributes": {
            "name": "Button Test",
            "definition": {
                "content_type": "block",
                "type": "button",
                "data": {
                    "content": "SHOP NOW",
                    "properties": {
                        "href": "http://www.klaviyo.com"
                    },
                    "display_options": {
                        "show_on": "desktop"
                    },
                    "styles": {
                        "background_color": "#1155CC"
                    }
                }
            },
            "created": "2025-05-09T20:12:28.323582+00:00",
            "updated": "2025-05-09T20:13:34.988260+00:00",
            "screenshot_status": "completed",
            "screenshot_url": "https://example.com/screenshots/8d342cbfe638405b91ff49950af1765c.png"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/template-universal-content/8d342cbfe638405b91ff49950af1765c/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/template-universal-content/8d342cbfe638405b91ff49950af1765c"
    }
}
Divider
{
    "data": {
        "type": "template-universal-content",
        "id": "bab3d71d688e483f98946d9b603ef87f",
        "attributes": {
            "name": "Divider block name",
            "definition": {
                "content_type": "block",
                "type": "horizontal_rule",
                "data": {
                    "display_options": {
                        "show_on": "desktop"
                    },
                    "styles": {
                        "block_padding_bottom": 30,
                        "block_padding_left": 30,
                        "block_padding_right": 30,
                        "block_padding_top": 30,
                        "border_color": "#D25959",
                        "border_style": "solid",
                        "border_width": 1
                    }
                }
            },
            "created": "2025-05-09T20:08:37.692442+00:00",
            "updated": "2025-05-09T20:08:47.543512+00:00",
            "screenshot_status": "completed",
            "screenshot_url": "https://example.com/screenshots/bab3d71d688e483f98946d9b603ef87f.png"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/template-universal-content/bab3d71d688e483f98946d9b603ef87f/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/template-universal-content/bab3d71d688e483f98946d9b603ef87f"
    }
}
Drop shadow
{
    "data": {
        "type": "template-universal-content",
        "id": "6f29ee607b524e1d9f1ab6c2043ea571",
        "attributes": {
            "name": "Drop shadow block name",
            "definition": {
                "content_type": "block",
                "type": "drop_shadow",
                "data": {
                    "display_options": {
                        "show_on": "desktop"
                    },
                    "styles": {
                        "block_background_color": "#FFFFFF",
                        "shadow_color": "dark"
                    }
                }
            },
            "created": "2025-05-09T20:20:18.168163+00:00",
            "updated": "2025-05-09T20:21:03.261814+00:00",
            "screenshot_status": "completed",
            "screenshot_url": "https://example.com/screenshots/6f29ee607b524e1d9f1ab6c2043ea571.png"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/template-universal-content/6f29ee607b524e1d9f1ab6c2043ea571/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/template-universal-content/6f29ee607b524e1d9f1ab6c2043ea571"
    }
}
HTML
{
    "data": {
        "type": "template-universal-content",
        "id": "4fc3b48d7f404d3ebd579b0d1c9ffe5c",
        "attributes": {
            "name": "HTML block name",
            "definition": {
                "content_type": "block",
                "type": "html",
                "data": {
                    "content": "TEXT_OR_HTML_CONTENT_HERE",
                    "styles": {},
                    "display_options": {}
                }
            },
            "created": "2024-05-23T14:26:36.530847+00:00",
            "updated": "2024-05-23T14:26:39.010728+00:00",
            "screenshot_status": "completed",
            "screenshot_url": "https://klaviyo-template-thumbnails.s3.amazonaws.com/saved_content/4fc3b48d7f404d3ebd579b0d1c9ffe5c"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/template-universal-content/4fc3b48d7f404d3ebd579b0d1c9ffe5c/"
        }
    }
}
Image
{
    "data": {
        "type": "template-universal-content",
        "id": "a4c6d1b33d014b2a99e55f887fb7d17e",
        "attributes": {
            "name": "Image block name",
            "definition": {
                "content_type": "block",
                "type": "image",
                "data": {
                    "properties": {
                        "dynamic": false,
                        "alt_text": "Our famous, blue t-shirt.",
                        "asset_id": "193828341",
                        "href": "",
                        "src": "https://d3k81ch9hvuctc.cloudfront.net/company/TWQgMA/images/fe6cb7cd-6cde-49d7-8c13-0439bd9b5c8c.jpeg"
                    },
                    "display_options": {},
                    "styles": {
                        "background_color": "#0057FF",
                        "height": 1000,
                        "width": 888
                    }
                }
            },
            "created": "2025-05-09T20:25:34.272695+00:00",
            "updated": "2025-05-09T20:36:29.224052+00:00",
            "screenshot_status": "completed",
            "screenshot_url": "https://example.com/screenshots/a4c6d1b33d014b2a99e55f887fb7d17e.png"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/template-universal-content/a4c6d1b33d014b2a99e55f887fb7d17e/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/template-universal-content/a4c6d1b33d014b2a99e55f887fb7d17e"
    }
}
Spacer
{
    "data": {
        "type": "template-universal-content",
        "id": "99bea286e260495285dd4197710c871c",
        "attributes": {
            "name": "Spacer block name",
            "definition": {
                "content_type": "block",
                "type": "spacer",
                "data": {
                    "display_options": {
                        "show_on": "desktop"
                    },
                    "styles": {
                        "background_color": "#0057FF"
                    }
                }
            },
            "created": "2025-05-09T20:54:02.543016+00:00",
            "updated": "2025-05-09T20:54:09.947621+00:00",
            "screenshot_status": "completed",
            "screenshot_url": "https://example.com/screenshots/99bea286e260495285dd4197710c871c.png"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/template-universal-content/99bea286e260495285dd4197710c871c/"
        }
    },
    "links": {
        "self": "https://a.klaviyo.com/api/template-universal-content/99bea286e260495285dd4197710c871c"
    }
}
Text
{
    "data": {
        "type": "template-universal-content",
        "id": "4fc3b48d7f404d3ebd579b0d1c9ffe5c",
        "attributes": {
            "name": "Text block name",
            "definition": {
                "content_type": "block",
                "type": "text",
                "data": {
                    "content": "TEXT_OR_HTML_CONTENT_HERE",
                    "styles": {
                        "block_padding_left": 0,
                        "block_padding_right": 0,
                        "block_padding_top": 0,
                        "block_padding_bottom": 0
                    },
                    "display_options": {}
                }
            },
            "created": "2024-05-23T14:26:36.530847+00:00",
            "updated": "2024-05-23T14:26:39.010728+00:00",
            "screenshot_status": "completed",
            "screenshot_url": "https://klaviyo-template-thumbnails.s3.amazonaws.com/saved_content/4fc3b48d7f404d3ebd579b0d1c9ffe5c"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/template-universal-content/4fc3b48d7f404d3ebd579b0d1c9ffe5c/"
        }
    }
}

Querying templates

Querying universal content blocks with the Universal Content API can help you achieve many use cases, such as retrieving HTML for a specific block. Check out the supported query parameters below and test them with our latest Postman collection. Note that support for given operators and fields is endpoint-specific. Review the API reference documentation for more information on allowed fields and query operators.

Parameter Description Query example
filter Retrieve a subset of universal content blocks, e.g., blocks that have been created within a given time frame. Learn about the filter query parameter. GET /api/template-universal-content?filter=greater-than(created,"2023-06-05T12:30:00+00:00")
sort Sort universal content blocks, e.g., by date created in ascending order (oldest to newest). Learn about the sort query parameter. GET /api/template-universal-content?sort=created
fields Request for only specified universal content block data, e.g., HTML content. Learn more about sparse fieldsets. GET /api/template-universal-content?fields[template-universal-content]=definition.data.content

Updating a universal content block

Updating a universal content block with Update Universal Content will visually update all templates using the universal content (see example below).

The example request below updates an HTML block:

Request
curl --request PATCH \
     --url https://a.klaviyo.com/api/template-universal-content/4fc3b48d7f404d3ebd579b0d1c9ffe5c/ \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'revision: 2024-10-15' \
     --data '
{
  "data": {
    "type": "template-universal-content",
    "id": "4fc3b48d7f404d3ebd579b0d1c9ffe5c",
    "attributes": {
      "definition": {
        "content_type": "block",
        "type": "html",
        "data": {
          "content": "UPDATED_HTML_FOR_THE_BLOCK_HERE",
          "styles": {},
          "display_options": {}
        }
      }
    }
  }
}
'
Response
{
    "data": {
        "type": "template-universal-content",
        "id": "4fc3b48d7f404d3ebd579b0d1c9ffe5c",
        "attributes": {
            "name": "NAME",
            "definition": {
                "content_type": "block",
                "type": "html",
                "data": {
                    "content": "UPDATED_HTML_FOR_THE_BLOCK_HERE",
                    "styles": {},
                    "display_options": {}
                }
            },
            "created": "2024-05-23T14:26:36.530847+00:00",
            "updated": "2024-05-23T14:26:39.010728+00:00",
            "screenshot_status": "completed",
            "screenshot_url": "https://klaviyo-template-thumbnails.s3.amazonaws.com/saved_content/4fc3b48d7f404d3ebd579b0d1c9ffe5c"
        },
        "links": {
            "self": "https://a.klaviyo.com/api/template-universal-content/4fc3b48d7f404d3ebd579b0d1c9ffe5c/"
        }
    }
}

Deleting a universal content block

Use the Delete Universal Content endpoint to delete a universal content block, given a universal content block ID. Once the block has been deleted, any templates using the universal content block will no longer all be attached to a universal content block instance. The templates will visually appear unchanged after the deletion of the content block, i.e., deleted blocks will be turned into a regular, non-universal block.

Supported styles

View the table below for the available style options for text blocks.

Style name Description
block_background_color Background color of the block (e.g., "#ffffff")
block_border_color Border color of the block (e.g., "#000000").
block_border_style Border style (e.g., "solid"). Supports CSS border-style values.
block_padding_left Amount (in pixels) of left padding on the block. Defaults to 18.
block_padding_right Amount (in pixels) of right padding on the block. Defaults to 18.
block_padding_bottom Amount (in pixels) of bottom padding on the block. Defaults to 9.
block_padding_top Amount (in pixels) of top padding on the block. Defaults to 9.
color Foreground color of text and text decoration (e.g., "#000000").
inner_padding_bottom Bottom padding on the text area. This is additive with block-level padding.
inner_padding_left Left padding on the text area. This is additive with block-level padding.
inner_padding_right Right padding on the text area. This is additive with block-level padding.
inner_padding_top Top padding on the text area. This is additive with block-level padding.
letter_spacing Pixel-based letter-spacing CSS property (e.g., 8).
line_height Percentage-based line-height CSS property (e.g.,150).
text_align See text-align CSS property (e.g., "center").
text_table_layout See table-layout CSS property (e.g., "auto").

Supported display options

The display_options object contains fields that map to the options set for Display in the template editor.

Display option name Description
show_on Determines which platforms display the block. Options include: all, desktop, mobile.
visible_check A check to determine whether a recipient will see the block (e.g., "person.Country == \"Canada\""). Maps to Show/Hide Logic in the UI.
content_repeat Options include:
  • repeat_for, the key to repeat, typically a path to an event or profile property (e.g., "event.items").
  • item_alias, the alias of the repeated item to use in the block's contents (e.g., "item").