> ## 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 Dataset Version from File

Create a dataset version by submitting a base64-encoded CSV or JSON file. PromptLayer queues the file for asynchronous processing and creates a draft dataset while the job runs.

## Behavior Notes

* The draft dataset starts with `version_number = -1` and receives a real version number after processing succeeds.
* The `dataset_version_created_by_file` webhook event is sent when processing succeeds.
* The `dataset_version_created_by_file_failed` webhook event is sent when processing fails.
* Decoded file content must be 100MB or smaller.
* Failed drafts are automatically cleaned up.

## Related

* [Create Dataset Version from Request History](/reference/create-dataset-version-from-filter-params)
* [Create Draft Dataset Version](/reference/create-draft-dataset-version)
* [Create from History](/features/evaluations/datasets-create-from-history)


## OpenAPI

````yaml POST /api/public/v2/dataset-versions/from-file
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /api/public/v2/dataset-versions/from-file:
    post:
      tags:
        - datasets
      summary: Create Dataset Version from File
      operationId: createDatasetVersionFromFile
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatasetVersionFromFileRequest'
            examples:
              csvFile:
                summary: Create from CSV file
                value:
                  dataset_group_id: 123
                  file_name: support-eval.csv
                  file_content_base64: >-
                    cXVlc3Rpb24sZXhwZWN0ZWRfYW5zd2VyCldoYXQgaXMgUHJvbXB0TGF5ZXI/LEEgcHJvbXB0IG1hbmFnZW1lbnQgcGxhdGZvcm0=
              jsonFile:
                summary: Create from JSON file
                value:
                  dataset_group_id: 123
                  file_name: support-eval.json
                  file_content_base64: >-
                    W3sicXVlc3Rpb24iOiJXaGF0IGlzIFByb21wdExheWVyPyIsImV4cGVjdGVkX2Fuc3dlciI6IkEgcHJvbXB0IG1hbmFnZW1lbnQgcGxhdGZvcm0ifV0=
      responses:
        '201':
          description: Dataset version creation job queued.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateDatasetVersionFromFileResponse'
              examples:
                queued:
                  summary: File processing queued
                  value:
                    success: true
                    message: Dataset version creation job queued
                    dataset_id: 456
        '400':
          description: >-
            Bad Request - Invalid file format, file too large, or invalid base64
            encoding
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '422':
          $ref: '#/components/responses/ValidationError'
        '500':
          description: Failed to upload file or create dataset version
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreateDatasetVersionFromFileRequest:
      type: object
      title: CreateDatasetVersionFromFileRequest
      required:
        - dataset_group_id
        - file_name
        - file_content_base64
      properties:
        dataset_group_id:
          type: integer
          minimum: 1
          description: ID of the dataset group where the new version will be created.
        file_name:
          type: string
          minLength: 1
          maxLength: 255
          description: Name of the CSV or JSON file. Must end with .csv or .json.
        file_content_base64:
          type: string
          minLength: 1
          description: Base64-encoded file content. Maximum decoded file size is 100MB.
    CreateDatasetVersionFromFileResponse:
      type: object
      title: CreateDatasetVersionFromFileResponse
      required:
        - success
        - message
        - dataset_id
      properties:
        success:
          type: boolean
          enum:
            - true
        message:
          type: string
        dataset_id:
          type: integer
          description: ID of the draft dataset created for asynchronous processing.
    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

````