Create a template
Create a template from an editor document (content) or from finished HTML (html) - one or the other, not both.
On this page
https://app.usenotix.dev/api/v1/templatesNeeds a full access key. Sending access keys cannot call this. Key permissions lists the extra rules some calls have.
Create a template from an editor document (content) or from finished HTML (html) - one or the other, not both. HTML is sanitised on the way in. A marketing template created with no body is given the default marketing body so that it carries an unsubscribe footer.
The team can create or copy 60 templates a minute through the API (POST /v1/templates and both copies count together), and 120 template writes a minute counting the dashboard's own, so the dashboard always keeps room. Past either the answer is 429 with Retry-After. When Notix cannot count them the answer is 503 SERVICE_UNAVAILABLE (try again shortly), never a 429.
Body parameters
At most 200 characters.
One of TRANSACTIONAL, MARKETING.
At most 255 characters.
Lower-case letters, numbers and -, unique in the team. null clears it.
Can be null.
An address on a verified domain of the team. null clears it.
At most 320 characters. Can be null.
One email address. null clears it.
At most 320 characters. Can be null.
Declared variables: key, type TEXT or NUMBER, and an optional fallback.
One of TEXT, NUMBER.
At most 500 characters. Can be null.
Default true: the change goes live at once, as before, when it passes Publish's checks (a subject; and, once the template declares variables, every {{variable}} declared). When it does not, it is saved as a draft, the published version is left as it was, and the call answers 400 with savedAsDraft, templateId and problems. false saves a draft; publish it later with POST /v1/templates/{templateId}/publish.
Headers
Bearer followed by your API key.
Errors
The team created or copied 60 templates through the API in the last minute, or wrote 120 templates counting the dashboard's own writes.
Notix cannot count the team's calls just now; try again shortly.
Every error has the same shape. See all error codes.
curl -X POST "https://app.usenotix.dev/api/v1/templates" \
-H "Authorization: Bearer $NOTIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme",
"subject": "Your receipt for order 4471",
"html": "<p>Thanks for your order.</p>"
}'
import { Notix } from "notix-js";
const notix = new Notix(process.env.NOTIX_API_KEY);
const { data, error } = await notix.templates.create({
name: "Receipt",
subject: "Your order {{orderId}}",
html: "<p>Thanks, {{firstName}}.</p>",
});
{
"id": "cm5t3mplat3id0000",
"name": "Order receipt",
"subject": "Your order {{orderId}}",
"type": "TRANSACTIONAL",
"html": "<p>Thanks for your order.</p>",
"status": "DRAFT",
"unpublishedChanges": true,
"variables": [
{
"key": "string",
"type": "TEXT"
}
]
}