# Update a template

> Change a template’s name, description, tags or key.

<Endpoint method="PATCH" path="/v1/templates/{id}" />

<CodeTabs>

```bash tab="cURL"
curl -X PATCH https://api.muzekit.com/v1/templates/tpl_Vk1t4l9xvQv \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Product card (square)" }'
```

```javascript tab="Node"
const res = await fetch("https://api.muzekit.com/v1/templates/tpl_Vk1t4l9xvQv", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ name: "Product card (square)" }),
});
const template = await res.json();
```

```python tab="Python"
import os
import requests

template = requests.patch(
    "https://api.muzekit.com/v1/templates/tpl_Vk1t4l9xvQv",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
    json={"name": "Product card (square)"},
).json()
```

</CodeTabs>

`{id}` is the template's `tpl_…` id or its key. Send only the fields you change.

## Body

<ParamTable params={[
  { name: "name", type: "string", description: "Up to 200 characters." },
  { name: "description", type: "string", description: "Up to 2,000 characters." },
  { name: "tags", type: "string[]", description: "Replaces the tags." },
  { name: "external_id", type: "string", description: "The template's key. Change it in Test and Live, or Copy to Live treats the template as new. 409 external_id_taken when another template here has it." }
]} />

To change the content, use [Update a document](/docs/api-reference/templates-document-update).

## Examples

### Add a tag

`tags` replaces the whole list. To add one, read the template, add the tag, and send the full list. Send `[]` to clear them.

<CodeTabs>

```bash tab="cURL"
TAGS=$(curl -s https://api.muzekit.com/v1/templates/product-card \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  | jq -c '.tags + ["holiday"] | unique')

curl -X PATCH https://api.muzekit.com/v1/templates/product-card \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d "{ \"tags\": $TAGS }"
```

```javascript tab="Node"
const url = "https://api.muzekit.com/v1/templates/product-card";
const headers = {
  Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
  "Content-Type": "application/json",
};

const template = await (await fetch(url, { headers })).json();
const tags = [...new Set([...template.tags, "holiday"])];

await fetch(url, { method: "PATCH", headers, body: JSON.stringify({ tags }) });
```

```python tab="Python"
import os
import requests

url = "https://api.muzekit.com/v1/templates/product-card"
headers = {"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"}

template = requests.get(url, headers=headers).json()
tags = sorted(set(template["tags"]) | {"holiday"})

requests.patch(url, headers=headers, json={"tags": tags})
```

</CodeTabs>

### Change a template's key

Copy to Live matches templates by key, so change it with your Test key (`mk_test_…`) and your Live key (`mk_live_…`). Keys are stored in lower case. A key another template in that environment has answers `409 external_id_taken`.

<CodeTabs>

```bash tab="cURL"
for KEY in "$MUZEKIT_TEST_SECRET_KEY" "$MUZEKIT_LIVE_SECRET_KEY"; do
  curl -X PATCH https://api.muzekit.com/v1/templates/product-card \
    -H "Authorization: Bearer $KEY" \
    -H "Content-Type: application/json" \
    -d '{ "external_id": "product-card-square" }'
done
```

```javascript tab="Node"
const keys = [
  process.env.MUZEKIT_TEST_SECRET_KEY,
  process.env.MUZEKIT_LIVE_SECRET_KEY,
];

for (const key of keys) {
  await fetch("https://api.muzekit.com/v1/templates/product-card", {
    method: "PATCH",
    headers: {
      Authorization: `Bearer ${key}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ external_id: "product-card-square" }),
  });
}
```

```python tab="Python"
import os
import requests

for key in ["MUZEKIT_TEST_SECRET_KEY", "MUZEKIT_LIVE_SECRET_KEY"]:
    requests.patch(
        "https://api.muzekit.com/v1/templates/product-card",
        headers={"Authorization": f"Bearer {os.environ[key]}"},
        json={"external_id": "product-card-square"},
    )
```

</CodeTabs>

### Rename an end user's design

User designs are updated the same way, by their `tpl_…` id from [List templates](/docs/api-reference/templates-list) with `user`. Use it when your app lets users rename designs outside the editor.

<CodeTabs>

```bash tab="cURL"
curl -X PATCH https://api.muzekit.com/v1/templates/tpl_Vk1t4l9xvQv \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Spring flyer", "description": "Final version for print" }'
```

```javascript tab="Node"
const res = await fetch("https://api.muzekit.com/v1/templates/tpl_Vk1t4l9xvQv", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "Spring flyer",
    description: "Final version for print",
  }),
});
const design = await res.json();
```

```python tab="Python"
import os
import requests

design = requests.patch(
    "https://api.muzekit.com/v1/templates/tpl_Vk1t4l9xvQv",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
    json={"name": "Spring flyer", "description": "Final version for print"},
).json()
```

</CodeTabs>

## Response

The updated [template](/docs/api-reference/templates-get).

```json
{
  "object": "template",
  "id": "tpl_Vk1t4l9xvQv",
  "name": "Product card (square)",
  "description": null,
  "tags": ["shop"],
  "external_id": "product-card",
  "user": null,
  "source": "api",
  "version": { "id": "ver_…", "number": 1, "revision": 3 },
  "width": 1080,
  "height": 1080,
  "page_count": 1,
  "thumbnail_url": "https://storage.muzekit.com/…/r1.png",
  "created_at": "2026-10-17T02:10:00.000Z",
  "updated_at": "2026-10-18T09:42:00.000Z"
}
```
