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

# Create data source

> Creates a data source in the specified dataset. 




## OpenAPI

````yaml post /v1/team/datasets/{datasetId}/datasources
openapi: 3.0.1
info:
  title: Team Open API
  description: ''
  version: 1.0.0
servers:
  - url: https://ai.data.cloud/api
    description: 体验环境
security: []
tags:
  - name: Session
  - name: Dataset
  - name: Data source
  - name: File
  - name: Job
paths:
  /v1/team/datasets/{datasetId}/datasources:
    post:
      tags:
        - Data source
      summary: Create data source
      description: |
        Creates a data source in the specified dataset. 
      parameters:
        - name: datasetId
          in: path
          description: The dataset ID.
          required: true
          schema:
            type: string
        - name: userId
          in: query
          description: >-
            Your user ID.


            How to obtain your user ID: Sign in to Powerdrill Enterprise, click
            **Users** in the top navigation bar, and find your user ID in the
            list of users.
          required: true
          schema:
            type: string
        - name: x-pd-external-trace-id
          in: header
          description: The external trace ID. The length ranges from 0 to 128 characters.
          required: false
          example: ''
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: >-
                    The name of the data source. If not provided, it will
                    default to the value of `fileName`.
                fileName:
                  type: string
                  description: The file name, preferably including the file extension.
                type:
                  type: string
                  description: The type of the data source. Set it to **FILE**.
                  title: FILE
                url:
                  type: string
                  description: >-
                    The URL of the file for public access. 


                    Only files with the following extensions are supported:
                    **.csv**, **.tsv**, **.md**, **.mdx**, **.json**, **.txt**,
                    **.pdf**, **.pptx**, **.ppt**, **.doc**, **.docx**,
                    **.xls**, or **.xlsx**.


                    You must specify either `url` or `fileKey`, but not both.
                fileKey:
                  type: string
                  description: >-
                    The object storage path to your locally uploaded file.


                    Only files with the following extensions are supported:
                    **.csv**, **.tsv**, **.md**, **.mdx**, **.json**, **.txt**,
                    **.pdf**, **.pptx**, **.ppt**, **.doc**, **.docx**,
                    **.xls**, or **.xlsx**.


                    Each time you upload a file through the [Upload
                    file](/api-reference/upload-file) endpoint, its `fileKey` is
                    returned. For more details, see [How to Upload Local
                    Files](/developer-guides/upload-file).


                    You must specify either `url` or `fileKey`, but not both.
                userId:
                  type: string
                  description: >-
                    Your user ID. 


                    How to obtain your user ID: Sign in to Powerdrill
                    Enterprise, click **Users** in the top navigation bar, and
                    find your user ID in the list of users.
              required:
                - fileName
                - type
                - userId
            example:
              name: test.csv
              fileName: test.csv
              type: FILE
              url: >-
                https://s3.amazonaws.com/powerdrilltest/user/clvl4cad2001q01l1m522hxlu/upload/f9773f1e-cd68-489a-8121-d566ca9218b1.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20240924T143419Z&X-Amz-SignedHeaders=host&X-Amz-Expires=599&X-Amz-Credential=AKIARLSQLXURHEIDN4OZ%2F20240924%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=9ca0c58d508926a5811818041d557ffb53c64025dae94c0855280d457c7089a2
              userId: tmm-cm5m7khoz52zh07n4m7x1ut60
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    description: >-
                      Status code. **0** indicates that the operation is
                      successful. Otherwise, the operation fails. Possible error
                      codes include: 

                      - 100: Bad request. 

                      - 201: Request frequency limit.

                      - 9999: Internal error. 

                      - 100001: Invalid operation. 
                  data:
                    $ref: '#/components/schemas/DatasourceDTO'
                    description: The returned data object.
                required:
                  - data
                  - code
              examples:
                '1':
                  summary: Success example
                  value:
                    code: 0
                    data:
                      id: datasource-cadsgfsdagasgadsg
                      datasetId: dataset-dagasdgasgasg
                      name: test.csv
                      fileName: test.csv
                      type: FILE
                      status: pending
          headers:
            x-pd-trace-id:
              example: ''
              required: true
              description: The trace ID of Powerdrill.
              schema:
                type: string
      deprecated: false
      security:
        - apikey-header-x-pd-api-key: []
components:
  schemas:
    DatasourceDTO:
      type: object
      properties:
        id:
          type: string
          description: The data source ID, which uniquely identifies the data source.
        datasetId:
          type: string
          description: The dataset ID.
        name:
          type: string
          description: The data source name.
        fileName:
          type: string
          description: The file name.
        type:
          type: string
          description: The type of the data source, which is fixed to **FILE**.
          enum:
            - FILE
        status:
          type: string
          description: |-
            The processing status of the data source. Possible values are:
            - `invalid`: Awaiting processing.
            - `synching`: Currently processing.
            - `synched`: Successfully synchronized.
          enum:
            - synching
            - synched
            - invalid
        userId:
          type: string
          description: >-
            Your user ID. 


            How to obtain your user ID: Sign in to Powerdrill Enterprise, click
            **Users** in the top navigation bar, and find your user ID in the
            list of users.
      required:
        - id
        - name
        - type
        - datasetId
        - status
        - fileName
        - userId
  securitySchemes:
    apikey-header-x-pd-api-key:
      type: apiKey
      in: header
      name: x-pd-api-key

````