Create a email template
/api/v1/email-templatesRequest body
skeleton_htmlstringcontentarraysource_template_keystringlayoutstringshow_company_namebooleanplain_textstringvariables_schemaarraynamestringsubjectstringhtmlstring
Request
/api/v1/email-templatescurl -X POST 'https://app.mailyte.com/api/v1/email-templates' \
-H 'Authorization: Bearer mk_live_YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"skeleton_html": "<string>",
"content": [],
"source_template_key": "<string>",
"layout": "<string>",
"show_company_name": "<boolean>",
"plain_text": "<string>",
"variables_schema": [],
"name": "<string>",
"subject": "<string>",
"html": "<string>"
}'const response = await fetch('https://app.mailyte.com/api/v1/email-templates', {
method: 'POST',
headers: {
Authorization: 'Bearer mk_live_YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"skeleton_html": "<string>",
"content": [],
"source_template_key": "<string>",
"layout": "<string>",
"show_company_name": "<boolean>",
"plain_text": "<string>",
"variables_schema": [],
"name": "<string>",
"subject": "<string>",
"html": "<string>"
}),
});
const { data } = await response.json();import requests
response = requests.post(
"https://app.mailyte.com/api/v1/email-templates",
headers={"Authorization": "Bearer mk_live_YOUR_API_KEY"},
json={
"skeleton_html": "<string>",
"content": [],
"source_template_key": "<string>",
"layout": "<string>",
"show_company_name": "<boolean>",
"plain_text": "<string>",
"variables_schema": [],
"name": "<string>",
"subject": "<string>",
"html": "<string>"
},
)
data = response.json()["data"]<?php
$response = Http::withToken('mk_live_YOUR_API_KEY')
->post('https://app.mailyte.com/api/v1/email-templates', [
'skeleton_html' => '<string>',
'content' => [],
'source_template_key' => '<string>',
'layout' => '<string>',
'show_company_name' => '<boolean>',
'plain_text' => '<string>',
'variables_schema' => [],
'name' => '<string>',
'subject' => '<string>',
'html' => '<string>',
]);
$data = $response->json('data');require "net/http"
require "json"
uri = URI("https://app.mailyte.com/api/v1/email-templates")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer mk_live_YOUR_API_KEY"
request["Content-Type"] = "application/json"
request.body = {
"skeleton_html": "<string>",
"content": [],
"source_template_key": "<string>",
"layout": "<string>",
"show_company_name": "<boolean>",
"plain_text": "<string>",
"variables_schema": [],
"name": "<string>",
"subject": "<string>",
"html": "<string>"
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }Response
Success.
dataobjectobjectstringemail_templateidstringnamestringUnique within your organization.
subjectstringMay contain `{{ variable }}` placeholders, like the bodies. Required when the template is created and never null afterwards; an update that omits it keeps the stored one rather than clearing it.
htmlstringThe HTML body. Required on create and never null. A template with an empty body is `""`, not null -- test for the empty string.
textstringThe plain-text body. READ SIDE ONLY: the write side still accepts `plain_text` and nothing else. `POST`/`PUT`/`PATCH /email-templates` and `POST /email-templates/preview` validate `plain_text` and silently discard a `text` key, so posting `text` stores nothing and reads back as `"text": null`. Send `plain_text`, read `text`, until that is fixed.
variablesarray<string>The `{{ }}` placeholder names found in the subject and bodies. A flat list of names -- no types, no required flags, no defaults, which is why it is not called a schema. Never null: `[]` means this template has no placeholders, not that we have not looked.
created_atstringNULL MEANS UNKNOWN -- the stored row has no creation timestamp -- and never that the template is unsaved: you are reading it back, so it exists. The column is nullable only because Laravel's timestamps are, and every template created through the API has one.
updated_atstringNULL MEANS UNKNOWN, on the same terms as `created_at`, and never "never edited" -- an untouched template carries its creation time here, not null. Note that saving a template also re-derives `variables` from its content, so this moves on a create as well as an edit and is not a reliable "has a human changed this" signal.
Returned inside the standard envelope.
Errors
| Status | When |
|---|---|
401 | The API key is missing, unknown, revoked or expired. All four answer identically, on purpose: distinguishing them would confirm which keys exist. |
403 | The key is valid but may not do this: it lacks the required scope, its IP allowlist does not include you, or this endpoint does not accept API keys. |
404 | No such resource in this organization. |
422 | The request was understood but the values were not acceptable. |
429 | Too many requests, or the organization has spent its sending allowance. `Retry-After` says how long to wait. |
Every status, with what causes it and what to do, is on the error reference.