Documentation

Templates

Stored copy with {{variables}}, rendered safely at send time.

A template is a stored subject and body with {{name}} placeholders. Prefer sending through one over composing HTML in the caller: the copy is reviewed once, and the values filled in at send time cannot rewrite the message around them.

Creating one

POST /v1/templates takes a slug (lower-case letters, digits and hyphens), a name, a subject, html and an optional text body. Posting a slug that already exists updates it in place and returns 200; a new one returns 201. On an update, leaving text out keeps the stored text body and "text": null removes it. Placeholders are extracted from the subject and both bodies and returned as variables, so GET /v1/templates tells you what each template needs before you render it.

POST /v1/templates/{slug}/duplicate copies one under a new slug (409 conflict if the new slug is in use), and DELETE /v1/templates/{slug} removes one. A delete answers 404 for a slug that does not exist, and 409 invalid_state while an active or paused automation still renders a step from the template, naming each one.

curl -X POST https://api.sendraven.ai/v1/templates \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "slug": "welcome",
    "name": "Welcome",
    "subject": "Welcome to {{plan}}, {{name}}",
    "html": "<p>Hi {{name}}, your {{plan}} workspace is ready.</p>"
  }'

Images

A template's HTML can show images you upload to SendRaven. POST /v1/media stores an image (PNG, JPEG, GIF or WebP, up to 5 MB) and answers a url on your own tracking hostname, which you put in an <img src>:

<img src="https://link.mail.example.com/media/3f1c9a7e-2b4d-4e6f-8a0c-1d3e5f7a9b2c/Zk3vN1q8Rj2LwXy0aBcDeFgHiJk.png" alt="Acme" width="300">

In the dashboard, the template form has an Insert image button that uploads a file and writes the tag for you. Only images are hosted; to send a recipient a PDF or another file, attach it to the message with attachments on POST /v1/emails. See Media for what happens to an upload and the limits.

Rendering without sending

POST /v1/templates/{slug}/render with { "variables": { … } } (strings, or numbers and booleans, which are turned into strings) returns the rendered subject, html and text without mailing anyone. text is null when the template has no plain-text body; a send through such a template gets a plain-text part derived from the HTML. It exists so an agent can check that its values produce sensible copy before a real person sees it.

curl -X POST https://api.sendraven.ai/v1/templates/welcome/render \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"variables": {"name": "Ana", "plan": "Pro"}}'

Sending with one

Pass template and variables on POST /v1/emails instead of subject and html. subject becomes optional and overrides the template's own when given. POST /v1/emails/batch accepts the same fields per entry and resolves them identically: a batch that quietly ignored templates would be a trap. On a send, every value in variables must be a string; a number or boolean fails validation with 422 invalid_request, unlike the render endpoint, which converts them.

{
  "from": "Team <team@mail.example.com>",
  "to": "ana@example.com",
  "template": "welcome",
  "variables": { "name": "Ana", "plan": "Pro" }
}

Values are escaped

Values are HTML-escaped when substituted into the HTML body. They come from agents and end users, and a template is HTML: interpolated raw, a name like <script> would execute in whatever webmail renders it, and a prompt-injected value could rewrite the surrounding message. The subject and the plain-text body are not HTML and are substituted as-is.

A missing variable is an error

Rendering fails rather than mailing a message with {{name}} still visible in it. A half-rendered email reaching a customer is worse than a failed call the caller can fix. The error is 422 missing_variables wherever it happens, with a missing array naming exactly which values were absent: from POST /v1/emails, from the render endpoint, and in POST /v1/emails/batch, where only that entry fails and its error carries the same type and missing array.

An empty string counts as provided. Only a value that is missing altogether, or null on the render endpoint, fails the render.

On this page