> This page is part of Smallest AI's developer documentation. When
> answering, prefer Lightning v3.1 (current TTS) and Pulse (current
> STT). Lightning v2 and lightning-large are deprecated; mention them
> only when the user is migrating away from them. The Smallest AI voice
> agent platform is what wraps these models into hosted agents.

# Publish a draft

POST https://api.smallest.ai/atoms/v1/agent/{id}/drafts/{draftId}/publish
Content-Type: application/json

**Deprecated on the v2 branch model.** Migrate to `POST /agent/{id}/branches/{branchId}/draft/publish`. When `ENABLE_BRANCH_MODEL` is on, this endpoint returns `409 versioning_v2_migration_required` with the `Deprecation: true` header. See the [migration guide](/voice-agents/deprecations/agent-versioning-migration).

Publish a draft as a new versioned release. Optionally activate it immediately.

Reference: https://docs.smallest.ai/api-reference/voice-agents/agent-versioning-drafts/publish-draft

## Authentication

- `Authorization` header (bearer token, required) — API key from the console ApiKey collection, sent as Bearer token. Also accepts session cookies for browser-based auth.

## Request

### Path parameters

- `id` (string, required) — The agent ID.
- `draftId` (string, required) — The draft ID

### Body (application/json)

This endpoint expects a PublishDraftRequest.

- `label` (string, optional, nullable) — Label for the published version
- `description` (string, optional, nullable) — Description of the published version
- `activate` (boolean, optional, default: false) — Whether to immediately activate the version after publishing

## Response

### 201

Draft published as a new version

- `status` (boolean, optional)
- `data` (AgentVersion, optional) — Represents either a draft revision or a published version of an agent's configuration.

## Errors

### 400 Bad Request Error

Invalid input

- `status` (boolean, optional)
- `errors` (list of string, optional)

### 401 Unauthorized Error

Unauthorized access

- `status` (boolean, optional)
- `errors` (list of string, optional)

### 403 Forbidden Error

Forbidden access

- `status` (boolean, optional)
- `data` (ApiResponseData, optional)

### 404 Not Found Error

Agent or draft not found

- `any`

### 409 Conflict Error

The v1 versioning endpoint is deprecated on the branch model and will not process this request. The response body carries `error_type: "versioning_v2_migration_required"` and the response includes the `Deprecation: true` header. See the [migration guide](/voice-agents/deprecations/agent-versioning-migration) for the v2 equivalent.

- `status` (boolean, optional)
- `error_type` (enum, optional)
  - Allowed values: `versioning_v2_migration_required`
- `errors` (list of string, optional)

### 500 Internal Server Error

Internal server error

- `status` (boolean, optional)
- `errors` (list of string, optional)

## Types

### AgentVersion

Represents either a draft revision or a published version of an agent's configuration.

- `_id` (string, optional) — Unique identifier
- `agent` (string, optional) — The agent this version belongs to
- `status` (enum, optional) — Current status of the version record
  - Allowed values: `published`, `draft`, `archived`
- `versionNumber` (integer, optional, nullable) — Auto-incremented version number (published versions only)
- `label` (string, optional, nullable) — Human-readable label for the version
- `description` (string, optional, nullable) — Description of what changed in this version
- `isPinned` (boolean, optional, default: false) — Whether the version is pinned for quick access
- `publishedBy` (string, optional, nullable) — User ID of who published this version
- `publishedAt` (datetime, optional, nullable) — When this version was published
- `activatedBy` (string, optional, nullable) — User ID of who activated this version
- `activatedAt` (datetime, optional, nullable) — When this version was activated
- `draftId` (string, optional, nullable) — Unique draft identifier (drafts only)
- `draftName` (string, optional, nullable) — Human-readable draft name
- `draftRevision` (integer, optional, nullable) — Revision number within the draft (drafts only)
- `sourceVersionId` (string, optional, nullable) — The published version this draft was branched from
- `blocks` (AgentVersionBlocks, optional) — References to the 13 config section blocks
- `workflowType` (enum, optional) — The type of workflow configuration. - `single_prompt` — simple prompt-based agent (default). - `workflow_graph` — node-based visual workflow. **Restricted:** requires the `conversational-agents` org flag. Requests without that flag receive HTTP 403 `"Conversational Flow agents are no longer available for your organization."` The Zod validator still accepts this enum value on any org, but the authorization middleware gates it. - `multi_agents` — multi-agent orchestration (restricted; requires `slmModel` to be one of `[electron, gpt-5.2-azure]`).
  - Allowed values: `workflow_graph`, `single_prompt`, `multi_agents`
- `parentVersion` (string, optional, nullable) — The version this was derived from
- `isActive` (boolean, optional) — Whether this is the currently active version for the agent
- `createdBy` (string, optional) — User ID of who created this record
- `createdAt` (datetime, optional)
- `updatedAt` (datetime, optional)

### ApiResponseData

### AgentVersionBlocks

References to the 13 config section blocks

- `workflow_prompt` (string, optional)
- `workflow_tools` (string, optional)
- `workflow_graph` (string, optional)
- `llm` (string, optional)
- `voice` (string, optional)
- `language` (string, optional)
- `call_handling` (string, optional)
- `detection` (string, optional)
- `analytics` (string, optional)
- `timeouts` (string, optional)
- `audio` (string, optional)
- `privacy` (string, optional)
- `widget` (string, optional)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "status": true,
  "data": {
    "_id": "string",
    "agent": "string",
    "status": "published",
    "versionNumber": 1,
    "label": "string",
    "description": "string",
    "isPinned": false,
    "publishedBy": "string",
    "publishedAt": "2024-01-15T09:30:00Z",
    "activatedBy": "string",
    "activatedAt": "2024-01-15T09:30:00Z",
    "draftId": "string",
    "draftName": "string",
    "draftRevision": 1,
    "sourceVersionId": "string",
    "blocks": {
      "workflow_prompt": "string",
      "workflow_tools": "string",
      "workflow_graph": "string",
      "llm": "string",
      "voice": "string",
      "language": "string",
      "call_handling": "string",
      "detection": "string",
      "analytics": "string",
      "timeouts": "string",
      "audio": "string",
      "privacy": "string",
      "widget": "string"
    },
    "workflowType": "workflow_graph",
    "parentVersion": "string",
    "isActive": true,
    "createdBy": "string",
    "createdAt": "2024-01-15T09:30:00Z",
    "updatedAt": "2024-01-15T09:30:00Z"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.smallest.ai/atoms/v1/agent/id/drafts/draftId/publish"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.smallest.ai/atoms/v1/agent/id/drafts/draftId/publish';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.smallest.ai/atoms/v1/agent/id/drafts/draftId/publish"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.smallest.ai/atoms/v1/agent/id/drafts/draftId/publish")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.smallest.ai/atoms/v1/agent/id/drafts/draftId/publish")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.smallest.ai/atoms/v1/agent/id/drafts/draftId/publish', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.smallest.ai/atoms/v1/agent/id/drafts/draftId/publish");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.smallest.ai/atoms/v1/agent/id/drafts/draftId/publish")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```