Update email templates
/ccadmin/v1/email/types/{emailTypeId}/templates
Uploads custom Freemarker templates for the subject and body of the email type for a specific site, along with associated locale-specific resource files. These allow you to apply site-specific custom email formatting for the given email type.
The custom email templates and locale resources must first be uploaded in zip form using the file's admin endpoints (startFileUpload and doFileSegmentUpload).
These file endpoints and the updateEmailTemplate endpoint support the site context specified using the X-CCSite request header, which should specify the applicable site. If the site is omitted, the default site is assumed.
The email type to be updated is identified by the {emailTypeId} path parameter. The emailTypeId parameter must correspond to the ID of an existing email type; for example, the emailTypeId for the Abandon Order email type is abandon_order_v1. The updateEmailTemplate endpoint takes a JSON request body where the location of the uploaded zip file is specified via a filename field.
Request
- application/json
-
emailTypeId: string
The ID of the email type.
object
-
filename:
string
Path to previously uploaded zip file containing email templates to apply for the specified email type.
{
"filename":"notifications/uploads/abandoned_order_v1.zip"
}
Response
- application/json
200 Response
Note: The success property in the response indicates whether the update was successful or not.
If successful, it will return the success property as true and no further action is needed.
If the success property is false, the error array property in the response shows any errors.
A table of possible errors is listed below.
Error Array Descriptions |
---|
Uploaded zip file does not contain subject.ftl file |
The uploaded zip file does not contain html_body.ftl or text_body.ftl |
Strings.xlf for the default locale must be present under locales/'locale' |
The contents of the Freemarker templates (subject.ftl, html_body.ftl or text_body.ftl) are invalid. |
Duplicate resources (xx_yy and xx-yy folders under locales) |
Note:If any errors occur during validation checks, the uploaded template will not be applied.
object
-
displayName(optional):
string
The display name for the email type
-
errors(optional):
array errors
Errors reported for the update.
-
success(optional):
boolean
true - if update was successful, false - if update was unsuccessful
-
warnings(optional):
array warnings
Warnings reported for the update.
{
"success":true,
"displayName":"Abandoned Cart",
"warnings":[
"Locale 'sh' referenced in 'locales/sh/Strings.xlf' is not a supported locale. This folder and its contents will not be uploaded."
],
"links":[
{
"rel":"self",
"href":"http://admin.example.com/ccadminui/v1/email/types/abandoned_order_v1/templates"
}
],
"errors":[
]
}
400 Response
object
-
errorCode(optional):
string
950031
-
message(optional):
string
Filename is required for update email templates.
-
status(optional):
string
400
404 Response
object
-
errorCode(optional):
string
00000000
-
message(optional):
string
Email type nonesuch does not exist.
-
status(optional):
string
400
Default Response
Error Code | Description | Possible Fix |
---|---|---|
950031 | Property 'filename' must exist in the request body. | Ensure you have specified a filename. |
950046 | Cannot update OCCS Email Notification Type. | Specify another notification type. |
950047 | Notification Type ID has not been specified. | Specify a valid 'emailTypeId'. |
950029 | Read-only email type. | Specify a valid 'emailTypeId'. |
950030 | Internal server error. | See returned error messages for further information. |
The error response:
object
-
devMessage(optional):
string
An optional non-localized message containing technical information for developers
-
errorCode(optional):
string
The numerical code identifying the error
-
errors(optional):
array errors
An optional list of errors if multiple errors were encountered
-
message(optional):
string
The localized message describing the error
-
moreInfo(optional):
string
An optional non-localized message with more information
-
o:errorPath(optional):
string
An optional machine readable description of where the error occurred
-
status(optional):
string
The HTTP status code
-
type(optional):
string
The URI to the HTTP state code definition
array
object
-
devMessage(optional):
string
An optional non-localized message containing technical information for developers
-
errorCode(optional):
string
The numerical code identifying the error
-
message(optional):
string
The localized message describing the error
-
moreInfo(optional):
string
An optional non-localized message with more information
-
o:errorPath(optional):
string
An optional machine readable description of where the error occurred
-
status(optional):
string
The HTTP status code