---
title: "Update a template"
method: PATCH
path: "/v1/templates/{id}"
tags: ["templates"]
---

# Update a template

`PATCH /v1/templates/{id}`

## Request

- Base URL: `https://api.wraps.dev`
- URL: `https://api.wraps.dev/v1/templates/{id}`
- Auth: HTTP bearer

Partial update, org-scoped. Last-write-wins unless ifUnmodifiedSince is sent. When source changes, a new templateVersion row is written (skipped if the source is unchanged from the latest version).

## Path parameters

- `id` string, required

## Request body

- object
  - `name` string
  - `subject` string
  - `previewText` string
  - `description` string
  - `emailType` union
    - string
    - string
  - `channel` union
    - string
    - string
  - `source` string: React Email TSX source
  - `compiledHtml` string
  - `compiledText` string
  - `variables` object[]
    - `name` string, required
    - `fallback` string
  - `ifUnmodifiedSince` string, date-time: Optimistic-concurrency guard. When present and the stored updatedAt is later, the update is rejected with 409 instead of overwriting.

## Response `200`

- object
  - `id` string, required
  - `name` string, required
  - `description` string, required
  - `subject` string, required
  - `previewText` string, required
  - `emailType` string, required
  - `channel` string, required
  - `status` string, required
  - `slug` string, required
  - `publishedAt` string, required
  - `createdAt` string, required
  - `updatedAt` string, required
  - `sourceHash` string, required
  - `variables` unknown[], required
    - unknown
  - `lastEditedFrom` string, required
  - `source` string
  - `compiledHtml` string
  - `compiledText` string

## Other responses

- `400`: Malformed request — unparseable body or an invalid parameter.
- `401`: Missing, malformed, or revoked credentials. Send `Authorization: Bearer <api key>`.
- `403`: Authenticated, but the resource belongs to another organization.
- `404`: No such route, or no such resource in this organization.
- `409`
- `422`: The request parsed but failed schema validation.
- `429`: Rate limit exceeded. Wait for the window named by the RateLimit headers.
- `500`: Unexpected server failure. Safe to retry with backoff; quote `requestId` if it persists.

---

[API](https://skmtc.dev/wraps/apis/wraps-platform-api.md) · [All operations](https://skmtc.dev/wraps/apis/wraps-platform-api/llms.txt) · [OpenAPI document](https://skmtc.dev/wraps/apis/wraps-platform-api/revisions/12116fb21af7?raw)
