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

# Add a Datasource

> This endpoint creates and stores a Datasource with the provided details.

### Auth Headers

<ParamField required header="x-metal-api-key" type="string">
  An API key for your org.
</ParamField>

<ParamField required header="x-metal-client-id" type="string">
  A Client ID for your org.
</ParamField>

### Body

<ParamField body="name" type="string" placeholder="Datasource Name" required>
  Name of the Datasource.
</ParamField>

<ParamField body="sourcetype" type="string" placeholder="Source Type" required>
  Type of the source. File or Text.
</ParamField>

<ParamField body="autoExtract" type="boolean" required>
  Flag indicating whether auto-extraction is enabled. If disabled, it will
  short-cirtuit to bypass extraction.
</ParamField>

<ParamField body="metadataFields" type="array">
  An array containing metadata fields. Each object should have `name`, `type`,
  `description`, and `autoExtract` properties.
</ParamField>

<RequestExample>
  ```bash Example Request theme={null}
  curl -X POST "https://api.getmetal.io/v1/datasources" \
  --header 'Content-Type: application/json' \
  --header 'x-metal-api-key: <api-key>' \
  --header 'x-metal-client-id: <client-id>' \
  --data-raw '{
      "name": "my_datasource",
      "metadataFields": [
        {
          "name": "band",
          "type": "string",
          "description": "The band that the uploaded file is about.",
          "autoExtract": true
        },
        {
          "name": "author",
          "type": "string",
          "autoExtract": false
        }
      ],
      "sourcetype": "file",
      "autoExtract": true
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "data": {
      "id": "datasourceID",
      "createdAt": "2023-08-29T10:51:04.246Z",
      "createdBy": "userId",
      "name": "my_datasource",
      "metadataFields": [
        // Extracted field, which we will detect on upload
        {
          "name": "band",
          "type": "string",
          "description": "Which heavy metal band is represented by the iconic mascot Eddie?",
          "autoExtract": true
        },
        // Normal field, which needs to be manually set on upload
        {
          "name": "author",
          "type": "string",
          "autoExtract": false
        }
      ],
      "sourcetype": "File",
      "autoExtract": true
    }
  }
  ```
</ResponseExample>
