> 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.

# Get open draft

GET https://api.smallest.ai/atoms/v1/agent/{id}/branches/{branchId}/draft

Return the currently-open draft on this branch, including per-edit history.

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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: atoms
  version: 1.0.0
paths:
  /agent/{id}/branches/{branchId}/draft:
    get:
      operationId: get-draft
      summary: Get open draft
      description: >-
        Return the currently-open draft on this branch, including per-edit
        history.
      tags:
        - agentVersioningBranches
      parameters:
        - name: id
          in: path
          description: The agent ID.
          required: true
          schema:
            type: string
        - name: branchId
          in: path
          description: The branch ID.
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: >-
            API key from the console ApiKey collection, sent as Bearer token.
            Also accepts session cookies for browser-based auth.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/agent_versioning_branches_get_draft_Response_200
        '400':
          description: Invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestErrorResponse'
        '401':
          description: Unauthorized access
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorResponse'
        '403':
          description: Forbidden access
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
        '404':
          description: No open draft on this branch, or the branch does not exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
servers:
  - url: https://api.smallest.ai/atoms/v1
    description: Production server
components:
  schemas:
    RevisionStatus:
      type: string
      enum:
        - published
        - draft
        - archived
      title: RevisionStatus
    VersionBlocks:
      type: object
      properties:
        workflow_prompt:
          type: string
        workflow_tools:
          type: string
        workflow_graph:
          type: string
        llm:
          type: string
        voice:
          type: string
        language:
          type: string
        call_handling:
          type: string
        detection:
          type: string
        analytics:
          type: string
        timeouts:
          type: string
        audio:
          type: string
        privacy:
          type: string
        widget:
          type: string
        playbooks:
          type: string
          description: >-
            Only present on revisions created after multi-agent playbooks
            shipped.
      description: >-
        ObjectId references to the `AgentConfigBlock` docs that make up a
        revision, one per config section.
      title: VersionBlocks
    RevisionSecurityCheck:
      type: object
      properties:
        status:
          type: string
          description: The `SecurityCheckStatus` enum.
        reason:
          type:
            - string
            - 'null'
        triggeredAt:
          type:
            - string
            - 'null'
          format: date-time
        completedAt:
          type:
            - string
            - 'null'
          format: date-time
      description: Populated after publish. `null` on pre-feature versions.
      title: RevisionSecurityCheck
    RevisionPendingPublishState:
      type: string
      enum:
        - active
        - cancelled
      title: RevisionPendingPublishState
    RevisionPendingPublish:
      type: object
      properties:
        state:
          $ref: '#/components/schemas/RevisionPendingPublishState'
        startedBy:
          type: string
        startedAt:
          type: string
          format: date-time
      description: Set while a publish is armed against this draft revision.
      title: RevisionPendingPublish
    PromptScoreDimensionsItems:
      type: object
      properties:
        tier:
          type: integer
        level:
          type: string
        evidence_span:
          type: string
        title:
          type: string
        description:
          type: string
      title: PromptScoreDimensionsItems
    PromptScore:
      type: object
      properties:
        overall_score:
          type: number
          format: double
        overall_grade:
          type: string
        band:
          type: string
        estimated_ttft_overhead_ms:
          type: number
          format: double
        scoredAt:
          type: string
          format: date-time
        dimensions:
          type: array
          items:
            $ref: '#/components/schemas/PromptScoreDimensionsItems'
      description: Result of the prompt-scoring pass, if any.
      title: PromptScore
    Revision:
      type: object
      properties:
        _id:
          type: string
        agent:
          type: string
        status:
          $ref: '#/components/schemas/RevisionStatus'
        branch:
          type:
            - string
            - 'null'
          description: Owning branch (v2). `null` on legacy rows until backfilled.
        revisionNumber:
          type:
            - integer
            - 'null'
          description: Monotonic per-branch commit number. Only set on committed rows.
        versionNumber:
          type:
            - integer
            - 'null'
          description: >-
            Legacy v1 published-version number. `null` for branch revisions and
            drafts.
        label:
          type:
            - string
            - 'null'
        description:
          type:
            - string
            - 'null'
        isPinned:
          type: boolean
        publishedBy:
          type:
            - string
            - 'null'
        publishedAt:
          type:
            - string
            - 'null'
          format: date-time
        publishedByName:
          type:
            - string
            - 'null'
          description: Display name of the publisher. `null` when unresolvable.
        restoredFromLabel:
          type:
            - string
            - 'null'
          description: >-
            On a commit produced by restore, the label of the revision it
            copied.
        draftId:
          type:
            - string
            - 'null'
        draftName:
          type:
            - string
            - 'null'
        draftRevision:
          type:
            - integer
            - 'null'
        sourceVersionId:
          type:
            - string
            - 'null'
        blocks:
          $ref: '#/components/schemas/VersionBlocks'
        workflowType:
          type: string
          description: The `WorkflowType` enum for this revision.
        parentVersion:
          type:
            - string
            - 'null'
        isActive:
          type: boolean
        activatedBy:
          type:
            - string
            - 'null'
        activatedAt:
          type:
            - string
            - 'null'
          format: date-time
        securityCheck:
          oneOf:
            - $ref: '#/components/schemas/RevisionSecurityCheck'
            - type: 'null'
          description: Populated after publish. `null` on pre-feature versions.
        pendingPublish:
          oneOf:
            - $ref: '#/components/schemas/RevisionPendingPublish'
            - type: 'null'
          description: Set while a publish is armed against this draft revision.
        restoredFromRevisionId:
          type:
            - string
            - 'null'
          description: On a commit produced by restore, the revision it copied.
        sourceDraftId:
          type:
            - string
            - 'null'
        promptScore:
          $ref: '#/components/schemas/PromptScore'
        promptScoreStale:
          type: boolean
        createdBy:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      description: >
        An `AgentVersion` document. Represents either a committed revision
        (`status: published`, with `branch` + `revisionNumber`) or an
        in-progress draft revision (`status: draft`, with `draftId` +
        `draftRevision`). Fields that do not apply to a given row are `null`.
      title: Revision
    DraftDetailEditHistoryItems:
      type: object
      properties:
        revision:
          $ref: '#/components/schemas/Revision'
        changedSections:
          type: array
          items:
            type: string
        editorName:
          type:
            - string
            - 'null'
          description: >-
            Display name of the editor who made this draft edit. `null` when the
            editor's display name is not resolvable.
      title: DraftDetailEditHistoryItems
    DraftDetail:
      type: object
      properties:
        latest:
          $ref: '#/components/schemas/Revision'
        editCount:
          type: integer
        editHistory:
          type: array
          items:
            $ref: '#/components/schemas/DraftDetailEditHistoryItems'
      description: Returned by `GET /agent/{id}/branches/{branchId}/draft`.
      title: DraftDetail
    agent_versioning_branches_get_draft_Response_200:
      type: object
      properties:
        status:
          type: boolean
        data:
          $ref: '#/components/schemas/DraftDetail'
      title: agent_versioning_branches_get_draft_Response_200
    BadRequestErrorResponse:
      type: object
      properties:
        status:
          type: boolean
        errors:
          type: array
          items:
            type: string
      title: BadRequestErrorResponse
    UnauthorizedErrorResponse:
      type: object
      properties:
        status:
          type: boolean
        errors:
          type: array
          items:
            type: string
      title: UnauthorizedErrorResponse
    ApiResponseData:
      type: object
      properties: {}
      title: ApiResponseData
    ApiResponse:
      type: object
      properties:
        status:
          type: boolean
        data:
          $ref: '#/components/schemas/ApiResponseData'
      title: ApiResponse
    InternalServerErrorResponse:
      type: object
      properties:
        status:
          type: boolean
        errors:
          type: array
          items:
            type: string
      title: InternalServerErrorResponse
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key from the console ApiKey collection, sent as Bearer token. Also
        accepts session cookies for browser-based auth.

