Save an email template

Overview

Save your custom version of an email type.

Use this after editing.

You'll need the type and the content.

The override is saved and used from now on.

Prerequisites

  • A bearer token. See Authentication.
  • The account's id (company_id), with the email templates section turned on.
  • The email type, from List email types.

Base URL

EnvironmentURL
Productionhttps://production-api.shoutaboutus.com
Developmenthttps://development-api.shoutaboutus.com

Endpoint

POST /api/v1/account/white-label/email-templates/save

Authentication

Partner or Account token

  • company_id must be inside your own account tree. A Partner token can use any account under the partner; an Account token only its own account.
  • An account outside your tree, or one that doesn't exist, is rejected with 422.
  • The email templates section must be turned on for the account's partner (email_templates_enabled in Get branding). When it's off, every email template call for that account returns 403 with The email template section is disabled for this account.
  • Types managed centrally by the platform return 403 (This template is managed centrally and cannot be edited here.).

Rate limit

This endpoint has no rate limit.

Request parameters

None.

Request body

A save replaces all four regions: any of header, body, footer or signature you leave out is reset to the default, so send every region you want to keep. subject_override left out is cleared too. template_mode and custom_html are kept when you leave them out.

Region fields are base64-encoded HTML.

Only the merge fields returned by List an email's merge fields for that type are accepted (the example decodes to <p>Hello [customerName]</p>, valid for user_welcome); any other token returns 422 Unknown variables for this template: [token].

FieldTypeRequiredDescription
company_idintegerYesThe account. Must exist and be inside your account tree.
typestringYesThe email type, from List email types.
headerstringNoThe header region. Base64-encoded HTML, up to 80,000 characters. Only merge fields from List an email's merge fields for this type are allowed. Left out or empty: the default is used.
bodystringNoThe body region. Base64-encoded HTML, up to 80,000 characters. Only merge fields from List an email's merge fields for this type are allowed. Left out or empty: the default is used.
footerstringNoThe footer region. Base64-encoded HTML, up to 80,000 characters. Only merge fields from List an email's merge fields for this type are allowed. Left out or empty: the default is used.
signaturestringNoThe signature region. Base64-encoded HTML, up to 80,000 characters. Only merge fields from List an email's merge fields for this type are allowed. Left out or empty: the default is used.
subject_overridestringNoThe subject, as plain text (not base64), up to 255 characters. Merge fields allowed. Left out: cleared, so the default subject is used.
template_modestringNoregions (header, body, footer and signature) or html (one full-HTML body in custom_html). Left out: unchanged.
custom_htmlstringNoThe full-HTML body for html mode, base64-encoded, up to 400,000 characters. Left out: the saved full-HTML version is kept.

Request payload

{
  "company_id": 5994,
  "type": "user_welcome",
  "body": "PHA+SGVsbG8gW2N1c3RvbWVyTmFtZV08L3A+",
  "subject_override": "Welcome to [partnerTitle]!",
  "template_mode": "regions"
}

Response body

The payload is inside data.

FieldTypeDescription
statusstringsuccess.
messagestringEmail template saved successfully.

Response payload

{
  "data": {
    "status": "success",
    "message": "Email template saved successfully."
  }
}

Examples

Success payload

See Response payload.

Error payload

403 Email templates section is off

{
  "message": "The email template section is disabled for this account.",
  "status": "error",
  "errors": []
}

403 Type managed centrally

{
  "message": "This template is managed centrally and cannot be edited here.",
  "status": "error",
  "errors": []
}

422 Unknown merge field

{
  "message": "Unknown variables for this template: [recipientName]",
  "errors": {
    "body": [
      "Unknown variables for this template: [recipientName]"
    ]
  }
}

422 template_mode isn't allowed

{
  "message": "The selected template mode is invalid.",
  "errors": {
    "template_mode": [
      "The selected template mode is invalid."
    ]
  }
}

422 Account outside your tree

{
  "message": "The selected company id does not belong to your company hierarchy.",
  "errors": {
    "company_id": [
      "The selected company id does not belong to your company hierarchy."
    ]
  }
}
StatusMeaning
200The template was saved.
401The token is missing, expired or invalid.
403The email templates section is off for this account, or the type is managed centrally.
422A field is invalid, a region uses a merge field that isn't valid for this type, or the account is outside your tree.
500Unexpected server error.

Example request

curl --request POST \
  --url "https://production-api.shoutaboutus.com/api/v1/account/white-label/email-templates/save" \
  --header 'Authorization: Bearer <bearer-token>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"company_id": 5994, "type": "user_welcome", "body": "PHA+SGVsbG8gW2N1c3RvbWVyTmFtZV08L3A+", "subject_override": "Welcome to [partnerTitle]!", "template_mode": "regions"}'

Did this page help you?