> ## Documentation Index
> Fetch the complete documentation index at: https://docs.promptlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Draft Dataset Version

Create a mutable draft dataset version for a dataset group. Drafts use `version_number = -1` until they are saved as a published version.

## Behavior Notes

* Only one draft can exist per dataset group at a time; creating another draft returns `409`.
* Without `source_dataset_id`, PromptLayer creates an empty draft and returns `201`.
* With `source_dataset_id`, rows are copied from the source dataset asynchronously and the endpoint returns `202`.
* The source dataset must belong to the same dataset group.

## Related

* [Add Request Log to Dataset](/reference/add-request-log-to-dataset)
* [Save Draft Dataset Version](/reference/save-draft-dataset-version)
* [Create Dataset Version from File](/reference/create-dataset-version-from-file)


## OpenAPI

````yaml POST /api/public/v2/dataset-versions/create-draft
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /api/public/v2/dataset-versions/create-draft:
    post:
      tags:
        - datasets
      summary: Create Draft Dataset Version
      operationId: createDraftDatasetVersion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDraftDatasetVersionRequest'
            examples:
              emptyDraft:
                summary: Create an empty draft
                value:
                  dataset_group_id: 123
              copyFromSource:
                summary: Create a draft from an existing dataset version
                value:
                  dataset_group_id: 123
                  source_dataset_id: 456
      responses:
        '201':
          description: Empty draft created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DraftDatasetVersionResponse'
              examples:
                created:
                  summary: Empty draft created
                  value:
                    success: true
                    message: Draft dataset version created
                    draft_dataset_id: 789
        '202':
          description: Draft created and source rows are being copied asynchronously.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DraftDatasetVersionResponse'
              examples:
                copying:
                  summary: Rows copying from source dataset
                  value:
                    success: true
                    message: >-
                      Draft created; rows are being copied from the source
                      dataset
                    draft_dataset_id: 789
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '409':
          description: A draft version already exists for this dataset group
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    CreateDraftDatasetVersionRequest:
      type: object
      title: CreateDraftDatasetVersionRequest
      required:
        - dataset_group_id
      properties:
        dataset_group_id:
          type: integer
          minimum: 1
          description: ID of the dataset group to create a draft version for.
        source_dataset_id:
          type: integer
          minimum: 1
          nullable: true
          description: >-
            Optional existing dataset version to copy rows from. Must belong to
            the same dataset group.
    DraftDatasetVersionResponse:
      type: object
      title: DraftDatasetVersionResponse
      required:
        - success
        - message
        - draft_dataset_id
      properties:
        success:
          type: boolean
          enum:
            - true
        message:
          type: string
        draft_dataset_id:
          type: integer
          description: ID of the draft dataset.
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          default: false
          description: Indicates that the request failed.
        message:
          type: string
          description: Human-readable error message.
        error:
          type: string
          description: Machine-readable or fallback error message.
      additionalProperties: true
      description: >-
        Standard error response. Some legacy endpoints may return either message
        or error.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  responses:
    UnauthorizedError:
      description: Unauthorized - missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ForbiddenError:
      description: Forbidden - API key does not have access to the requested resource.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFoundError:
      description: Not found - requested resource does not exist or is not accessible.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Validation error - request parameters or body are invalid.
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/HTTPValidationError'
              - $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````