```

## Examples



**Request**

```json
{}
```

**Response**

```json
{
  "status": true,
  "data": {
    "latest": {
      "_id": "64b8f9a2e4b0c123456789ab",
      "agent": "64b8f9a2e4b0c123456789ac",
      "status": "draft",
      "branch": "64b8f9a2e4b0c123456789ad",
      "revisionNumber": null,
      "versionNumber": null,
      "label": null,
      "description": "Initial draft for new customer support workflow",
      "isPinned": false,
      "publishedBy": null,
      "publishedAt": null,
      "publishedByName": null,
      "restoredFromLabel": null,
      "draftId": "draft_00123",
      "draftName": "Customer Support Workflow Draft",
      "draftRevision": 3,
      "sourceVersionId": null,
      "blocks": {
        "workflow_prompt": "64b8f9a2e4b0c123456789ae",
        "workflow_tools": "64b8f9a2e4b0c123456789af",
        "workflow_graph": "64b8f9a2e4b0c123456789b0",
        "llm": "64b8f9a2e4b0c123456789b1",
        "voice": "64b8f9a2e4b0c123456789b2",
        "language": "64b8f9a2e4b0c123456789b3",
        "call_handling": "64b8f9a2e4b0c123456789b4",
        "detection": "64b8f9a2e4b0c123456789b5",
        "analytics": "64b8f9a2e4b0c123456789b6",
        "timeouts": "64b8f9a2e4b0c123456789b7",
        "audio": "64b8f9a2e4b0c123456789b8",
        "privacy": "64b8f9a2e4b0c123456789b9",
        "widget": "64b8f9a2e4b0c123456789ba",
        "playbooks": "64b8f9a2e4b0c123456789bb"
      },
      "workflowType": "customer_support",
      "parentVersion": null,
      "isActive": false,
      "activatedBy": null,
      "activatedAt": null,
      "securityCheck": null,
      "pendingPublish": {
        "state": "active",
        "startedBy": "user_98765",
        "startedAt": "2024-04-20T14:45:00Z"
      },
      "restoredFromRevisionId": null,
      "sourceDraftId": null,
      "promptScore": {
        "overall_score": 87.5,
        "overall_grade": "B+",
        "band": "medium",
        "estimated_ttft_overhead_ms": 120.5,
        "scoredAt": "2024-04-20T14:40:00Z",
        "dimensions": [
          {
            "tier": 2,
            "level": "moderate",
            "evidence_span": "Prompt section 3",
            "title": "Clarity",
            "description": "The prompt is mostly clear but could be simplified."
          }
        ]
      },
      "promptScoreStale": false,
      "createdBy": "user_12345",
      "createdAt": "2024-04-18T10:00:00Z",
      "updatedAt": "2024-04-20T14:50:00Z"
    },
    "editCount": 3,
    "editHistory": [
      {
        "revision": {
          "_id": "64b8f9a2e4b0c123456789ac",
          "agent": "64b8f9a2e4b0c123456789ac",
          "status": "draft",
          "branch": "64b8f9a2e4b0c123456789ad",
          "revisionNumber": null,
          "versionNumber": null,
          "label": null,
          "description": "Added new call handling logic",
          "isPinned": false,
          "publishedBy": null,
          "publishedAt": null,
          "publishedByName": null,
          "restoredFromLabel": null,
          "draftId": "draft_00123",
          "draftName": "Customer Support Workflow Draft",
          "draftRevision": 2,
          "sourceVersionId": null,
          "blocks": {
            "workflow_prompt": "64b8f9a2e4b0c123456789ae",
            "workflow_tools": "64b8f9a2e4b0c123456789af",
            "workflow_graph": "64b8f9a2e4b0c123456789b0",
            "llm": "64b8f9a2e4b0c123456789b1",
            "voice": "64b8f9a2e4b0c123456789b2",
            "language": "64b8f9a2e4b0c123456789b3",
            "call_handling": "64b8f9a2e4b0c123456789b4",
            "detection": "64b8f9a2e4b0c123456789b5",
            "analytics": "64b8f9a2e4b0c123456789b6",
            "timeouts": "64b8f9a2e4b0c123456789b7",
            "audio": "64b8f9a2e4b0c123456789b8",
            "privacy": "64b8f9a2e4b0c123456789b9",
            "widget": "64b8f9a2e4b0c123456789ba",
            "playbooks": "64b8f9a2e4b0c123456789bb"
          },
          "workflowType": "customer_support",
          "parentVersion": null,
          "isActive": false,
          "activatedBy": null,
          "activatedAt": null,
          "securityCheck": null,
          "pendingPublish": null,
          "restoredFromRevisionId": null,
          "sourceDraftId": null,
          "promptScore": null,
          "promptScoreStale": false,
          "createdBy": "user_12345",
          "createdAt": "2024-04-19T09:00:00Z",
          "updatedAt": "2024-04-19T09:30:00Z"
        },
        "changedSections": [
          "call_handling",
          "workflow_prompt"
        ],
        "editorName": "Alice Johnson"
      },
      {
        "revision": {
          "_id": "64b8f9a2e4b0c123456789ab",
          "agent": "64b8f9a2e4b0c123456789ac",
          "status": "draft",
          "branch": "64b8f9a2e4b0c123456789ad",
          "revisionNumber": null,
          "versionNumber": null,
          "label": null,
          "description": "Initial draft for new customer support workflow",
          "isPinned": false,
          "publishedBy": null,
          "publishedAt": null,
          "publishedByName": null,
          "restoredFromLabel": null,
          "draftId": "draft_00123",
          "draftName": "Customer Support Workflow Draft",
          "draftRevision": 1,
          "sourceVersionId": null,
          "blocks": {
            "workflow_prompt": "64b8f9a2e4b0c123456789ae",
            "workflow_tools": "64b8f9a2e4b0c123456789af",
            "workflow_graph": "64b8f9a2e4b0c123456789b0",
            "llm": "64b8f9a2e4b0c123456789b1",
            "voice": "64b8f9a2e4b0c123456789b2",
            "language": "64b8f9a2e4b0c123456789b3",
            "call_handling": "64b8f9a2e4b0c123456789b4",
            "detection": "64b8f9a2e4b0c123456789b5",
            "analytics": "64b8f9a2e4b0c123456789b6",
            "timeouts": "64b8f9a2e4b0c123456789b7",
            "audio": "64b8f9a2e4b0c123456789b8",
            "privacy": "64b8f9a2e4b0c123456789b9",
            "widget": "64b8f9a2e4b0c123456789ba",
            "playbooks": "64b8f9a2e4b0c123456789bb"
          },
          "workflowType": "customer_support",
          "parentVersion": null,
          "isActive": false,
          "activatedBy": null,
          "activatedAt": null,
          "securityCheck": null,
          "pendingPublish": null,
          "restoredFromRevisionId": null,
          "sourceDraftId": null,
          "promptScore": null,
          "promptScoreStale": false,
          "createdBy": "user_12345",
          "createdAt": "2024-04-18T10:00:00Z",
          "updatedAt": "2024-04-18T10:00:00Z"
        },
        "changedSections": [
          "workflow_prompt"
        ],
        "editorName": "Alice Johnson"
      }
    ]
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.smallest.ai/atoms/v1/agent/id/branches/branchId/draft"

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

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

print(response.json())
```

```javascript
const url = 'https://api.smallest.ai/atoms/v1/agent/id/branches/branchId/draft';
const options = {
  method: 'GET',
  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/branches/branchId/draft"

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

	req, _ := http.NewRequest("GET", 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/branches/branchId/draft")

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

request = Net::HTTP::Get.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.get("https://api.smallest.ai/atoms/v1/agent/id/branches/branchId/draft")
  .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('GET', 'https://api.smallest.ai/atoms/v1/agent/id/branches/branchId/draft', [
  '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/branches/branchId/draft");
var request = new RestRequest(Method.GET);
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/branches/branchId/draft")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```