> ## Documentation Index
> Fetch the complete documentation index at: https://docs.drin.run/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a template

> PATCH /v1/templates/{id} — partially update a saved template's name, subject, or body.

Partial update — send only the fields you want to change. The rest are left untouched.

**`PATCH /v1/templates/{id}`**

## Path parameters

<ParamField body="id" type="string" required>
  The template `id` to update.
</ParamField>

## Body parameters

All fields are optional; omitted fields keep their current value.

<ParamField body="name" type="string">
  New display name.
</ParamField>

<ParamField body="subject" type="string">
  New subject line.
</ParamField>

<ParamField body="html" type="string | null">
  New HTML body. Pass `null` to clear it.
</ParamField>

<ParamField body="text" type="string | null">
  New plain-text body. Pass `null` to clear it.
</ParamField>

<ParamField body="slug" type="string">
  New slug. Must stay unique within the project.
</ParamField>

## Request

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.drin.run/v1/templates/tmpl_8XQ2k9 \
    -X PATCH \
    -H "Authorization: Bearer $DRIN_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "subject": "Your receipt — order {{orderId}}",
      "text": "Hi {{firstName}}, thanks for your order."
    }'
  ```

  ```typescript Node.js theme={null}
  import { DrinClient } from "@drin00/sdk";

  const drin = new DrinClient({ apiKey: process.env.DRIN_API_KEY });

  const template = await drin.templates.update("tmpl_8XQ2k9", {
    subject: "Your receipt — order {{orderId}}",
    text: "Hi {{firstName}}, thanks for your order.",
  });
  ```
</CodeGroup>

## Response

Returns the full template with a refreshed `updatedAt` and a recomputed `variables` list.

```json 200 OK theme={null}
{
  "id": "tmpl_8XQ2k9",
  "slug": "order-receipt",
  "name": "Order Receipt",
  "subject": "Your receipt — order {{orderId}}",
  "html": "<p>Hi {{firstName}}, thanks for your order.</p>",
  "text": "Hi {{firstName}}, thanks for your order.",
  "variables": ["firstName", "orderId"],
  "createdAt": "2026-06-02T10:00:00.000Z",
  "updatedAt": "2026-06-02T11:30:00.000Z"
}
```

<Warning>
  **Slug collisions.** Changing `slug` to one already taken in the project returns `409 conflict` (`template_slug_taken`).
</Warning>
