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
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Optional | Rename the template (max 255 chars). |
description | string | Optional | Update the description (max 1000 chars). |
subject | string | Optional | New subject line (max 998 chars). Bumps version. |
html | string | Optional | New HTML body — sanitized like on create. Bumps version. |
text_body | string | Optional | New plain-text body. Bumps version. |
vars_schema | object | Optional | Update the declared variables. Does not bump version. |
active | boolean | Optional | Deactivate a template without deleting it. |
category | string | Optional | Re-categorise (max 100 chars). Does not bump version. |
Responses
| Status | Description |
|---|---|
200 | OK. The updated template. |
400 | Validation error, or the HTML references a blocked image URL. |
401 | Missing or invalid API key. |
404 | No 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()