Skip to documentation

API · Templates

Create Template

Create a draft email template (requires full access). Variables are inferred from inline merge tags unless explicit definitions are supplied.

POST/templatesFull access

Request parameters

ParameterTypeDescription
Idempotency-Key
header · optional
string
1–256 characters
Makes the request safe to retry. See Idempotency.
name
body · required
stringTemplate name, up to 256 characters.
alias
body · optional
string | nullUnique template alias, up to 128 characters, generated when omitted on creation.
from
body · optional
string | nullSender address, up to 512 characters, optionally formatted as Name <sender@example.com>.
subject
body · optional
string | nullEmail subject, up to 998 characters.
reply_to
body · optional
string | (string)[]Up to 50 valid reply-to addresses, supplied as a string or array.
html
body · required
stringHTML content, up to 256 KiB, with variable values escaped when rendered.
text
body · optional
string | nullPlain text content, up to 256 KiB, derived from HTML when omitted on creation; an explicit empty string stays empty.
variables
body · optional
(object)[]
Up to 50 items
Up to 50 unique string or number variable definitions, overriding inferred inline variables.
variables[].key
body · required
string
Matches /^[A-Za-z_][A-Za-z0-9_]*$/
Unique identifier of up to 50 characters, excluding FIRST_NAME, LAST_NAME, EMAIL, RESEND_UNSUBSCRIBE_URL, contact, and this.
variables[].type
body · required
"string" | "number"Variable type: string or number.
variables[].fallback_value
body · optional
string | numberDefault matching the variable type, with string defaults limited to 2000 characters.

Request example

Set OPENSEND_BASE_URL=https://api.example.com and OPENSEND_API_KEY=os_replace_me on your server.

bash
curl -X POST "$OPENSEND_BASE_URL/templates" \
  -H "Authorization: Bearer $OPENSEND_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"name":"Welcome","html":"<p>Hello.</p>"}'

Response

201 · application/json. Example IDs stand for IDs returned by your installation.

json
{
  "object": "template",
  "id": "YOUR_ID"
}

Behavior and errors

A template has one mutable draft and one published snapshot. Sends must use the published snapshot. There is no historical version API.

Use a full-access credential. Resource IDs belong to your team; an unknown or foreign resource returns 404. See authentication, errors, rate limits, and compatibility for the shared contract.