---
title: "Update Template"
method: PUT
path: "/templates/{slug}"
tags: ["Templates"]
---

# Update Template

`PUT /templates/{slug}`

## Request

- Base URL: `https://app.lettr.com/api`
- URL: `https://app.lettr.com/api/templates/{slug}`
- Auth: HTTP bearer

Update an existing email template's name and/or content. If content (html or json) is provided, a new active version will be created with extracted merge tags. If `project_id` is not provided, the template will be looked up in the team's default project.

## Path parameters

- `slug` string, required

## Request body

- UpdateTemplateRequest: Request to update an existing email template. All fields are optional - provide only what you want to change. If `html` or `json` is provided, a new active version will be created. `purpose` is **not** updatable and is not listed below. Sending it here is silently ignored: the request returns `200` with `Template updated successfully.` and the template keeps the purpose it was created with. To move a template to the other module, copy it — a transactional template cannot become a campaign one in place.
  - `project_id` integer: Project ID to find the template in. If not provided, uses the team's default project.
  - `name` string: New name for the template
  - `html` string: New HTML content for the template. Creates a new active version. Mutually exclusive with `json`.
  - `json` string: New JSON content for Topol visual editor templates. Creates a new active version. Mutually exclusive with `html`.

## Response `200`

Template updated successfully

- UpdateTemplateResponse: Response after successfully updating a template
  - `message` string, required: Human-readable response message
  - `data` UpdatedTemplateView, required: View of an updated template
    - `id` integer, required: Unique identifier for the template
    - `name` string, required: Name of the template
    - `slug` string, required: URL-friendly identifier for the template
    - `project_id` integer, required: ID of the project containing this template
    - `folder_id` integer, required: ID of the folder containing this template
    - `purpose` 'transactional' | 'campaign', required: Module the template belongs to. `transactional` templates are the ones you send single emails with; `campaign` templates are the ones the campaign builder can pick.
    - `preparation_status` 'pending' | 'ready' | 'failed', required: How far the template has got through preparation. Creating or updating a template through the API defers image migration and HTML rendering to a background job, so the template is `pending` until that finishes. On a create with JSON there is no HTML at all yet - the editor works (it reads the JSON) but sending and the screenshot do not. On an update the previous render stays in place, so the template remains sendable, but it is still serving the *old* content until this reads `ready`. `failed` means preparation exhausted its retries and will not become ready on its own. A template created from raw HTML is `ready` immediately.
    - `active_version` integer, required: Version number of the active template version
    - `merge_tags` MergeTagView[], required: List of merge tags extracted from the template content
      - `key` string, required: The merge tag key/name used in templates
      - `required` boolean, required: Whether this merge tag is required when sending emails
      - `type` 'text' | 'number' | 'image' | 'button': The data type of the merge tag (only present for loop children)
      - `children` MergeTagChild[]: Child merge tags for loop blocks. Each child represents a field available within the loop iteration.
        - `key` string, required: The child merge tag key/name
        - `type` 'text' | 'number' | 'image' | 'button': The data type of the child merge tag
    - `created_at` string, date-time, required: When the template was created
    - `updated_at` string, date-time, required: When the template was last updated

## Other responses

- `401`: Unauthorized - Missing or invalid API key
- `404`: Template or project not found
- `422`: Validation error
- `500`: Server error
- `503`: Service unavailable - the API key could not be verified, so the request was not processed. This does not mean the key is invalid; retry after the delay given in the Retry-After header.

---

[API](https://skmtc.dev/lettr/apis/lettr-api.md) · [All operations](https://skmtc.dev/lettr/apis/lettr-api/llms.txt) · [OpenAPI document](https://skmtc.dev/lettr/apis/lettr-api/revisions/48ef0dac1ebd?raw)
