सामग्री पर जाएं

Email Templates API

यह सामग्री अभी तक आपकी भाषा में उपलब्ध नहीं है।

The Email Templates API manages the reusable email templates behind an application’s email presets — the same templates you build in the Control Panel’s email editor. Each template stores per-locale subjects, sender info, and editor content, and is identified by the code of the email preset it’s connected to. Use that code to send the template through Notify (email payload email_template) or a Customer Journey Send email point.

https://rpc-api.svc-nue.pushwoosh.com

All endpoints are served over HTTPS. Requests and responses use application/json unless noted otherwise.

Authentication

Anchor link to

Every request must include an Authorization header with your Server API token:

Authorization: Api YOUR_API_TOKEN

Conventions

Anchor link to
  • Field naming: request bodies and query/path parameters accept lowerCamelCase (for example, previewSettings, searchByLabel, includeHtml) — the server unmarshals either casing. Responses are always marshaled using the proto field names, in snake_case (per_page, email_template, sender_info, preview_settings, and so on). The response examples and the object reference below use that casing.
  • code: every template response carries the code of its connected email preset, not an internal template ID. Pass this same code to Get, Update, Delete, and to the messaging/journey APIs above.
  • Unpopulated fields: responses include all fields, even when empty or zero-valued.

Error responses

Anchor link to
HTTP statusMeaning
400 Bad RequestInvalid argument — a required field is missing or malformed, or a precondition failed (for example, deleting a template still used by a journey).
401 UnauthorizedMissing or invalid Authorization header.
403 ForbiddenThe application or preset does not belong to the caller’s account.
404 Not FoundThe template, preset, or application was not found.
500 Internal Server ErrorUnexpected server-side failure.
MethodPathDescription
POST/api/email_templatesCreate a new email template
GET/api/email_templatesList an application’s email templates
GET/api/email_templates/{code}Get a single email template
PUT/api/email_templates/{code}Update an email template
DELETE/api/email_templates/{code}Delete an email template
POST/api/email_templates:cloneClone an email template into an application

Creates a new email template — its editor content plus a connected email preset — in an application, and returns the generated template code.

POST /api/email_templates

Request body

Anchor link to
ParameterTypeRequiredDescription
applicationstringYesThe Pushwoosh application code to create the template in.
namestringYesTemplate name, 1–255 characters.
contentobjectYesThe email content object.
labelstringNoFree-text label, up to 255 characters.
categoriesarray of stringsNoCategory names to tag the template with.
previewSettingsobjectNoArbitrary editor preview settings, stored and returned as-is.
systembooleanNoMarks the template as a system template — an internal feature, e.g. a synced-block fragment. System templates are hidden from List (see note below), but stay reachable by code. Defaults to false.
Request example
Anchor link to
{
"application": "XXXXX-XXXXX",
"name": "Welcome email",
"label": "onboarding",
"categories": ["lifecycle"],
"content": {
"senderInfo": {
"from": { "email": "hello@acme.com", "name": "Acme" },
"replyTo": { "email": "support@acme.com", "name": "Acme Support" }
},
"subject": { "en": "Welcome to Acme!", "default": "Welcome to Acme!" },
"mjml": {
"mjml": "<mjml><mj-body><mj-section><mj-column><mj-text>Welcome, {name|string|there}!</mj-text></mj-column></mj-section></mj-body></mjml>",
"html": "<html>...</html>",
"localizationData": { "default": { "name": "there" } },
"settings": {}
}
}
}

Returns { "email_template": { ... } } — the created email template object, but without content (this endpoint doesn’t echo it back). Call Get with the returned code if you need to read the content back.

Lists an application’s email templates — metadata only, no content — with paging, ordering, and filtering by name, label, or category.

GET /api/email_templates

Query parameters

Anchor link to
ParameterTypeRequiredDescription
applicationstringYesThe application code to list templates for.
orderBystringNoNAME (default), CREATED, or UPDATED.
orderDirectionstringNoASC (default) or DESC.
pageintegerNoZero-based page index.
perPageintegerNoPage size. Defaults to 100 when omitted or 0. This endpoint doesn’t enforce an explicit maximum.
searchByNamestringNoSubstring match (like %value%) against the template’s name or its code — either matching is enough.
searchByLabelstringNoSubstring match on label (like %label%), or exact match when strictSearchByLabel is true.
strictSearchByLabelbooleanNoUse exact-match instead of substring for searchByLabel.
searchByCategoryarray of stringsNoRepeat the parameter to filter by any of several categories, e.g. ?searchByCategory=lifecycle&searchByCategory=promo.
FieldTypeDescription
email_templatesarray of objectsThe current page of email template objects. content is null on every item.
pageintegerThe returned page index.
per_pageintegerThe page size used for this response.
totalintegerTotal number of templates matching the filters, across all pages.
Response example
Anchor link to
{
"email_templates": [
{ "code": "AAAAA-BBBBB", "name": "Welcome email", "label": "onboarding", "categories": ["lifecycle"] }
],
"page": 0,
"per_page": 100,
"total": 1
}

Returns a single email template by its code, including sender info, per-locale subjects, and the full editor content.

GET /api/email_templates/{code}

Path parameters

