---
title: "saveTemplate"
method: POST
path: "/v1/email-template/templates"
tags: ["Email templates"]
---

# saveTemplate

`POST /v1/email-template/templates`

Create or update a template. If `id` is provided, it will update the template.

## Request body

- EmailTemplateRequest
  - `_id` string
  - `_tags` string[] — Entity tags
  - `_manifest` string[] — Manifest ID used to create/update the entity
  - `_purpose` string[] — Entity Purposes
  - `name` string, required — name
  - `brand_id` number, nullable — Brand ID. Equal 0 if available for All brands
  - `from` From
    - `name` string
    - `email` string, required
  - `to` To[] — To
    - `name` string
    - `email` string, required
  - `cc` To[] — Cc
    - `name` string
    - `email` string, required
  - `bcc` To[] — Bcc
    - `name` string
    - `email` string, required
  - `subject` string, required — Subject
  - `body` string — Body
  - `attachments` Attachment[], nullable — Email template attachments
    - `cid` string — Attachment ID
    - `filename` string, required — File name
    - `size` number, required — File size in bytes
    - `content_type` string, required — Content type
    - `url` string — URL to download the attachment.
    - `bucket` string, required — S3 bucket where file is stored
    - `object_key` string, required — S3 object apiKey
    - `inline` boolean — If true then this attachment should not be offered for download (at least not in the main attachments list).\ The usecase is CID embedded image (aka inline image).
    - `send_as_link` boolean — If true then this attachment is sent via link. The link is already inserted to email body by API caller. In this case, service doesn't process this attachment.
    - `type` string — File type such as Document template, Document,... Use for replace variables on document template
    - `copy_to_message` boolean — If true then this attachment is copied to the message and replaces corresponding one
  - `file` object
    - `$relation` object[] — Entity tags
  - `system_template` boolean — If template is created by system (Double Opt-in, CMD invitation,...) then true, and some attributes can not be edited such as Name, To,... Remember to add default content of template to [system-template.ts](https://gitlab.com/e-pilot/product/email-templates/svc-email-templates-api/-/blob/main/lambda/HandlerFunction/src/enum/system-template.ts) enum for revert to original feature
  - `created_by` string — Created by
  - `updated_by` string — Updated by
  - `json_template` string — This field is used to store JSON templates. If this field is populated, then the Body html is derived from the JSON.
  - `original_template_id` string, nullable — Set on a duplicated template to point at its source template id. Cleared (set to null) after automations referencing the source have been migrated onto the new template via `migrateAutomationsForTemplate`.
  - `backup` object — Snapshot of the legacy template body, taken when migrating to the email-builder format.
    - `body` string — Original HTML body before conversion to email-builder blocks.
    - `backed_up_at` string — ISO 8601 timestamp when the backup was created.
  - `converted_to_new_editor` boolean — True after the template has been converted from legacy HTML to the new email-builder format. Used by the UI to expose the "Revert to legacy HTML" action.

## Response `200`

Success

- EmailTemplateEntity
  - `_id` string, required — Entity ID
  - `_title` string, required — Entity title
  - `_org` string, required — Ivy Organization ID the entity belongs to
  - `_schema` string, required — URL-friendly identifier for the entity schema
  - `_tags` string[] — Entity tags
  - `_created_at` string, date-time, required — Created date
  - `_updated_at` string, date-time, required — Updated date
  - `_purpose` string[] — Entity Purposes
  - `_manifest` string[] — Manifest ID used to create/update the entity
  - `name` string, required — name
  - `brand_id` number, nullable — Brand ID. Equal 0 if available for All brands
  - `from` From
    - `name` string
    - `email` string, required
  - `to` To[] — To
    - `name` string
    - `email` string, required
  - `cc` To[] — Cc
    - `name` string
    - `email` string, required
  - `bcc` To[] — Bcc
    - `name` string
    - `email` string, required
  - `subject` string — Subject
  - `body` string — Body
  - `attachments` Attachment[], nullable — Email template attachments
    - `cid` string — Attachment ID
    - `filename` string, required — File name
    - `size` number, required — File size in bytes
    - `content_type` string, required — Content type
    - `url` string — URL to download the attachment.
    - `bucket` string, required — S3 bucket where file is stored
    - `object_key` string, required — S3 object apiKey
    - `inline` boolean — If true then this attachment should not be offered for download (at least not in the main attachments list).\ The usecase is CID embedded image (aka inline image).
    - `send_as_link` boolean — If true then this attachment is sent via link. The link is already inserted to email body by API caller. In this case, service doesn't process this attachment.
    - `type` string — File type such as Document template, Document,... Use for replace variables on document template
    - `copy_to_message` boolean — If true then this attachment is copied to the message and replaces corresponding one
  - `file` object
    - `$relation` object[] — Entity tags
  - `created_by` string — Created by
  - `updated_by` string — Updated by
  - `json_template` string — This field is used to store JSON templates. If this field is populated, then the Body html is derived from the JSON.
  - `backup` object — Snapshot of the legacy template body, taken when migrating to the email-builder format.
    - `body` string — Original HTML body before conversion to email-builder blocks.
    - `backed_up_at` string — ISO 8601 timestamp when the backup was created.
  - `converted_to_new_editor` boolean — True after the template has been converted from legacy HTML to the new email-builder format. Used by the UI to expose the "Revert to legacy HTML" action.
  - `system_template` boolean — If template is created by system (Double Opt-in, CMD invitation,...) then true, and some attributes can not be edited such as Name, To,... Remember to add default content of template to system_template enum for revert to original feature
  - `original_template_id` string, nullable — Set on a duplicated template to point at its source template id. Cleared after automations have been migrated via `migrateAutomationsForTemplate`.

## Other responses

- `403` — Forbidden

---

[API](https://skmtc.dev/epilot/apis/email-template-api.md) · [All operations](https://skmtc.dev/epilot/apis/email-template-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/epilot/email-template-api/revisions/0c6165eaceb0/schema)
