Documentation
Templates
Templates are pre-built image designs hosted on html2img. Instead of sending raw HTML or a URL, you POST a JSON payload to a named template endpoint and receive a rendered PNG. Templates are versioned and tested by us, so the rendered output is stable.
How templates differ from HTML and screenshot requests
The /api/v1/html and /api/v1/screenshot endpoints render whatever markup or web page you point them at. Templates skip the markup step. The design lives on our side, you supply only the data, and the API returns a finished image. This makes integration shorter and the output more predictable.
Authentication
Every template request requires the X-API-Key header. The
authentication docs
cover where to get a key and how to keep it secure.
Rate limits
Template requests count against the same monthly credit pool as HTML and screenshot requests. The quick start guide explains how credits work and how to monitor usage.
Request shape
All template requests follow the same shape:
POST https://html2img.com/api/v1/templates/{slug}
X-API-Key: <your-api-key>
Content-Type: application/json
{
"input_one": "value",
"input_two": 42
} The path slug picks the template. The JSON body contains the inputs that template accepts. Output is always PNG, served from our CDN.
Response shape
A successful render returns a JSON envelope:
{
"success": true,
"id": "abc123",
"url": "https://i.html2img.com/abc123.png",
"credits_remaining": 1234,
"template": "open-graph-image"
} The same response shape used everywhere else in the API. See the API parameters reference for shared rendering options like DPI.
Available templates
Templates are listed below by category. Each links to a full reference page covering inputs, defaults, code examples and errors. New templates appear here automatically as they are added to the API.
social
- Open Graph Image — Generate dynamic Open Graph images from JSON
Errors
Templates use the standard html2img error envelope. Validation failures return 422 with field-level details, unknown slugs return 404, missing or invalid keys return 401, and rate-limit hits return 429. The testing and debugging guide covers how to reproduce and inspect these locally.
Looking for the marketing-side overview, with sample renders and use cases? See the templates gallery.