# 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.senddart.com/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 { SendDart } from 'senddart';

const mb = new SendDart('mb_xxxxxxxxx');

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

**Ruby**

```ruby
require "senddart"

SendDart.api_key = "mb_xxxxxxxxx"

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

**PHP**

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

use SendDart\SendDart;

$senddart = SendDart::client('mb_xxxxxxxxx');

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

**Python**

```python
import senddart

senddart.api_key = "mb_xxxxxxxxx"

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

**Go**

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

client := senddart.NewClient("mb_xxxxxxxxx")

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

**Rust**

```rust
use senddart::SendDart;

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

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

**Java**

```java
import com.senddart.SendDart;
import com.senddart.SendDartResponse;

SendDart senddart = new SendDart("mb_xxxxxxxxx");

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

**.NET**

```csharp
using SendDart;

ISendDart senddart = SendDartClient.Create("mb_xxxxxxxxx");

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

**cURL**

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

**CLI**

```bash
senddart 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.
