Skip to main content
Contributor II
January 22, 2026
Solved

Render Template API - Unable to render given template with provided context: customer profile is required

  • January 22, 2026
  • 1 reply
  • 73 views

Hello!

When using the /api/template-render endpoint, certain templates that have profile-dependent tags (e.g. {% coupon_code %}), api returns a 400 bad request with the detail “Unable to render given template with provided context: customer profile is required”.

Have been able to pass other context data with no issues. But what is the correct syntax for sending profile information with the template context? Tried every combination/structure I could think of.


Anyone else figured this out?

Thanks

    Best answer by Timmy Solomon

    You cannot pass a synthetic or inline “profile” object to /api/template-render to satisfy profile-dependent tags like {% coupon_code %}, {{ person.email }}, etc.
    Those tags require a real Klaviyo profile that already exists in your account.

    Why this happens

    Some template tags are profile-bound, not just context-bound. Examples include:

    • {% coupon_code %}

    • {{ person.email }}

    • {{ person.first_name }}

    • Loyalty, subscription, or event-driven tags

    When Klaviyo renders these, it internally:

    1. Looks up a profile ID

    2. Resolves entitlements (e.g., coupon eligibility)

    3. Applies account-level logic

    Because of this, the render engine cannot accept a manually supplied profile object inside context.

    What does work

    You have two valid options:

    Option 1: Render using a real profile

    You must pass a profile ID, not profile fields.

    Example (simplified):

     

    POST /api/template-render { "data": { "type": "template-render", "attributes": { "template_id": "YOUR_TEMPLATE_ID", "profile_id": "REAL_KLAVIYO_PROFILE_ID" } } }

    This is the only way to render templates containing {% coupon_code %}.

    Option 2: Remove profile-dependent tags

    If you want to render templates purely for:

    • Preview

    • Testing

    • External systems (CMS, backend, etc.)

    Then you must:

    • Remove {% coupon_code %} and similar tags

    • Replace them with variables you inject via context

    Example:

     

    {{ custom.coupon_code }}

    Then pass:

     

    "context": { "custom": { "coupon_code": "TEST-CODE-123" } }

    Important clarification

    This will not work, regardless of structure:

     

    "context": { "person": { "email": "test@example.com" } }

    Klaviyo explicitly ignores inline profile objects for rendering.

    1 reply

    Timmy Solomon
    Problem Solver III
    Problem Solver III
    January 23, 2026

    You cannot pass a synthetic or inline “profile” object to /api/template-render to satisfy profile-dependent tags like {% coupon_code %}, {{ person.email }}, etc.
    Those tags require a real Klaviyo profile that already exists in your account.

    Why this happens

    Some template tags are profile-bound, not just context-bound. Examples include:

    • {% coupon_code %}

    • {{ person.email }}

    • {{ person.first_name }}

    • Loyalty, subscription, or event-driven tags

    When Klaviyo renders these, it internally:

    1. Looks up a profile ID

    2. Resolves entitlements (e.g., coupon eligibility)

    3. Applies account-level logic

    Because of this, the render engine cannot accept a manually supplied profile object inside context.

    What does work

    You have two valid options:

    Option 1: Render using a real profile

    You must pass a profile ID, not profile fields.

    Example (simplified):

     

    POST /api/template-render { "data": { "type": "template-render", "attributes": { "template_id": "YOUR_TEMPLATE_ID", "profile_id": "REAL_KLAVIYO_PROFILE_ID" } } }

    This is the only way to render templates containing {% coupon_code %}.

    Option 2: Remove profile-dependent tags

    If you want to render templates purely for:

    • Preview

    • Testing

    • External systems (CMS, backend, etc.)

    Then you must:

    • Remove {% coupon_code %} and similar tags

    • Replace them with variables you inject via context

    Example:

     

    {{ custom.coupon_code }}

    Then pass:

     

    "context": { "custom": { "coupon_code": "TEST-CODE-123" } }

    Important clarification

    This will not work, regardless of structure:

     

    "context": { "person": { "email": "test@example.com" } }

    Klaviyo explicitly ignores inline profile objects for rendering.

    Whatsaap: +234 7044075666