Skip to content

Get template by ID

Returns the published version of a template: the HTML, subject and variables frozen the last time it was published. Use the format query parameter to get only the HTML or only the variables.

GET https://app.maiilo.io/api/v1/templates/:id

The template ID is shown on the template’s details page in the app.

HeaderValueRequired
AuthorizationBearer YOUR_API_KEYYes
NameTypeRequiredDescription
formatstringNohtml returns the raw HTML. variables returns only the variable list. Leave it out for the full JSON response.

The response always comes from the template’s current published version:

  • It does not change when you edit the draft or a shared block. Only publishing changes it.
  • Every request for the same version returns the same bytes, because the HTML is stored at publish time, not rendered on request.
  • A template that has never been published returns 404 with {"error":"template_not_published"}.

See What the API and SendGrid serve.


Terminal window
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://app.maiilo.io/api/v1/templates/fewQsSLBrA9R"
const res = await fetch('https://app.maiilo.io/api/v1/templates/fewQsSLBrA9R', {
headers: { Authorization: 'Bearer YOUR_API_KEY' },
});
const template = await res.json();
{
"id": "fewQsSLBrA9R",
"name": "Welcome Email",
"subject": "Hello {{name}}",
"html": "<!DOCTYPE html>...",
"variables": ["name", "company"],
"updatedAt": "2026-09-01T12:00:00.000Z"
}
FieldTypeDescription
idstringThe template’s ID.
namestringThe template’s name.
subjectstringThe subject line of the published version. May contain {{variables}}. Empty if the version was published without a subject.
htmlstringThe HTML of the published version, exactly as stored when it was published.
variablesstring[]The variable names used in the published version: subject, text, links, image sources and Code Blocks.
updatedAtstringISO 8601 timestamp of when the template was last updated. This includes draft edits, so it can be later than the last publish.

Returns the published HTML as the response body, with Content-Type: text/html.

Terminal window
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://app.maiilo.io/api/v1/templates/fewQsSLBrA9R?format=html"
<!DOCTYPE html>
<html>
<body>
...
</body>
</html>

Returns only the list of variables in the published version. Use it to check which merge fields a template expects before you send.

Terminal window
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://app.maiilo.io/api/v1/templates/fewQsSLBrA9R?format=variables"
const res = await fetch(
'https://app.maiilo.io/api/v1/templates/fewQsSLBrA9R?format=variables',
{ headers: { Authorization: 'Bearer YOUR_API_KEY' } },
);
const { variables } = await res.json();
// ["name", "company"]
{
"variables": ["name", "company"]
}

StatusBodyMeaning
401Missing API key (plain text)No Authorization header.
401Invalid API key (plain text)The key does not exist or was deleted.
403No active subscription found (plain text)The account that owns the key has no active plan.
404{"error":"Not found"}No template with this ID exists in the key owner’s account.
404{"error":"template_not_published"}The template exists but has never been published. Publish it.
429Plan limit exceeded (plain text)The monthly request quota is used up.
500{"error":"Internal server error"}Something went wrong on Maiilo’s side.

Both 404 responses count toward your monthly quota. See Errors and Limits and quotas.

  • Replace the {{variables}} with your own data before sending. Maiilo never fills them in.
  • Keep your API key on your server, never in frontend code.
  • The API is read-only. Creating or editing templates through the API is not available.