Skip to content

Create or update a template

PUT
/v1/templates/{id}
curl --request PUT \
--url https://api.velumrelay.email/v1/templates/example \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'If-None-Match: *' \
--data '{ "name": "Welcome email", "subject": "Welcome, {{name}}!", "html": "<h1>Hello {{name}}</h1>\n<p><a href=\"{{verify_url}}\">Verify your email</a></p>", "layout": "default" }'

Creates the template, or replaces it if the ID exists. layout assigns one of your layouts; null removes it; leaving it out keeps the current one. name defaults to the ID when creating and is kept when left out on update. Use If-Match or If-None-Match to avoid overwriting someone else’s change.

id
required
string
/^[a-z][a-z0-9_]{0,47}$/

Use a lowercase letter first, then a-z, 0-9 and _ (up to 48 characters)

If-Match
string

Only update if the current version is this one (e.g. "3", from the ETag). Otherwise you get 412.

If-None-Match
string
Allowed values: *

Send * to only create: if the ID already exists you get 412 instead of overwriting it.

Media typeapplication/json
object
name

Display name, e.g. Welcome email (1-100 characters).

string
subject
required

Subject line (Mustache). Rendered without HTML escaping, with line breaks removed.

string
>= 1 characters <= 1024 characters
html
required

HTML body (Mustache). {{var}} is HTML-escaped; {{{var}}} inserts raw HTML. CSS is inlined when sending.

string
>= 1 characters <= 524288 characters
text

Plain-text body (Mustache). If left out, it’s generated from the final HTML.

string
<= 262144 characters
layout

ID of one of your layouts to wrap this template in; null removes it; leave out to keep the current one.

Any of:
string
/^[a-z][a-z0-9_]{0,47}$/

Example

{
"name": "Welcome email",
"subject": "Welcome, {{name}}!",
"html": "<h1>Hello {{name}}</h1>\n<p><a href=\"{{verify_url}}\">Verify your email</a></p>",
"layout": "default"
}

Updated.

Media typeapplication/json
object
id
string
version
integer
created
boolean

Example

{
"id": "welcome",
"version": 2,
"created": false
}
ETag
string
Example
"3"

The current version, quoted ("3"). Send it back as If-Match to update safely.

X-Request-Id
string
Example
req_3kTMd9vXq2LwB8nYpR4sZa

Unique ID of this request (req_ + 22 characters). Include it when you contact support.

Created.

Media typeapplication/json
object
id
string
version
integer
created
boolean

Example

{
"id": "welcome",
"version": 1,
"created": true
}
ETag
string
Example
"3"

The current version, quoted ("3"). Send it back as If-Match to update safely.

X-Request-Id
string
Example
req_3kTMd9vXq2LwB8nYpR4sZa

Unique ID of this request (req_ + 22 characters). Include it when you contact support.

Invalid request: a field breaks a rule, an unknown field was sent, or If-Match isn’t a version.

Media typeapplication/json
object
error
required

What went wrong, in plain words.

string

Example

{
"error": "invalid request: html: Enter the HTML"
}

Missing or invalid management key.

Media typeapplication/json
object
error
required

What went wrong, in plain words.

string

Example

{
"error": "invalid or missing management key"
}

If-Match didn’t match the current version, or If-None-Match: * was sent for an ID that exists.

Media typeapplication/json
object
error
required

What went wrong, in plain words.

string
current_version
integer

Example

{
"error": "version mismatch"
}

The template isn’t valid Mustache, uses an include, or names a layout that doesn’t exist.

Media typeapplication/json
object
error
required

What went wrong, in plain words.

string

Example

{
"error": "{{> header}} isn't supported in templates; put shared parts in a layout"
}

Rate limit exceeded (20 requests per second, bursts up to 40, per key). Wait for Retry-After seconds, then retry.

Media typeapplication/json
object
error
required

What went wrong, in plain words.

string

Example

{
"error": "rate limit exceeded"
}
Retry-After
integer
Example
1
X-Request-Id
string
Example
req_3kTMd9vXq2LwB8nYpR4sZa

Unique ID of this request (req_ + 22 characters). Include it when you contact support.