> ## 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. You can create data sources only in datasets that you have created.

A data source can be in one of the following formats: **.csv**, **.tsv**, **.md**, **.mdx**, **.json**, **.txt**, **.pdf**, **.pptx**, **.docx**, **.xls**, or **.xlsx**.



## OpenAPI

````yaml POST /v2/team/datasets/{id}/datasources
openapi: 3.0.1
info:
  title: Team Open API Snake
  description: ''
  version: 1.0.0
servers:
  - url: https://ai.data.cloud/api
    description: 体验环境
security:
  - apikey-header-x-pd-api-key: []
tags:
  - name: Session
  - name: Dataset
  - name: Data source
  - name: File
  - name: Job
paths:
  /v2/team/datasets/{id}/datasources:
    post:
      tags:
        - Data source
      summary: Create data source
      description: >-
        Creates a data source in the specified dataset. You can create data
        sources only in datasets that you have created.


        A data source can be in one of the following formats: **.csv**,
        **.tsv**, **.md**, **.mdx**, **.json**, **.txt**, **.pdf**, **.pptx**,
        **.docx**, **.xls**, or **.xlsx**.
      parameters:
        - name: id
          in: path
          description: >-
            The ID of the dataset in which you want to create a data  source.


            To check the datasets you have access to, call [GET
            /v2/team/datasets](/api-reference/v2/list-datasets).
          required: true
          schema:
            type: string
        - name: x-pd-external-trace-id
          in: header
          description: >-
            The trace ID you set in your system to trace this request. It can be
            up to 128 characters in length. If the request fails, you can
            provide it to the Powerdrill team to help with troubleshooting.
          required: false
          example: ''
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: >-
                    The name of the data source, including the file extension
                    (e.g., `example.csv`). The name must be between 1 and 128
                    characters. If it exceeds this limit, it will be truncated.
                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. 


                    You must specify either `url` or `file_object_key`, but not
                    both.


                    Only files with the following extensions are supported:
                    **.csv**, **.tsv**, **.md**, **.mdx**, **.json**, **.txt**,
                    **.pdf**, **.pptx**, **.docx**, **.xls**, or **.xlsx**.
                file_object_key:
                  type: string
                  description: >
                    The object storage path to your locally uploaded file.


                    You must specify either `url` or `file_object_key`, but not
                    both.


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


                    How to obtain:


                    Each time you upload a file through the [Upload
                    file](/api-reference/v2/upload-file) endpoint, its
                    `file_object_key` is returned. For more details, see [How to
                    Upload Local Files](/developer-guides/upload-file).
                user_id:
                  type: string
                  description: >-
                    Your user ID, which uniquely identifies you within your
                    team. To obtain your ID:


                    - If you're the team admin, refer to [Check user
                    information](/enterprise/users#check-user-information).

                    - If you're a system or virtual user, ask your team admin to
                    check your user ID by referring to [Check user
                    information](/enterprise/users#check-user-information).
              required:
                - name
                - type
                - user_id
            example:
              name: test.csv
              type: FILE
              user_id: tmm-dsfasdfasdfa
              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
      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. For error
                      troubleshooting, refer to [Error
                      Codes](/api-reference/error-codes).
                  data:
                    description: A data source object.
                    type: object
                    properties:
                      id:
                        type: string
                        description: >-
                          The data source ID, which uniquely identifies the data
                          source.
                      dataset_id:
                        type: string
                        description: The ID of the dataset that hosts the data source.
                      name:
                        type: string
                        description: The data source 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
                    required:
                      - id
                      - dataset_id
                      - name
                      - type
                      - status
                required:
                  - data
                  - code
              example:
                code: 0
                data:
                  id: datasource-cadsgfsdagasgadsg
                  dataset_id: dataset-dagasdgasgasg
                  name: test.csv
                  type: FILE
                  status: synching
          headers:
            x-pd-trace-id:
              example: ''
              required: true
              description: >-
                The trace ID returned by Powerdrill. If a failure occurs, you
                can provide it to the Powerdrill team to assist with
                troubleshooting.
              schema:
                type: string
      deprecated: false
      security:
        - apikey-header-x-pd-api-key: []
components:
  securitySchemes:
    apikey-header-x-pd-api-key:
      type: apiKey
      in: header
      name: x-pd-api-key

````