comecerodocs

Create a template

POST
/templates

Saves a Handlebars template. Use its id as template_id on a notification subscription, as wrapper_template_id on another template, or with POST /notifications. Secret and trusted tokens may call it; a limited token may not (403).

Authorization

headerAuthorizationBearer <token>

A secret, trusted or limited token. See Authentication.

Request Body

application/json
  1. body

The fields you can set on a template. On create, body is required. On update, send only the fields to change.

body*string

The Handlebars source, at most 128 kB (UTF-8).

default_subject?|

The subject a notification subscription uses when it sets none. It is saved but not returned when you read the template.

wrapper_template_id?|

The id of a template to place this one inside. It must be in your account, and templates may not wrap or embed each other in a loop (400).

expand?|

Comma-separated child objects of the data to expand.

show?|

Comma-separated fields of the data to keep.

hide?|

Comma-separated fields of the data to leave out.

comments?|

Your own notes.

Lengthlength <= 256
template_type?|

email (the default) or pdf. A PDF template cannot be changed back (400).

Value in"email""pdf"null
pdf_type?|

For a PDF template, what it renders, such as invoice or order.

page_format?|

For a PDF template, the page size, such as A4 or Letter.

orientation?|

For a PDF template, portrait or landscape.

margin_top?|

For a PDF template, the top margin.

margin_bottom?|

For a PDF template, the bottom margin.

margin_left?|

For a PDF template, the left margin.

margin_right?|

For a PDF template, the right margin.

Response Body

The new template.

application/json
  1. response

A Handlebars template that builds the body of an email (or a PDF). Use one on a notification subscription, wrap it in another with wrapper_template, or render it yourself with the build endpoint.

object?"template"

Always template.

Value in"template"
url?string

The URL of this template in the API.

Formaturi
template_id?string

The template id.

date_created?string

When the template was created.

Formatdate-time
date_modified?string

When the template last changed.

Formatdate-time
test?boolean

true for a test mode template.

account_id?string

The account it belongs to.

expand?|

Comma-separated child objects of the data to expand before the template is filled.

show?|

Comma-separated fields of the data to keep.

hide?|

Comma-separated fields of the data to leave out.

wrapper_template?||

The template this one is placed inside (a shared header and footer, for example): its URL, the full object with expand=wrapper_template, or null.

comments?|

Your own notes, at most 256 characters.

template_type?|

email (or null, the same) or pdf. A PDF template cannot be changed back.

Value in"email""pdf"null
pdf_type?|

For a PDF template, what it renders, such as invoice or order.

page_format?|

For a PDF template, the page size, such as A4 or Letter.

orientation?|

For a PDF template, portrait or landscape.

margin_top?|

For a PDF template, the top margin.

margin_bottom?|

For a PDF template, the bottom margin.

margin_left?|

For a PDF template, the left margin.

margin_right?|

For a PDF template, the right margin.

body?|

The Handlebars source, at most 128 kB. In a list this holds a short note instead; get the template by id to read the body.

formatted?

Dates as display text. Only returned with formatted=true.

curl -X POST 'https://api.comecero.com/api/v1/templates' \  -H 'Content-Type: application/json' \  -d '{  "body": "<p>Thanks for your order, {{customer.first_name}}.</p>"}'
Example Response
{  "object": "template",  "url": "https://api.comecero.com/api/v1/templates/1102500900112TEm5Jc3Rw",  "template_id": "1102500900112TEm5Jc3Rw",  "date_created": "2026-10-01T09:05:00Z",  "date_modified": "2026-10-01T09:05:00Z",  "test": true,  "account_id": "AB1234",  "expand": null,  "show": null,  "hide": null,  "wrapper_template": null,  "comments": "Download email",  "template_type": null,  "pdf_type": null,  "page_format": null,  "orientation": null,  "margin_top": null,  "margin_bottom": null,  "margin_left": null,  "margin_right": null,  "body": "<p>Hi {{customer.first_name}}, your download is ready: {{download_url}}</p>"}