# Duplicate a template

Creates a duplicate of an existing template.\
The duplicated template will belong to the same user and can be customized independently.\
Duplicating a template counts towards the template limit of your plan.

## Parameters

<span class="font-mono font-bold">id</span> `string` <code class="text-white !bg-red-500">REQUIRED</code>\
The template id of the template that you want to duplicate.

<span class="font-mono font-bold">name</span> `string` <code class="text-white !bg-gray-500">OPTIONAL</code>\
The name for the duplicated template.\
If not provided, defaults to "Copy of <span class="font-mono">\{original_template_name\}</span>".

## Sample Request

Here's a sample request to duplicate a template:

```js title="ENDPOINT"
POST /v1/template/:id/duplicate
```

```js title="REQUEST WITH CUSTOM NAME" "id" "API_KEY" "name"
fetch(`https://api.templated.io/v1/template/${id}/duplicate?name=My Custom Template`, {
  method: 'POST',
  headers: {
    'Authorization' : `Bearer ${API_KEY}`
  }
})
```

```js title="REQUEST WITH DEFAULT NAME" "id" "API_KEY"
fetch(`https://api.templated.io/v1/template/${id}/duplicate`, {
  method: 'POST',
  headers: {
    'Authorization' : `Bearer ${API_KEY}`
  }
})
```

## Response

The API returns a JSON object with the duplicated template details.

```json
{
  "id": "new-template-id-123",
  "name": "My Custom Template",
  "width": 1200,
  "height": 800,
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:30:00Z",
}
```