Update email templates

put

/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

Supported Media Types
Path Parameters
Body ()
Root Schema : updateEmailTemplates_request
Type: object
Show Source
  • Path to previously uploaded zip file containing email templates to apply for the specified email type.
Example:
{
    "filename":"notifications/uploads/abandoned_order_v1.zip"
}
Back to Top

Response

Supported Media Types

200 Response

Returned when the operation completes without error.
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.
Body ()
Root Schema : updateEmailTemplates_200_response
Type: object
Show Source
Nested Schema : errors
Type: array
Errors reported for the update.
Show Source
Nested Schema : warnings
Type: array
Warnings reported for the update.
Show Source
Example Response (application/json)
{
    "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

Returned if the filename parameter is empty.
Body ()
Root Schema : updateEmailTemplates_400_response
Type: object
Show Source

404 Response

Returned if the email type does not exist.
Body ()
Root Schema : updateEmailTemplates_404_response
Type: object
Show Source

Default Response

The following internal error codes are thrown by this API when the request fails in Commerce:
Error CodeDescriptionPossible Fix
950031Property 'filename' must exist in the request body.Ensure you have specified a filename.
950046Cannot update OCCS Email Notification Type.Specify another notification type.
950047Notification Type ID has not been specified.Specify a valid 'emailTypeId'.
950029Read-only email type.Specify a valid 'emailTypeId'.
950030Internal server error.See returned error messages for further information.

The error response:
Body ()
Root Schema : errorModel
Type: object
Show Source
Nested Schema : errors
Type: array
An optional list of errors if multiple errors were encountered
Show Source
Nested Schema : items
Type: object
Show Source
Back to Top