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:
When Klaviyo renders these, it internally:
-
Looks up a profile ID
-
Resolves entitlements (e.g., coupon eligibility)
-
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:
Then you must:
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.