Skip to content

Create or update a layout

PUT
/v1/layouts/{id}
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.

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. Default layout (1-100 characters).

string
html
required

HTML (Mustache) with {{> template}} where the template’s HTML goes.

string
>= 1 characters <= 524288 characters
text

Plain text (Mustache) with {{> template}} where the template’s text goes.

string
<= 262144 characters

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>"
}

Updated.

Media typeapplication/json
object
id
string
version
integer
created
boolean

Example

{
"id": "default",
"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": "default",
"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 layout isn’t valid Mustache or is missing {{> template}}.

Media typeapplication/json
object
error
required

What went wrong, in plain words.

string

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.

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.