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

# Create a resource

> Add data sources for Brewit to use.

<RequestExample>
  ```bash theme={null}
  curl --request POST \
      --url https://api.brewit.ai/v2/datasets/3fa85f64-5717-4562-b3fc-2c963f66afa6/resources \
      --header 'Content-Type: application/json' \
      --header 'Authorization: Bearer access-token' \
      --data '{
          "name": "resource name",
          "description": "resource description",
          "type": "db:postgres",
          "db_credentials": {...}
      }'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "name": "resource name",
      "description": "resource description",
      "type": "db:postgres",
      "db_credentials": {...},
      "dataset_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "owner_id": 1,
      "created_at": "2024-01-02T03:04:05.000000",
      "updated_at": "2024-01-02T03:04:05.000000"
  }
  ```
</ResponseExample>

<ParamField path="dataset_id" type="string" required>
  The identifier of the dataset (workspace) to which the resource belongs.
</ParamField>

## Body Parameters

<ParamField body="name" type="string" required>
  The name of the resource to display in the Brewit UI.
</ParamField>

<ParamField body="description" type="string">
  The description of the resource to display in the Brewit UI.
</ParamField>

<ParamField body="type" type="enum" required>
  The type of resource you are connecting to. Currently, we support: `db:mysql`
  (MySQL), `db:postgres` (PostgreSQL), `dw:bigquery` (BigQuery), `dw:snowflake`
  (Snowflake).
</ParamField>

<ParamField body="db_credentials" type="object" required>
  The credentials to connect to the resource. We will store the credentials securely and only display the insensitive fields (e.g. host, port, etc.) in the response.

  <Accordion title="MySQL">
    ```json theme={null}
    {
        "username": "username",
        "password": "password",
        "host": "host",
        "port": 3306,
        "dbname": "database name"
    }
    ```
  </Accordion>

  <Accordion title="PostgreSQL">
    ```json theme={null}
    {
        "username": "username",
        "password": "password",
        "host": "host",
        "port": 5432,
        "dbname": "database name"
    }
    ```
  </Accordion>

  <Accordion title="BigQuery">
    You should extract the JSON from the service account key file downloaded from the Google Cloud Console.

    ```json theme={null}
    {
        "type": "service_account",
        "project_id": "project_id",
        "private_key_id": "private_key_id",
        "private_key": "private_key",
        "client_email": "client_email",
        "client_id": "client_id",
        "auth_uri": "auth_uri",
        "token_uri": "token_uri",
        "auth_provider_x509_cert_url": "auth_provider_x509_cert_url",
        "client_x509_cert_url": "client_x509_cert_url"
    }
    ```
  </Accordion>

  <Accordion title="Snowflake">
    ```json theme={null}
    {
        "account": "account",
        "user": "user",
        "password": "password",
        "warehouse": "warehouse",
        "database": "database",
        "role": "role",
    }
    ```
  </Accordion>
</ParamField>
