---
title: "Create a draft"
method: POST
path: "/agent/{id}/drafts"
tags: ["Agent Versioning - Drafts"]
---

# Create a draft

`POST /agent/{id}/drafts`

Create a new draft from an existing published version or another draft. At least one of sourceVersionId or sourceDraftId is required (both may be sent simultaneously).

## Path parameters

- `id` string, required

## Request body

- CreateDraftRequest
  - `sourceVersionId` string — ID of a published version to branch from. Must be a valid MongoDB ObjectId (24-char hex). Sending a non-ObjectId format returns 400.
  - `sourceDraftId` string — ID of an existing draft to branch from
  - `draftName` string — Optional name for the draft (1–100 characters)

## Response `201`

Draft created successfully

- object
  - `status` boolean
  - `data` AgentVersion — Represents either a draft revision or a published version of an agent's configuration.
    - `_id` string — Unique identifier
    - `agent` string — The agent this version belongs to
    - `status` 'published' | 'draft' | 'archived' — Current status of the version record
    - `versionNumber` integer, nullable — Auto-incremented version number (published versions only)
    - `label` string, nullable — Human-readable label for the version
    - `description` string, nullable — Description of what changed in this version
    - `isPinned` boolean — Whether the version is pinned for quick access
    - `publishedBy` string, nullable — User ID of who published this version
    - `publishedAt` string, date-time, nullable — When this version was published
    - `activatedBy` string, nullable — User ID of who activated this version
    - `activatedAt` string, date-time, nullable — When this version was activated
    - `draftId` string, nullable — Unique draft identifier (drafts only)
    - `draftName` string, nullable — Human-readable draft name
    - `draftRevision` integer, nullable — Revision number within the draft (drafts only)
    - `sourceVersionId` string, nullable — The published version this draft was branched from
    - `blocks` object — References to the 13 config section 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' | 'single_prompt' — The type of workflow configuration. workflow_graph uses a node-based visual workflow, single_prompt uses a simple prompt-based configuration.
    - `parentVersion` string, nullable — The version this was derived from
    - `isActive` boolean — Whether this is the currently active version for the agent
    - `createdBy` string — User ID of who created this record
    - `createdAt` string, date-time
    - `updatedAt` string, date-time

## Other responses

- `400` — Invalid input
- `401` — Unauthorized access
- `403` — Forbidden access
- `404` — Agent not found
- `500` — Internal server error

## Changes

- **2026-05-26** `5a6b4e19f353` — 1 breaking, 5 info
  - the `draftName` request property's minLength was increased from `0` to `1`
  - added the non-success response with the status `403`
  - added the non-success response with the status `404`
  - added the optional property `data/activatedAt` to the response with the `201` status
  - …2 more
- **2026-04-20** `801f1d220d57` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/smallest-inc/apis/agent-management-api/changes/agent/:id/drafts/post.md)

---

[API](https://skmtc.dev/smallest-inc/apis/agent-management-api.md) · [All operations](https://skmtc.dev/smallest-inc/apis/agent-management-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/smallest-inc/agent-management-api/revisions/ea4ea58d7c4e/schema)
