# Duplicate a template

> Copy a template's current version into a new template with its own key, or into one end user's designs.

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

<CodeTabs>

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

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

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

copy = requests.post(
    "https://api.muzekit.com/v1/templates/product-card/duplicate",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
    json={"name": "Product card (holiday)", "external_id": "product-card-holiday"},
).json()
```

</CodeTabs>

`{id}` is the template's `tpl_…` id or its key.

## Body

<ParamTable params={[
  { name: "name", type: "string", description: "The copy's name. The original's name with \"copy\" when left out." },
  { name: "external_id", type: "string", description: "The copy's key. Made from the name when left out (workspace templates only)." },
  { name: "user", type: "usr_…", description: "Make the copy one of this end user's designs instead of a workspace template." }
]} />

The copy starts with one version, the original's current one, and keeps its description and tags. Without `user` it is a workspace template, even when the original is a user's design. With `user` it is that user's design: it has no key unless you send `external_id`, and it lists under `GET /v1/templates?user=usr_…`. A `template.created` webhook goes out with `source: "duplicate"` and the `user` (or `null`).

A `user` that isn't a `usr_…` id answers `400`; one that isn't in this key's environment answers `404 user_not_found`. To let a user start from your template in the editor instead, open a [`fill` session](/docs/editor-modes#fill-mode-and-fields) on it: their first change saves their own copy.

## Examples

### Make a variant under its own key

Copy a template for a season or a client, then render the copy by its new key. The original stays as it was.

<CodeTabs>

```bash tab="cURL"
curl -X POST https://api.muzekit.com/v1/templates/product-card/duplicate \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Product card (Acme)", "external_id": "product-card-acme" }'

# Later renders name the copy by its key
curl https://api.muzekit.com/v1/renders \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "template": "product-card-acme", "modifications": { "headline": "Hi" } }'
```

```javascript tab="Node"
const headers = {
  Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
  "Content-Type": "application/json",
};

await fetch("https://api.muzekit.com/v1/templates/product-card/duplicate", {
  method: "POST",
  headers,
  body: JSON.stringify({
    name: "Product card (Acme)",
    external_id: "product-card-acme",
  }),
});

// Later renders name the copy by its key
await fetch("https://api.muzekit.com/v1/renders", {
  method: "POST",
  headers,
  body: JSON.stringify({
    template: "product-card-acme",
    modifications: { headline: "Hi" },
  }),
});
```

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

API = "https://api.muzekit.com/v1"
headers = {"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"}

requests.post(
    f"{API}/templates/product-card/duplicate",
    headers=headers,
    json={"name": "Product card (Acme)", "external_id": "product-card-acme"},
)

# Later renders name the copy by its key
requests.post(
    f"{API}/renders",
    headers=headers,
    json={"template": "product-card-acme", "modifications": {"headline": "Hi"}},
)
```

</CodeTabs>

A key that another template in this environment already has returns `409 external_id_taken`.

### Keep a copy before you change a document

[Update a document](/docs/api-reference/templates-document-update) saves over the current version in place. Duplicate the template first when you want to keep the old design.

<CodeTabs>

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

```javascript tab="Node"
const res = await fetch(
  "https://api.muzekit.com/v1/templates/tpl_Vk1t4l9xvQv/duplicate",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ name: "Product card (backup 2026-11-29)" }),
  },
);
const backup = await res.json(); // backup.id is the copy's tpl_… id
```

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

backup = requests.post(
    "https://api.muzekit.com/v1/templates/tpl_Vk1t4l9xvQv/duplicate",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
    json={"name": "Product card (backup 2026-11-29)"},
).json()
```

</CodeTabs>

### Give a user their own copy of your template

Copy a starter template into a user's designs before they first open the editor, so it waits in their "My designs" list. Open it later with a `design` session on the copy's id.

<CodeTabs>

```bash tab="cURL"
curl -X POST https://api.muzekit.com/v1/templates/product-card/duplicate \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "user": "usr_8fK2mQ1xZpR", "name": "My product card" }'
```

```javascript tab="Node"
const res = await fetch(
  "https://api.muzekit.com/v1/templates/product-card/duplicate",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ user: "usr_8fK2mQ1xZpR", name: "My product card" }),
  },
);
const design = await res.json(); // design.user is "usr_8fK2mQ1xZpR"
```

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

design = requests.post(
    "https://api.muzekit.com/v1/templates/product-card/duplicate",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
    json={"user": "usr_8fK2mQ1xZpR", "name": "My product card"},
).json()
```

</CodeTabs>

### Turn a user's design into a workspace template

A user made something you want everyone to start from. Duplicate their template by its id: the copy is a workspace template with a key, listed by `GET /v1/templates`, and the user's design doesn't change.

<CodeTabs>

```bash tab="cURL"
curl -X POST https://api.muzekit.com/v1/templates/tpl_G2l2bmhk8Pq/duplicate \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Spring launch post", "external_id": "spring-launch-post" }'
```

```javascript tab="Node"
const res = await fetch(
  "https://api.muzekit.com/v1/templates/tpl_G2l2bmhk8Pq/duplicate",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      name: "Spring launch post",
      external_id: "spring-launch-post",
    }),
  },
);
const template = await res.json(); // template.user is null
```

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

template = requests.post(
    "https://api.muzekit.com/v1/templates/tpl_G2l2bmhk8Pq/duplicate",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
    json={"name": "Spring launch post", "external_id": "spring-launch-post"},
).json()
```

</CodeTabs>

List one user's designs with `GET /v1/templates?user=usr_8fK2mQ1xZpR` to find the id.

## Response

`201` with the new [template](/docs/api-reference/templates-get).

```json
{
  "object": "template",
  "id": "tpl_Hn4cW2rTq8z",
  "name": "Product card (holiday)",
  "description": null,
  "tags": ["shop"],
  "external_id": "product-card-holiday",
  "user": null,
  "source": "duplicate",
  "version": { "id": "ver_Lp0sQ7dXk2m", "number": 1, "revision": 1 },
  "width": 1080,
  "height": 1080,
  "page_count": 1,
  "thumbnail_url": null,
  "created_at": "2026-11-29T09:12:04.511Z",
  "updated_at": "2026-11-29T09:12:04.511Z"
}
```
