Create or update a template
const url = 'https://api.velumrelay.email/v1/templates/example';const options = { method: 'PUT', headers: { 'If-None-Match': '*', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"name":"Welcome email","subject":"Welcome, {{name}}!","html":"<h1>Hello {{name}}</h1>\n<p><a href=\"{{verify_url}}\">Verify your email</a></p>","layout":"default"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Use a lowercase letter first, then a-z, 0-9 and _ (up to 48 characters)
Header Parameters
Section titled “Header Parameters”Only update if the current version is this one (e.g. "3", from the ETag). Otherwise you get 412.
Send * to only create: if the ID already exists you get 412 instead of overwriting it.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Display name, e.g. Welcome email (1-100 characters).
Subject line (Mustache). Rendered without HTML escaping, with line breaks removed.
HTML body (Mustache). {{var}} is HTML-escaped; {{{var}}} inserts raw HTML. CSS is inlined when sending.
Plain-text body (Mustache). If left out, it’s generated from the final HTML.
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"}Responses
Section titled “Responses”Updated.
object
Example
{ "id": "welcome", "version": 2, "created": false}Headers
Section titled “Headers”Example
"3"The current version, quoted ("3"). Send it back as If-Match to update safely.
Example
req_3kTMd9vXq2LwB8nYpR4sZaUnique ID of this request (req_ + 22 characters). Include it when you contact support.
Created.
object
Example
{ "id": "welcome", "version": 1, "created": true}Headers
Section titled “Headers”Example
"3"The current version, quoted ("3"). Send it back as If-Match to update safely.
Example
req_3kTMd9vXq2LwB8nYpR4sZaUnique 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.
object
What went wrong, in plain words.
Example
{ "error": "invalid request: html: Enter the HTML"}Missing or invalid management key.
object
What went wrong, in plain words.
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.
object
What went wrong, in plain words.
Example
{ "error": "version mismatch"}The template isn’t valid Mustache, uses an include, or names a layout that doesn’t exist.
object
What went wrong, in plain words.
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.
object
What went wrong, in plain words.
Example
{ "error": "rate limit exceeded"}Headers
Section titled “Headers”Example
1Example
req_3kTMd9vXq2LwB8nYpR4sZaUnique ID of this request (req_ + 22 characters). Include it when you contact support.