Templates
Save reusable HTML with {{variable}} placeholders and render them with dynamic data.
Overview
Templates let you define the visual design once and render it repeatedly with different content. The API stores the HTML on the server and returns a template_id. On each render, pass that ID plus a variables object — all {{key}} occurrences in the HTML are replaced before rendering.
You can also use
variables directly in POST /v1/render without saving a template — useful for one-off renders.Create a Template
POST/v1/template
| Name | Type | Description |
|---|---|---|
| html * | String | HTML to save. Use {{key}} for dynamic values. |
| name | String | Optional label for this template. |
Request
curl -X POST https://api.starkrender.com/v1/template \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "News card", "html": "<div style=\"background:#0f172a;width:1080px;height:1080px;display:flex;flex-direction:column;align-items:center;justify-content:center;color:#fff;font-family:Montserrat;gap:16px\"><h1 style=\"font-size:52px;margin:0\">{{headline}}</h1><p style=\"color:#94a3b8;font-size:22px;margin:0\">{{source}}</p></div>" }'
Response
{
"status": "success",
"template_id": "86c4dab7-6570-442a-9a46-74bb2a472aed"
}
Render with a Template
Pass template_id and variables to POST /v1/render. All other render parameters (width, height, format, device_scale, etc.) work as normal.
Request
curl -X POST https://api.starkrender.com/v1/render \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "template_id": "86c4dab7-6570-442a-9a46-74bb2a472aed", "variables": { "headline": "Real estate market grows 18%", "source": "InfoMoney — May 2026" }, "width": 1080, "height": 1080 }'
Response
{
"status": "success",
"image_url": "https://api.starkrender.com/static/uuid.png"
}
Variable Syntax
Variables use double curly braces: {{variable_name}}. Names can contain letters, numbers, and underscores.
HTML Template
<div style="font-family:Montserrat;..."> <h1>{{headline}}</h1> <p>{{body}}</p> <img src="{{image_url}}"> <span>{{date}}</span> </div>
If a key in the template has no matching variable in the request, the placeholder is left unchanged in the output (
{{missing_key}}).List Templates
GET/v1/template
Response
{
"status": "success",
"templates": [
{ "id": "86c4dab7-...", "name": "News card", "created_at": "2026-05-04T19:02:00Z" }
]
}
Get a Template
GET/v1/template/{id}
Response
{
"status": "success",
"template": {
"id": "86c4dab7-...",
"name": "News card",
"html": "<div>{{headline}}</div>",
"created_at": "2026-05-04T19:02:00Z"
}
}
Delete a Template
DELETE/v1/template/{id}
Response
{ "status": "success" }