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.
Endpoint
Section titled “Endpoint”GET https://app.maiilo.io/api/v1/templates/:idThe template ID is shown on the template’s details page in the app.
Headers
Section titled “Headers”| Header | Value | Required |
|---|---|---|
Authorization | Bearer YOUR_API_KEY | Yes |
Query parameters
Section titled “Query parameters”| Name | Type | Required | Description |
|---|---|---|---|
format | string | No | html returns the raw HTML. variables returns only the variable list. Leave it out for the full JSON response. |
What you get back
Section titled “What you get back”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
404with{"error":"template_not_published"}.
See What the API and SendGrid serve.
Default response
Section titled “Default response”Example request
Section titled “Example request”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();Response (200 OK)
Section titled “Response (200 OK)”{ "id": "fewQsSLBrA9R", "name": "Welcome Email", "subject": "Hello {{name}}", "html": "<!DOCTYPE html>...", "variables": ["name", "company"], "updatedAt": "2026-09-01T12:00:00.000Z"}| Field | Type | Description |
|---|---|---|
id | string | The template’s ID. |
name | string | The template’s name. |
subject | string | The subject line of the published version. May contain {{variables}}. Empty if the version was published without a subject. |
html | string | The HTML of the published version, exactly as stored when it was published. |
variables | string[] | The variable names used in the published version: subject, text, links, image sources and Code Blocks. |
updatedAt | string | ISO 8601 timestamp of when the template was last updated. This includes draft edits, so it can be later than the last publish. |
HTML format
Section titled “HTML format”Returns the published HTML as the response body, with Content-Type: text/html.
Example request
Section titled “Example request”curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://app.maiilo.io/api/v1/templates/fewQsSLBrA9R?format=html"Response (200 OK)
Section titled “Response (200 OK)”<!DOCTYPE html><html> <body> ... </body></html>Variables format
Section titled “Variables format”Returns only the list of variables in the published version. Use it to check which merge fields a template expects before you send.
Example request
Section titled “Example request”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"]Response (200 OK)
Section titled “Response (200 OK)”{ "variables": ["name", "company"]}Errors
Section titled “Errors”| Status | Body | Meaning |
|---|---|---|
401 | Missing API key (plain text) | No Authorization header. |
401 | Invalid API key (plain text) | The key does not exist or was deleted. |
403 | No 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. |
429 | Plan 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.