# Duplicate template

> POST /templates/:id/duplicate — copy a template into a new draft.

`POST /templates/:id/duplicate`

Creates a new template that is an exact copy of the source (`subject`, `html`, `text`, `from`, `reply_to`, `variables`). The copy starts as a fresh `draft` — new `id`, no published snapshot, no version history. The source's `alias` is dropped because aliases must be unique; supply a new one in the request body if you want one.

**Body parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | No | Name for the copy. Defaults to `"<source name> (copy)"` when omitted. |
| `alias` | string | No | Alias for the copy. Must be unique across your templates. Omit to create the copy without an alias. |

**Node.js**

```js
import { SendPing } from 'sendping';

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.templates.duplicate('43f68331-0622-4e15-8202-246a0388854b', { "name": "Welcome email v2" });
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Templates.duplicate("43f68331-0622-4e15-8202-246a0388854b", {
  "name": "Welcome email v2"
})
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

use SendPing\SendPing;

$sendping = SendPing::client('mb_xxxxxxxxx');

$sendping->templates->duplicate('43f68331-0622-4e15-8202-246a0388854b', [
  'name' => "Welcome email v2"
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Templates.duplicate("43f68331-0622-4e15-8202-246a0388854b", {
  "name": "Welcome email v2"
})
```

**Go**

```go
import "github.com/shekhu10/sendping-sdks/sendping-go"

client := sendping.NewClient("mb_xxxxxxxxx")

duplicated, err := client.Templates.Duplicate("43f68331-0622-4e15-8202-246a0388854b", &sendping.DuplicateTemplateRequest{
    Name: "Welcome email v2",
})
```

**Rust**

```rust
use sendping::{DuplicateTemplateOptions, SendPing};

let mb = SendPing::new("mb_xxxxxxxxx");

let params = Some(DuplicateTemplateOptions::new().with_name("Welcome email v2"));
let _duplicated = mb.templates.duplicate("43f68331-0622-4e15-8202-246a0388854b", params).await?;
```

**Java**

```java
import co.sendping.SendPing;
import co.sendping.SendPingResponse;
import co.sendping.requests.DuplicateTemplateRequest;

SendPing sendping = new SendPing("mb_xxxxxxxxx");

SendPingResponse response = sendping.templates().duplicate(
        "43f68331-0622-4e15-8202-246a0388854b",
        DuplicateTemplateRequest.builder().name("Welcome email v2").build());
```

**.NET**

```csharp
using SendPing;

ISendPing sendping = SendPingClient.Create("mb_xxxxxxxxx");

var resp = await sendping.TemplateDuplicateAsync(
    "43f68331-0622-4e15-8202-246a0388854b",
    new TemplateDuplicateOptions { Name = "Welcome email v2" });
```

**cURL**

```bash
curl -X POST 'https://www.sendping.co/api/templates/43f68331-0622-4e15-8202-246a0388854b/duplicate' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "Welcome email v2" }'
```

**CLI**

```bash
sendping templates duplicate 43f68331-0622-4e15-8202-246a0388854b \
  --name 'Welcome email v2'
```

### Response

```json
{ "object": "template", "id": "b8d4f21c-3e07-4a95-bf62-1d9c5e08a743" }
```

> **Note:** Returns `not_found` if no template with that id belongs to you.
