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

# Create a data source

> Creates a new data source connection for an organization. Requires admin access to the organization. Currently only direct database connections are supported.

## Side effects

When a data source is successfully created:

1. **Schema sync** - A background job is triggered to connect to the database and sync its schema (tables, columns, etc.)
2. **Trial activation** - If the organization has never been on a trial, a trial period is automatically started


## OpenAPI

````yaml https://charts.basedash.com/api/public/openapi post /api/public/organizations/{orgId}/data-sources
openapi: 3.1.0
info:
  title: Basedash Public API
  version: 0.0.0
  description: >-
    API for programmatic access to Basedash features. Use API keys for
    authentication.
  contact:
    name: Basedash Support
    url: https://basedash.com
    email: support@basedash.com
servers:
  - url: https://charts.basedash.com
    description: Production
security: []
tags:
  - name: Organizations
    description: Manage organizations
  - name: Groups
    description: Manage organization groups and memberships
  - name: Data Sources
    description: Manage database connections and data sources
  - name: MCP servers
    description: Manage MCP server data sources
  - name: Insights
    description: Manage generated insights
  - name: Automations
    description: Manage automations and automation runs
  - name: Skills
    description: Manage organization skills
  - name: Definitions
    description: Manage reusable SQL definitions
paths:
  /api/public/organizations/{orgId}/data-sources:
    post:
      tags:
        - Data Sources
      summary: Create a data source
      description: >-
        Creates a new data source connection for an organization. Requires admin
        access to the organization. Currently only direct database connections
        are supported.
      parameters:
        - schema:
            type: string
            description: Organization ID
          required: true
          description: Organization ID
          name: orgId
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                snowflakeAccountId:
                  type: string
                  description: Snowflake account ID
                snowflakeWarehouse:
                  type: string
                  description: Snowflake warehouse
                snowflakeRole:
                  type: string
                  description: Snowflake role
                snowflakePrivateKey:
                  type: string
                  description: Snowflake private key
                snowflakePrivateKeyPassphrase:
                  type: string
                  description: Snowflake private key passphrase
                databaseName:
                  type:
                    - string
                    - 'null'
                  default: null
                  description: Database name
                username:
                  type: string
                  description: Database username
                host:
                  type: string
                  description: Database host
                port:
                  type: integer
                  minimum: 0
                  maximum: 65535
                  description: Database port
                password:
                  type: string
                  description: Database password
                bigQueryJsonKey:
                  type: string
                  description: BigQuery JSON key
                bigQueryProjectId:
                  type: string
                  description: BigQuery project ID
                spannerInstanceId:
                  type: string
                  description: Spanner instance ID
                athenaWorkgroup:
                  type: string
                  description: Athena workgroup
                athenaOutputLocation:
                  type: string
                  description: Athena output location (s3://...)
                athenaCatalog:
                  type: string
                  description: Athena catalog
                sslEnabled:
                  type: boolean
                  default: true
                  description: Enable SSL connection
                sshEnabled:
                  type: boolean
                  default: false
                  description: Enable SSH tunnel
                sshHost:
                  type: string
                  description: SSH tunnel host
                sshPort:
                  type: integer
                  minimum: 0
                  maximum: 65535
                  description: SSH tunnel port
                sshUsername:
                  type: string
                  description: SSH tunnel username
                sshPassword:
                  type: string
                  description: SSH tunnel password
                sshPrivateKey:
                  type: string
                  description: SSH private key
                sshPrivateKeyPassphrase:
                  type: string
                  description: SSH private key passphrase
                maxPoolSize:
                  type: integer
                  minimum: 1
                  maximum: 100
                  description: Maximum number of connections in the pool per container
                type:
                  type: string
                  enum:
                    - direct
                  description: Connection type (currently only direct)
                dialect:
                  $ref: '#/components/schemas/DatabaseDialect'
                displayName:
                  type: string
                  minLength: 1
                  description: Display name for the data source
              required:
                - type
                - dialect
                - displayName
      responses:
        '201':
          description: Data source created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        description: Data source ID
                      displayName:
                        type: string
                        description: Display name for the data source
                      description:
                        type: string
                        description: Description of the data source
                      dialect:
                        $ref: '#/components/schemas/DatabaseDialect'
                      databaseName:
                        type:
                          - string
                          - 'null'
                        description: Database name
                      username:
                        type:
                          - string
                          - 'null'
                        description: Database username
                      host:
                        type:
                          - string
                          - 'null'
                        description: Database host
                      port:
                        type:
                          - number
                          - 'null'
                        description: Database port
                      sslEnabled:
                        type:
                          - boolean
                          - 'null'
                        description: Whether SSL is enabled
                      sslCustomCertificatesEnabled:
                        type:
                          - boolean
                          - 'null'
                        description: Whether custom SSL certificates are enabled
                      sshEnabled:
                        type:
                          - boolean
                          - 'null'
                        description: Whether SSH tunnel is enabled
                      sshHost:
                        type:
                          - string
                          - 'null'
                        description: SSH tunnel host
                      sshPort:
                        type:
                          - number
                          - 'null'
                        description: SSH tunnel port
                      sshUsername:
                        type:
                          - string
                          - 'null'
                        description: SSH tunnel username
                      bigQueryProjectId:
                        type:
                          - string
                          - 'null'
                        description: BigQuery project ID
                      spannerInstanceId:
                        type:
                          - string
                          - 'null'
                        description: Spanner instance ID
                      athenaWorkgroup:
                        type:
                          - string
                          - 'null'
                        description: Athena workgroup
                      athenaOutputLocation:
                        type:
                          - string
                          - 'null'
                        description: Athena output location
                      athenaCatalog:
                        type:
                          - string
                          - 'null'
                        description: Athena data catalog
                      snowflakeAccountId:
                        type:
                          - string
                          - 'null'
                        description: Snowflake account ID
                      snowflakeWarehouse:
                        type:
                          - string
                          - 'null'
                        description: Snowflake warehouse
                      snowflakeRole:
                        type:
                          - string
                          - 'null'
                        description: Snowflake role
                      lastSuccessfulSyncAt:
                        type:
                          - string
                          - 'null'
                        format: date-time
                        description: Last successful schema sync timestamp
                      lastSyncStatus:
                        $ref: '#/components/schemas/SyncStatus'
                      lastSyncAttemptAt:
                        type:
                          - string
                          - 'null'
                        format: date-time
                        description: Last schema sync attempt timestamp
                      hasCompletedFirstSync:
                        type: boolean
                        description: Whether the first schema sync has completed
                      syncErrorMessage:
                        type:
                          - string
                          - 'null'
                        description: Error message from the last failed sync
                      lastHealthyAt:
                        type: string
                        format: date-time
                        description: Last time the connection was healthy
                      lastHealthStatus:
                        $ref: '#/components/schemas/ConnectionHealthStatus'
                      lastHealthCheckAttemptAt:
                        type: string
                        format: date-time
                        description: Last health check attempt timestamp
                      isDemo:
                        type: boolean
                        description: Whether this is a demo data source
                      isBasedashWarehouse:
                        type: boolean
                        description: Whether this is a Basedash-managed warehouse
                      mutatingQueriesEnabled:
                        type: boolean
                        description: Whether admins can approve AI-generated database edits
                      createdAt:
                        type: string
                        format: date-time
                        description: Creation timestamp
                      updatedAt:
                        type: string
                        format: date-time
                        description: Last update timestamp
                    required:
                      - id
                      - displayName
                      - description
                      - dialect
                      - databaseName
                      - username
                      - host
                      - port
                      - sslEnabled
                      - sslCustomCertificatesEnabled
                      - sshEnabled
                      - sshHost
                      - sshPort
                      - sshUsername
                      - bigQueryProjectId
                      - spannerInstanceId
                      - athenaWorkgroup
                      - athenaOutputLocation
                      - athenaCatalog
                      - snowflakeAccountId
                      - snowflakeWarehouse
                      - snowflakeRole
                      - lastSuccessfulSyncAt
                      - lastSyncStatus
                      - lastSyncAttemptAt
                      - hasCompletedFirstSync
                      - syncErrorMessage
                      - lastHealthyAt
                      - lastHealthStatus
                      - lastHealthCheckAttemptAt
                      - isDemo
                      - isBasedashWarehouse
                      - mutatingQueriesEnabled
                      - createdAt
                      - updatedAt
                required:
                  - data
        '400':
          description: >-
            Bad request - Invalid JSON body, validation error, or unsupported
            type
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found - Organization not found or no admin access
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded - Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    DatabaseDialect:
      anyOf:
        - type: string
          enum:
            - POSTGRES
        - type: string
          enum:
            - SUPABASE
        - type: string
          enum:
            - MYSQL
        - type: string
          enum:
            - PLANETSCALE
        - type: string
          enum:
            - ATHENA
        - type: string
          enum:
            - BIGQUERY
        - type: string
          enum:
            - CLICKHOUSE
        - type: string
          enum:
            - SPANNER
        - type: string
          enum:
            - SNOWFLAKE
        - type: string
          enum:
            - REDSHIFT
        - type: string
          enum:
            - SQL_SERVER
        - type: string
          enum:
            - ORACLE
        - type: string
          enum:
            - DATABRICKS
        - type: string
          enum:
            - POSTHOG
        - type: string
          enum:
            - DUCKDB
      description: Database dialect/type
    SyncStatus:
      anyOf:
        - type: string
          enum:
            - PENDING
        - type: string
          enum:
            - SUCCESS
        - type: string
          enum:
            - FAILED
        - type: string
          enum:
            - NEVER_SYNCED
      description: Status of the last schema sync
    ConnectionHealthStatus:
      anyOf:
        - type: string
          enum:
            - HEALTHY
        - type: string
          enum:
            - UNHEALTHY
      description: Connection health status
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ApiError'
      required:
        - error
    RateLimitErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/RateLimitError'
      required:
        - error
    ApiError:
      type: object
      properties:
        title:
          type: string
          description: Error type identifier
        detail:
          type: string
          description: Human-readable error description
      required:
        - title
        - detail
    RateLimitError:
      allOf:
        - $ref: '#/components/schemas/ApiError'
        - type: object
          properties:
            title:
              type: string
              enum:
                - RateLimitExceeded
            retryAfterMs:
              type: number
              description: Milliseconds until the rate limit window resets
          required:
            - retryAfterMs
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authentication using Bearer token format: `Bearer
        <basedash_api_key>`

````