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

# Create import dataset

> Add a new import dataset.



## OpenAPI

````yaml /generated/openapi-import-generated-2023-12-01.json post /import/datasets
openapi: 3.1.0
info:
  title: Prequel Data Import
  description: Data Import API spec
  version: '2023-12-01'
servers:
  - url: https://api.prequel.co
    description: Cloud-hosted server (US)
  - url: https://eu-api.prequel.co
    description: Cloud-hosted server (EU)
  - url: https://{custom_host}
    description: Self-hosted Prequel API host
security:
  - ApiKeyAuth: []
paths:
  /import/datasets:
    post:
      tags:
        - Import Datasets
      summary: Create import dataset
      description: Add a new import dataset.
      operationId: create-import-dataset
      parameters:
        - name: skip_validation
          in: query
          required: false
          description: Skip validation when creating or updating.
          schema:
            type: boolean
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatasetRequest'
              $schema: https://json-schema.org/draft/2020-12/schema
              $id: >-
                https://github.com/prequel-co/datafeed/internal/import/api/models/create-dataset-request
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                properties:
                  status:
                    type: string
                    const: success
                  data:
                    $ref: '#/components/schemas/GetDatasetResponse'
                    $schema: https://json-schema.org/draft/2020-12/schema
                    $id: >-
                      https://github.com/prequel-co/datafeed/internal/import/api/models/get-dataset-response
                  message:
                    type: string
                type: object
                required:
                  - status
                  - data
                  - message
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CreateDatasetRequest:
      properties:
        dataset:
          $ref: '#/components/schemas/DatasetOptions'
      additionalProperties: false
      type: object
      required:
        - dataset
    GetDatasetResponse:
      properties:
        dataset:
          $ref: '#/components/schemas/DatasetResource'
      additionalProperties: false
      type: object
      required:
        - dataset
    DatasetOptions:
      allOf:
        - oneOf:
            - properties:
                type:
                  const: dimension
                dimension:
                  $ref: '#/components/schemas/DimensionOptions'
                  title: Dimension Configuration
              required:
                - type
                - dimension
              title: Dimension Configuration
            - properties:
                type:
                  const: fact
                fact:
                  $ref: '#/components/schemas/FactOptions'
                  title: Fact Configuration
              required:
                - type
                - fact
              title: Fact Configuration
        - oneOf:
            - properties:
                method:
                  const: table
                table:
                  $ref: '#/components/schemas/TableOptions'
                  title: Table Configuration
              required:
                - method
                - table
              title: Table Configuration
            - properties:
                method:
                  const: sql
                sql:
                  $ref: '#/components/schemas/SQLOptions'
                  title: SQL Configuration
              required:
                - method
                - sql
              title: SQL Configuration
            - properties:
                method:
                  const: glob
                glob:
                  $ref: '#/components/schemas/GlobOptions'
                  title: Glob Configuration
              required:
                - method
                - glob
              title: Glob Configuration
      properties:
        name:
          type: string
          title: Name
          description: Name of the dataset.
        source_id:
          type: string
          format: uuid
          title: Source ID
          description: ID of the import source this dataset belongs to.
        is_enabled:
          type: boolean
          title: Enabled
          description: Whether this dataset is enabled.
        frequency_minutes:
          type: integer
          minimum: 1
          title: Frequency Minutes
          description: Frequency in minutes for syncing this dataset.
      type: object
      required:
        - source_id
        - frequency_minutes
      unevaluatedProperties: false
    DatasetResource:
      allOf:
        - oneOf:
            - properties:
                type:
                  const: dimension
                dimension:
                  $ref: '#/components/schemas/DimensionResource'
              required:
                - type
                - dimension
              title: dimension
            - properties:
                type:
                  const: fact
                fact:
                  $ref: '#/components/schemas/FactResource'
              required:
                - type
                - fact
              title: fact
        - oneOf:
            - properties:
                method:
                  const: table
                table:
                  $ref: '#/components/schemas/TableResource'
              required:
                - method
                - table
              title: table
            - properties:
                method:
                  const: sql
                sql:
                  $ref: '#/components/schemas/SQLResource'
              required:
                - method
                - sql
              title: sql
            - properties:
                method:
                  const: glob
                glob:
                  $ref: '#/components/schemas/GlobResource'
              required:
                - method
                - glob
              title: glob
      properties:
        id:
          type: string
        name:
          type: string
        source_id:
          type: string
        is_enabled:
          type: boolean
        frequency_minutes:
          type: integer
        datalake_schema:
          type: string
        datalake_table_name:
          type: string
        created_at:
          type: string
        updated_at:
          type: string
      type: object
      required:
        - id
        - name
        - source_id
        - is_enabled
        - frequency_minutes
        - datalake_schema
        - datalake_table_name
        - created_at
        - updated_at
      unevaluatedProperties: false
    ErrorResponse:
      properties:
        status:
          type: string
          const: error
        message:
          type: string
        data:
          type: 'null'
      type: object
      required:
        - status
        - message
    DimensionOptions:
      properties:
        primary_key_column:
          type: string
          title: Primary Key Column
          description: Name of the primary key column.
        last_modified_column:
          type: string
          title: Last Modified Column
          description: Name of the last modified timestamp column (optional).
        is_deleted_column:
          type: string
          title: Is Deleted Column
          description: Name of the soft delete column (optional).
      additionalProperties: false
      type: object
      required:
        - primary_key_column
    FactOptions:
      properties:
        primary_key_column:
          type: string
          title: Primary Key Column
          description: Name of the primary key column.
        created_at_column:
          type: string
          title: Created At Column
          description: Name of the created at timestamp column (required for facts).
      additionalProperties: false
      type: object
      required:
        - primary_key_column
        - created_at_column
    TableOptions:
      properties:
        source_table_namespace:
          type: string
          pattern: ^[A-Za-z0-9_.]+([-][A-Za-z0-9_.]+)*$
          title: Source Table Namespace
          description: Namespace or schema of the source table.
        source_table_name:
          type: string
          pattern: ^[A-Za-z0-9_.]+([-][A-Za-z0-9_.]+)*$
          title: Source Table Name
          description: Name of the source table.
      additionalProperties: false
      type: object
      required:
        - source_table_namespace
        - source_table_name
    SQLOptions:
      properties:
        query:
          type: string
          title: Query
          description: SQL query to execute.
      additionalProperties: false
      type: object
      required:
        - query
    GlobOptions:
      properties:
        pattern:
          type: string
          title: Pattern
          description: Glob pattern for object files.
        format:
          type: string
          enum:
            - csv
            - parquet
            - jsonl
            - json
          title: Format
          description: Format of the object files.
      additionalProperties: false
      type: object
      required:
        - pattern
        - format
    DimensionResource:
      properties:
        primary_key_column:
          type: string
        last_modified_column:
          type: string
        is_deleted_column:
          type: string
      additionalProperties: false
      type: object
      required:
        - primary_key_column
    FactResource:
      properties:
        primary_key_column:
          type: string
        created_at_column:
          type: string
      additionalProperties: false
      type: object
      required:
        - primary_key_column
        - created_at_column
    TableResource:
      properties:
        source_table_namespace:
          type: string
        source_table_name:
          type: string
      additionalProperties: false
      type: object
      required:
        - source_table_namespace
        - source_table_name
    SQLResource:
      properties:
        query:
          type: string
      additionalProperties: false
      type: object
      required:
        - query
    GlobResource:
      properties:
        pattern:
          type: string
        format:
          type: string
      additionalProperties: false
      type: object
      required:
        - pattern
        - format
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````