Create a template and publish version 1
Creates a template container and atomically publishes version 1 from the same request, so the template is immediately sendable.
Creates a template container and atomically publishes version 1 from the same request, so the template is immediately sendable. slug (1–64 chars, lowercase letters, digits, and hyphens, no leading or trailing hyphen), name (≤120 chars), and source (a React email component, ≤64 KiB) are required; subject (≤2000 chars, with {{variable}} placeholders), variables, and notes (≤500 chars) are optional. variables is a JSON-Schema-lite contract (≤8 KiB) accepting either the field-local shape { "amount": { "type": "number", "required": true } } or a standard JSON Schema with properties and a top-level required array, over the types string, number, integer, boolean, object, array, null, url, and email. Before the version is stored Dairo dry-renders the source against sample values derived from the schema and returns 400 with a renderer error code (such as NO_COMPONENT_EXPORT, FORBIDDEN_IMPORT, or RENDER_FAILED) if it cannot render, while dangerouslySetInnerHTML in the source adds a non-blocking USES_DANGEROUS_HTML entry to the response warnings array. A slug already in use within the project returns 409 before any rate-limit token or render is spent; creation is capped at 50 per hour with a shared 60-per-minute mutation limit and requires the templates:write scope. Responds 201 with the object: "template" and its published version nested under version.
Scope: templates:write. Send the API key as a bearer token; Scopes lists what each one reaches.
Request
Headers
| Name | Type | Required | Description |
|---|---|---|---|
Idempotency-Key | string | no | Optional idempotency key for safe retries of side-effecting operations. (max length 128) |
Body
Required, application/json: TemplateCreateRequest.
| Field | Type | Required | Description |
|---|---|---|---|
slug | string | yes | |
name | string | yes | (min length 1) |
description | string | no | |
source | string | yes | React Email TSX source for version 1. |
subject | string | no | |
variables | TemplateVariableSchema | no | |
notes | string | no |
Response
201 Created. Body: application/json, TemplateVersionResponse.
| Field | Type | Required | Description |
|---|---|---|---|
template | Template | yes | |
version | TemplateVersion | yes | |
warnings | array of string | yes |
Errors
Every error has the same body, {"error": {"type", "code", "message", "param"}}; branch on code. Errors lists every code.
| Status | Meaning |
|---|---|
400 | The request is malformed or a value is invalid (invalid_request, invalid_domain, idempotency_key_mismatch). |
401 | The API key is missing or invalid. |
403 | The key lacks the scope this endpoint needs (scope_missing) or may not do this (not_permitted). |
404 | No such resource in this account (resource_not_found). |
422 | The request is well-formed but a field failed validation (validation_failed). |
429 | Rate limit, plan limit, budget or spend cap reached (rate_limited, plan_limit_reached, budget_exceeded, spend_cap_reached). |
500 | An unexpected error; retry with backoff, then contact support (internal_error). |