> ## 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 Group

Create a dataset group in a workspace. PromptLayer also creates an initial draft dataset for the group with `version_number = -1`.

## Behavior Notes

* Dataset group names must be unique within a workspace.
* If `folder_id` is omitted, the dataset group is created at the workspace root.
* Use [Resolve Folder ID by Path](/reference/resolve-folder-id) to look up a folder ID, or [Create Folder](/reference/create-folder) to create one.

## Related

* [List Datasets](/reference/list-datasets)
* [Create Dataset Version from Request History](/reference/create-dataset-version-from-filter-params)
* [Datasets Overview](/features/evaluations/datasets-overview)


## OpenAPI

````yaml POST /api/public/v2/dataset-groups
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /api/public/v2/dataset-groups:
    post:
      tags:
        - datasets
      summary: Create Dataset Group
      operationId: createDatasetGroup
      requestBody:
        required: true
        description: Dataset group creation payload.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatasetGroupRequest'
            examples:
              inFolder:
                summary: Create inside a folder
                value:
                  name: Customer support eval set
                  folder_id: 17
      responses:
        '201':
          description: Dataset group created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateDatasetGroupResponse'
              examples:
                created:
                  summary: Dataset group created
                  value:
                    success: true
                    message: Dataset group created successfully
                    dataset_group:
                      id: 123
                      name: Customer support eval set
                    dataset:
                      id: 456
                      version_number: -1
                    external_ids: []
        '400':
          description: >-
            Bad Request - Invalid workspace_id or dataset with this name already
            exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '409':
          description: External ID conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExternalIdErrorResponse'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    CreateDatasetGroupRequest:
      type: object
      title: CreateDatasetGroupRequest
      required:
        - name
      properties:
        name:
          type: string
          description: Name for the dataset group. Must be unique within the workspace.
        workspace_id:
          type: integer
          nullable: true
          description: Workspace ID. Defaults to the workspace associated with the API key.
        folder_id:
          type: integer
          nullable: true
          description: >-
            Folder ID to create the dataset group in. Omit to create at the
            workspace root.
        external_ids:
          type: array
          items:
            $ref: '#/components/schemas/ExternalId'
          description: External ID mappings to attach to the dataset group.
    CreateDatasetGroupResponse:
      type: object
      title: CreateDatasetGroupResponse
      required:
        - success
        - dataset_group
        - dataset
        - external_ids
      properties:
        success:
          type: boolean
          enum:
            - true
        message:
          type: string
        dataset_group:
          anyOf:
            - $ref: '#/components/schemas/DatasetGroup'
            - additionalProperties: true
              type: object
        dataset:
          anyOf:
            - $ref: '#/components/schemas/Dataset'
            - additionalProperties: true
              type: object
          description: Initial draft dataset created with version_number = -1.
        external_ids:
          type: array
          items:
            $ref: '#/components/schemas/ExternalId'
    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.
    ExternalIdErrorResponse:
      properties:
        success:
          type: boolean
          const: false
          default: false
          title: Success
        message:
          type: string
          title: Message
      type: object
      required:
        - message
      title: ExternalIdErrorResponse
    ExternalId:
      properties:
        source:
          type: string
          maxLength: 128
          minLength: 1
          title: Source
          description: The external system or namespace that owns the ID.
        external_id:
          type: string
          maxLength: 512
          minLength: 1
          title: External Id
          description: The identifier for this entity in the external system.
      type: object
      required:
        - source
        - external_id
      additionalProperties: false
      title: ExternalId
      description: >-
        Customer-defined mapping between a PromptLayer entity and an external
        system identifier.
    DatasetGroup:
      type: object
      properties:
        id:
          type: integer
          description: Dataset group ID
        name:
          type: string
          description: Dataset group name
        workspace_id:
          type: integer
          description: Associated workspace ID
        is_deleted:
          type: boolean
          description: Whether the dataset group is deleted
      required:
        - id
        - name
        - workspace_id
        - is_deleted
      title: DatasetGroup
    Dataset:
      type: object
      properties:
        id:
          type: integer
          description: Dataset ID
        dataset_group_id:
          type: integer
          description: Associated dataset group ID
        version_number:
          type: integer
          description: Version number of the dataset
        column_names:
          type: array
          items:
            type: string
          description: Array of column names in the dataset
        filter_params:
          type: object
          nullable: true
          description: Filter parameters used to create the dataset
        is_deleted:
          type: boolean
          description: Whether the dataset is deleted
        user_id:
          type: integer
          description: ID of the user who created the dataset
        dataset_group:
          $ref: '#/components/schemas/DatasetGroup'
          description: Associated dataset group information
        external_ids:
          type: array
          items:
            $ref: '#/components/schemas/ExternalId'
          description: External ID mappings attached to this dataset group.
      required:
        - id
        - dataset_group_id
        - version_number
        - column_names
        - is_deleted
        - user_id
      title: Dataset
    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'
    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

````