Anchor link to
ParameterTypeDescription
codestringThe template’s code (its connected email preset code).

Query parameters

Anchor link to
ParameterTypeRequiredDescription
includeHtmlbooleanNoWhether to return the rendered html alongside the editor content. Defaults to true. Set to false to skip it — it’s typically over half the payload, and the editor content already describes the template.

Returns { "email_template": { ... } }, the full email template object.

Updates an existing email template by code, overwriting the supplied fields.

PUT /api/email_templates/{code}

Path parameters

Anchor link to
ParameterTypeDescription
codestringThe template’s code to update.

Request body

Anchor link to
ParameterTypeRequiredDescription
namestringNoNew name, 1–255 characters. Omit to keep the current name.
contentobjectNoNew email content object, replacing the stored content in full. Omit to leave the content unchanged.
labelstringNoNew label. Always overwritten — omit or send "" to clear it.
categoriesarray of stringsNoNew full set of category names. Omit to leave categories unchanged; send [] to clear them.
previewSettingsobjectNoNew preview settings. Omit to leave unchanged.
Request example
Anchor link to
{
"name": "Welcome email v2",
"label": "onboarding",
"content": {
"senderInfo": { "from": { "email": "hello@acme.com", "name": "Acme" } },
"subject": { "default": "Welcome to Acme — updated!" },
"mjml": {
"mjml": "<mjml>...</mjml>",
"html": "<html>...</html>",
"localizationData": {},
"settings": {}
}
}
}

Returns { "email_template": { ... } } — the updated email template object, also without content. Call Get if you need to read the content back.

Deletes an email template and its connected preset by code, removing the stored content.

DELETE /api/email_templates/{code}

Path parameters

Anchor link to
ParameterTypeDescription
codestringThe template’s code to delete.

An empty object on success: {}.

Clones an email template — its content and preset — into a destination application, optionally under a new name.

POST /api/email_templates:clone

Request body

Anchor link to
ParameterTypeRequiredDescription
emailPresetCodestringYesThe template’s code (as returned by Create, Get, List, or Update) to clone. Named emailPresetCode here because it’s the code of the connected email preset — see Conventions.
applicationstringYesDestination application code. Can be the same application, or a different one owned by the same account.
namestringNoName for the clone, 1–255 characters. Defaults to the source template’s name.
Request example
Anchor link to
{
"emailPresetCode": "AAAAA-BBBBB",
"application": "YYYYY-YYYYY",
"name": "Welcome email (copy)"
}
FieldTypeDescription
email_preset_codestringThe new template’s code — the same identifier Get/Update/Delete call code.

Object reference

Anchor link to

Field names below match what Get, List, Update, and Create actually return — snake_case proto field names (see Conventions). When you send these same structures back in a request body (Create, Update), the lowerCamelCase form used in the request examples above works too; the server accepts either casing on input.

Email template object

Anchor link to
FieldTypeDescription
codestringCode of the connected email preset. Identifies this template everywhere else in the API.
namestringTemplate name.
labelstringFree-text label.
categoriesarray of stringsCategory names.
contentobjectThe email content object. Populated only by Get; null in Create, List, and Update responses.
preview_settingsobjectArbitrary editor preview settings.
createdstring (RFC 3339)Creation timestamp.
updatedstring (RFC 3339)Last update timestamp.

Email content object

Anchor link to
FieldTypeDescription
sender_infoobjectSender info objectfrom and reply_to addresses.
subjectobject (map)Per-locale subject, e.g. { "en": "Subject", "default": "Subject" }.
unlayer / pushwoosh / mjml / smartcards / vibeblocksobjectThe editor content. Exactly one of these must be set — it selects which editor produced (and will render) the template. See editor kinds below.

Editor kinds

Anchor link to
KindFieldRequired sub-fieldsDescription
unlayerhtml, localization_data, editor_configeditor_config, localization_dataDrag-and-drop block editor (Unlayer). editor_config is the Unlayer design JSON.
pushwooshhtml, localization_datalocalization_dataPushwoosh’s own HTML-based editor.
mjmlmjml, html, localization_data, settingsmjml, localization_data, settingsMJML source, plus the last-rendered html. Recommended for programmatic/API-authored templates.
smartcardshtml, localization_data, contentcontent, localization_dataSmart Cards block editor; content is its editor-specific JSON.
vibeblockshtml, localization_data, contentcontent, localization_dataVibeblocks block editor; content is its editor-specific JSON.

In every kind, html is the rendered output. localization_data is that editor’s own per-locale content: an object keyed by locale code (en, es, default, …), where each value is that locale’s copy of the editor’s fields. Its inner shape is editor-specific and opaque to this API — the API stores and returns it as-is. It’s required on Create/Update for every kind (send {} if there’s nothing to localize).

Text inside html, mjml, or a localization_data value can include Dynamic Content tags, e.g. {name|string|there} — those resolve against the recipient’s device Tags when the email is actually sent. This API doesn’t resolve them; it just stores and returns whatever text you put there.

Sender info object

Anchor link to
FieldTypeDescription
fromobject{ "email": string, "name": string } — sender address.
reply_toobject{ "email": string, "name": string } — reply-to address.

Both email sub-fields, when non-empty, must be valid email addresses.