--- layout: page title: Image Templates permalink: /getting-started/templates/ description: >- Create reusable templates for your HTML & CSS to make image generation easy. parent: Getting started nav_order: 4 --- # Image Templates {: .no_toc } {: .fs-9 } Create reusable templates to make image generation easy. {: .fs-6 .fw-300 } [Get an API Key](https://htmlcsstoimage.com){: .btn .btn-blue .fs-5 .mb-4 .mb-md-0 }
post https://hcti.io/v1/template
### Parameters
The create template endpoint accepts the following parameters. Accepted as either `json` or `formdata`.
| Name | Type | Description |
|:-------------|:------------------|:------|
| **html***| `String` | This is the HTML you want to render. You can send an HTML snippet \(`
post https://hcti.io/v1/template/:template_id
### Parameters
The edit template endpoint accepts the following parameters. Accepted as either `json` or `formdata`.
| Name | Type | Description |
|:-------------|:------------------|:------|
| **html***| `String` | This is the HTML you want to render. You can send an HTML snippet \(`
post https://hcti.io/v1/image/:template_id
You can also generate a templated image with a signed `GET` URL that renders on demand. See [Creating a templated image URL](/getting-started/create-and-render/#creating-a-templated-image-url).
To use one template for automatic social cards across an existing site, select it in an [OG Image Config](/getting-started/og-images/#template-values). HCTI can map page titles, descriptions, Open Graph metadata, and explicit `html:tv:` values to its variables.
{% include hint.md title="Template Versions" text="When you create an image using a `template_id`, it will automatically use the most recent version of that template. If you want to create an image from a specific template_version you can append `/:template_version` to your POST: `hcti.io/v1/image/:template_id/:template_version`" %}
### Parameters
The create templated image endpoint accepts the following parameters, accepted as either `json` or `formdata`.
- If you use `formdata`, your `template_values` need to be JSON encoded.
| Name | Type | Description |
|:-------------|:------------------|:------|
| **template_values*** | `JSON` | Values for the variables in your template. For editor templates, see the [Variables guide](/template-editor/variables/). |
get https://hcti.io/v1/template
### Example responses
```
STATUS: 200 OK
```
```javascript
{
"data": [
{
"css": null,
"created_at": "2020-07-19T17:16:43.987+00:00",
"description": null,
"device_scale": 2.0,
"google_fonts": null,
"html": "\n\n\n\n\n", "id": "t-5ff7b966-d32c-4143-bda3-57a440e97a80", "max_wait_ms": null, "ms_delay": 1500, "name": null, "render_when_ready": null, "render_count": 142, "storage_destination_id": "your-storage-destination-id", "color_scheme": null, "timezone": null, "updated_at": "2020-07-19T17:16:43.987+00:00", "version": 1595179003987, "viewport_height": null, "viewport_width": null } ], "pagination": { "next_page_start": null } } ``` ### Response fields | Field | Type | Description | |:------|:-----|:------------| | **render_count** | `Integer` | Number of times this template has been used to generate images. | | **storage_destination_id** | `String` or `null` | Storage destination inherited by images created from this template. | | **color_scheme** | `String` | Light or dark mode setting, if configured. | | **timezone** | `String` | Timezone setting, if configured. | ## Listing your template versions To list all versions of a template, send a get to `v1/template/:template_id`. Authentication is required.
get https://hcti.io/v1/template/:template_id
### Example responses
```
STATUS: 200 OK
```
```javascript
{
"data": [
{
"css": null,
"created_at": "2020-07-19T17:16:43.987+00:00",
"description": null,
"device_scale": 2.0,
"google_fonts": null,
"html": "\n\n\n\n\n", "id": "t-5ff7b966-d32c-4143-bda3-57a440e97a80", "max_wait_ms": null, "ms_delay": 1500, "name": null, "render_when_ready": null, "render_count": 142, "storage_destination_id": "your-storage-destination-id", "color_scheme": null, "timezone": null, "updated_at": "2020-07-19T17:16:43.987+00:00", "version": 1595179003987, "viewport_height": null, "viewport_width": null, } ], "pagination": { "next_page_start": null } } ``` {% include code_footer.md version=2 %}