# Publish template

> POST /templates/:id/publish — snapshot the draft and make it live.

`POST /templates/:id/publish`

Publishes the current draft: copies the working `subject`/`html`/`text` into the published snapshot, sets `status` to `"published"`, stamps `published_at`, and records a new entry in the version history (`current_version_id` is updated). **Every** send that references the template — [`POST /emails`](https://www.sendping.co/docs/api/emails-send), batch, campaigns and automations — reads the published snapshot, so an unpublished template cannot be sent at all and later draft edits stay invisible until you publish again.

**Node.js**

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

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.templates.publish('43f68331-0622-4e15-8202-246a0388854b');
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Templates.publish("43f68331-0622-4e15-8202-246a0388854b")
```

**PHP**

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

use SendPing\SendPing;

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

$sendping->templates->publish('43f68331-0622-4e15-8202-246a0388854b');
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Templates.publish("43f68331-0622-4e15-8202-246a0388854b")
```

**Go**

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

client := sendping.NewClient("mb_xxxxxxxxx")

published, err := client.Templates.Publish("43f68331-0622-4e15-8202-246a0388854b")
```

**Rust**

```rust
use sendping::SendPing;

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

let _published = mb.templates.publish("43f68331-0622-4e15-8202-246a0388854b").await?;
```

**Java**

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

SendPing sendping = new SendPing("mb_xxxxxxxxx");

SendPingResponse response = sendping.templates().publish("43f68331-0622-4e15-8202-246a0388854b");
```

**.NET**

```csharp
using SendPing;

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

var resp = await sendping.TemplatePublishAsync("43f68331-0622-4e15-8202-246a0388854b");
```

**cURL**

```bash
curl -X POST 'https://www.sendping.co/api/templates/43f68331-0622-4e15-8202-246a0388854b/publish' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
sendping templates publish 43f68331-0622-4e15-8202-246a0388854b
```

### Response

```json
{ "object": "template", "id": "43f68331-0622-4e15-8202-246a0388854b" }
```

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