FlaresendDocs
Templates

Update a template

Save a new version of a stored template.

PATCH/v1/templates/{name}API key

Every update creates a new version: version goes up by one and the previous content stays in the version history, so you can restore it later. Sends pick up the new version straight away, and each email records the version it was rendered with (templateVersion).

Send only the fields you want to change. The name can't be changed.

Only stored templates can be updated. Built-in templates are read-only and return 404 template_not_found here. To change one for your project, create a stored template with the same name; it replaces the built-in one.

Concurrent edits

If someone else saves the same template between the moment your update reads it and the moment it writes, the update fails with 409 template_conflict and nothing is saved. Fetch the template again and retry.

Path parameters

namestringpathrequired

The template name.

Body parameters

subjectstring

1 to 998 characters.

htmlstring

The HTML body. Can't be empty.

textstring | null

The plain text body. null removes it, so sends fall back to text made from the HTML.

variablesVariable[]

Replaces the whole list. Each entry is { name, required?, example? }. See Create a template.

Response

The template with its new version. Same fields as Retrieve a template.

Errors

StatusCodeWhen
400missing_bodyThe request has no body.
400invalid_bodyA field is malformed. param names the field.
400invalid_templateA syntax error. param is subject, html or text.
404template_not_foundNo stored template with this name. Built-in templates also return this.
409template_conflictThe template changed while this update ran.