Update a template

Save a new version of an existing template.

Send only the fields you want to change. Saving subject, html or text_body bumps the template's version; changing name, description, vars_schema, category or active does not.

PUT /v3/templates/{id}

Body parameters

ParameterTypeRequiredDescription
namestringOptionalRename the template (max 255 chars).
descriptionstringOptionalUpdate the description (max 1000 chars).
subjectstringOptionalNew subject line (max 998 chars). Bumps version.
htmlstringOptionalNew HTML body — sanitized like on create. Bumps version.
text_bodystringOptionalNew plain-text body. Bumps version.
vars_schemaobjectOptionalUpdate the declared variables. Does not bump version.
activebooleanOptionalDeactivate a template without deleting it.
categorystringOptionalRe-categorise (max 100 chars). Does not bump version.

Responses

StatusDescription
200OK. The updated template.
400Validation error, or the HTML references a blocked image URL.
401Missing or invalid API key.
404No template with this id on your account.

Code examples

cURL
curl -X PUT https://api.wemail.io/v3/templates/{id} \
  -H "Authorization: Bearer afn_live_…" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Welcome email v2", "subject": "Welcome, {{name}}!", "html": "<h1>Welcome aboard, {{name}}!</h1>" }'
Node.js
const res = await fetch("https://api.wemail.io/v3/templates/{id}", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.WEMAIL_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ "name": "Welcome email v2", "subject": "Welcome, {{name}}!", "html": "<h1>Welcome aboard, {{name}}!</h1>" }),
});
const data = await res.json();
Python
import os, requests

r = requests.put(
    "https://api.wemail.io/v3/templates/{id}",
    headers={"Authorization": f"Bearer {os.environ['WEMAIL_API_KEY']}"},
    json={ "name": "Welcome email v2", "subject": "Welcome, {{name}}!", "html": "<h1>Welcome aboard, {{name}}!</h1>" },
)
data = r.json()