Create or update a layout
const url = 'https://api.velumrelay.email/v1/layouts/example';const options = { method: 'PUT', headers: { 'If-None-Match': '*', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"name":"Default layout","html":"<!doctype html>\n<html><body>\n <header>{{company}}</header>\n {{> template}}\n <footer>Sent by {{company}}</footer>\n</body></html>"}'};
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/layouts/example \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'If-None-Match: *' \ --data '{ "name": "Default layout", "html": "<!doctype html>\n<html><body>\n <header>{{company}}</header>\n {{> template}}\n <footer>Sent by {{company}}</footer>\n</body></html>" }'Creates the layout, or replaces it if the ID exists. html (and text, if given) must contain {{> template}} where the template’s content goes. 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. Default layout (1-100 characters).
HTML (Mustache) with {{> template}} where the template’s HTML goes.
Plain text (Mustache) with {{> template}} where the template’s text goes.
Example
{ "name": "Default layout", "html": "<!doctype html>\n<html><body>\n <header>{{company}}</header>\n {{> template}}\n <footer>Sent by {{company}}</footer>\n</body></html>"}Responses
Section titled “Responses”Updated.
object
Example
{ "id": "default", "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": "default", "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 layout isn’t valid Mustache or is missing {{> template}}.
object
What went wrong, in plain words.
Example
{ "error": "the layout's html must contain {{> template}} where the template goes"}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.