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

# Update Datasource

> Update the credentials and configuration of an existing datasource. The API validates and tests the new credentials before applying changes.

Update an existing datasource's credentials or configuration. The API validates the new credentials, tests the connection, and automatically refreshes the cached schema.

<Note>
  You can only update datasources that already exist in your organization. The datasource is identified by the `name` field in the credentials. After updating, the schema will be automatically re-cached.
</Note>

## Endpoint

```
PUT https://api.usedatabrain.com/api/v2/datasource
```

## Self-hosted Databrain Endpoint

```
PUT <SELF_HOSTED_URL>/api/v2/datasource
```

## Authentication

This endpoint requires a service token in the Authorization header. Service tokens differ from data app API keys and provide organization-level permissions.

To access your service token:

1. In **Settings** page, navigate to the **Service Tokens** section.
2. Click the **"Generate Token"** button to create a new service token if you don't have one already.

<Panel>
  <RequestExample>
    ```bash Authentication theme={"dark"}
    curl --request PUT \
      --url https://api.usedatabrain.com/api/v2/datasource \
      --header 'Authorization: Bearer dbn_live_...' \
      --header 'Content-Type: application/json'
    ```
  </RequestExample>
</Panel>

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for API authentication. Use your service token.

  ```
  Authorization: Bearer dbn_live_abc123...
  ```
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be set to `application/json` for all requests.

  ```
  Content-Type: application/json
  ```
</ParamField>

## Request Body

<ParamField body="datasourceType" type="string" required>
  The type of datasource. Must match the existing datasource type. See [Create Datasource](/developer-docs/helpers/api-reference/create-datasource) for supported types.
</ParamField>

<ParamField body="credentials" type="object" required>
  Updated connection credentials for the datasource. Must include the `name` field matching the existing datasource name.

  <Warning>
    The `credentials.name` field must match the exact name of the existing datasource you want to update. This name is used to identify which datasource to update.
  </Warning>
</ParamField>

<ParamField body="credentials.name" type="string" required>
  The name of the existing datasource to update. Must match exactly as it was created.

  <Expandable title="Finding datasource names">
    * Use the [List Datasources API](/developer-docs/helpers/api-reference/list-datasources) to see all datasource names
    * Check the response from datasource creation
    * Available in the DataBrain dashboard when viewing datasources
  </Expandable>
</ParamField>

<ParamField body="tenancySettings" type="object">
  Multi-tenant configuration for the datasource. Defines how data is isolated between different tenants/clients. Optional - if not provided, existing tenancy settings will remain unchanged.

  <Expandable title="Tenancy configuration details">
    * **TABLE level**: Uses a dedicated table to map client identifiers
    * **DATABASE level**: Each client has a separate database
    * If the datasource doesn't have existing tenancy settings, new settings will be created
    * If tenancy settings already exist, they will be updated with the new values
  </Expandable>
</ParamField>

<ParamField body="tenancySettings.tenancyLevel" type="string">
  The level at which tenant isolation occurs. Must be one of: `TABLE` or `DATABASE`.

  * `TABLE`: Client mapping is stored in a specific table (most common)
  * `DATABASE`: Each client has a separate database instance

  **Required when** `tenancySettings` is provided. If `tenancySettings` is omitted, this field is not needed.
</ParamField>

<ParamField body="tenancySettings.clientColumnType" type="string">
  Data type of the client identifier column. Must be either `NUMBER` or `STRING`.

  **Required when** `tenancyLevel` is `TABLE`.
</ParamField>

<ParamField body="tenancySettings.schemaName" type="string">
  Schema name where the client mapping table is located.

  **Required when** `tenancyLevel` is `TABLE`.
</ParamField>

<ParamField body="tenancySettings.tableName" type="string">
  Name of the table that contains client mapping information.

  **Required when** `tenancyLevel` is `TABLE`.
</ParamField>

<ParamField body="tenancySettings.tableClientNameColumn" type="string">
  Column name in the mapping table that stores the client identifier.

  **Required when** `tenancyLevel` is `TABLE`.
</ParamField>

<ParamField body="tenancySettings.tablePrimaryKeyColumn" type="string">
  Primary key column of the client mapping table.

  **Required when** `tenancyLevel` is `TABLE`.
</ParamField>

### Datasource-Specific Credentials

You must provide all required fields for the datasource type, even if only some values are changing. Partial updates are not supported.

<Note>
  When updating credentials, provide the complete credential structure for the datasource type. Partial updates are not supported.
</Note>

<ParamField body="credentials" type="object">
  Datasource-specific credential fields. The required fields depend on the `datasourceType`.

  <AccordionGroup>
    <Accordion title="Snowflake">
      <ParamField body="credentials.host" type="string" required>
        Snowflake account hostname (e.g., `your-account.snowflakecomputing.com`)
      </ParamField>

      <ParamField body="credentials.username" type="string" required>
        Snowflake username
      </ParamField>

      <ParamField body="credentials.role" type="string" required>
        Snowflake role to use
      </ParamField>

      <ParamField body="credentials.warehouse" type="string" required>
        Snowflake warehouse name
      </ParamField>

      <ParamField body="credentials.database" type="string" required>
        Snowflake database name
      </ParamField>

      <ParamField body="credentials.schema" type="string" required>
        Snowflake schema name
      </ParamField>

      <ParamField body="credentials.credentials" type="string" required>
        Authentication method: `"username/password"` or `"Key-pair authentication"`
      </ParamField>

      <ParamField body="credentials.password" type="string">
        Password (required if credentials is `"username/password"`)
      </ParamField>

      <ParamField body="credentials.privateKey" type="string">
        Private key (required if credentials is `"Key-pair authentication"`)
      </ParamField>

      <ParamField body="credentials.privateKeyPass" type="string">
        Passphrase for the private key (optional)
      </ParamField>
    </Accordion>

    <Accordion title="Postgres / Redshift">
      <ParamField body="credentials.host" type="string" required>
        Database hostname or IP address
      </ParamField>

      <ParamField body="credentials.port" type="number" required>
        Database port number (1-65535)
      </ParamField>

      <ParamField body="credentials.username" type="string" required>
        Database username
      </ParamField>

      <ParamField body="credentials.password" type="string" required>
        Database password
      </ParamField>

      <ParamField body="credentials.database" type="string" required>
        Database name
      </ParamField>

      <ParamField body="credentials.schema" type="string" required>
        Schema name
      </ParamField>

      <ParamField body="credentials.sslMode" type="boolean">
        Enable SSL mode (optional)
      </ParamField>

      <ParamField body="credentials.sshTunnel" type="string">
        SSH tunnel setting: `"enable"` or `"disable"` (optional)
      </ParamField>

      <ParamField body="credentials.sshHost" type="string">
        SSH server hostname (required if sshTunnel is `"enable"`)
      </ParamField>

      <ParamField body="credentials.sshPort" type="number">
        SSH server port (required if sshTunnel is `"enable"`)
      </ParamField>

      <ParamField body="credentials.sshUsername" type="string">
        SSH username (required if sshTunnel is `"enable"`)
      </ParamField>

      <ParamField body="credentials.sshPrivateKey" type="string">
        SSH private key (required if sshTunnel is `"enable"`)
      </ParamField>
    </Accordion>

    <Accordion title="CockroachDB">
      <ParamField body="credentials.host" type="string" required>
        CockroachDB hostname or IP address
      </ParamField>

      <ParamField body="credentials.port" type="number" required>
        Database port number (1-65535)
      </ParamField>

      <ParamField body="credentials.username" type="string" required>
        Database username
      </ParamField>

      <ParamField body="credentials.password" type="string" required>
        Database password
      </ParamField>

      <ParamField body="credentials.database" type="string" required>
        Database name
      </ParamField>

      <ParamField body="credentials.schema" type="string" required>
        Schema name
      </ParamField>

      <ParamField body="credentials.sslMode" type="boolean">
        Enable SSL mode (optional)
      </ParamField>

      <ParamField body="credentials.sshTunnel" type="string">
        SSH tunnel setting: `"enable"` or `"disable"` (optional)
      </ParamField>

      <ParamField body="credentials.sshHost" type="string">
        SSH server hostname (required if sshTunnel is `"enable"`)
      </ParamField>

      <ParamField body="credentials.sshPort" type="number">
        SSH server port (required if sshTunnel is `"enable"`)
      </ParamField>

      <ParamField body="credentials.sshUsername" type="string">
        SSH username (required if sshTunnel is `"enable"`)
      </ParamField>

      <ParamField body="credentials.sshPrivateKey" type="string">
        SSH private key (required if sshTunnel is `"enable"`)
      </ParamField>
    </Accordion>

    <Accordion title="BigQuery">
      <ParamField body="credentials.credentials_json" type="string" required>
        JSON string containing Google Cloud service account credentials
      </ParamField>

      <ParamField body="credentials.project_id" type="string" required>
        Google Cloud project ID
      </ParamField>

      <ParamField body="credentials.dataset_location" type="string" required>
        BigQuery dataset location (e.g., `"US"`, `"EU"`)
      </ParamField>

      <ParamField body="credentials.dataset_id" type="string">
        BigQuery dataset ID (optional)
      </ParamField>
    </Accordion>

    <Accordion title="MySQL / MongoDB / ClickHouse">
      <ParamField body="credentials.host" type="string" required>
        Database hostname or IP address
      </ParamField>

      <ParamField body="credentials.port" type="number" required>
        Database port number (1-65535)
      </ParamField>

      <ParamField body="credentials.user" type="string" required>
        Database username. Note: Uses `user` not `username` for these datasource types.
      </ParamField>

      <ParamField body="credentials.password" type="string" required>
        Database password
      </ParamField>
    </Accordion>

    <Accordion title="MSSQL">
      <ParamField body="credentials.server" type="string" required>
        SQL Server hostname or IP address. Note: Uses `server` not `host` for MSSQL.
      </ParamField>

      <ParamField body="credentials.port" type="number" required>
        Database port number (1-65535)
      </ParamField>

      <ParamField body="credentials.user" type="string" required>
        Database username. Note: Uses `user` not `username` for MSSQL.
      </ParamField>

      <ParamField body="credentials.password" type="string" required>
        Database password
      </ParamField>

      <ParamField body="credentials.database" type="string">
        Database name (optional)
      </ParamField>

      <ParamField body="credentials.isDisableDatabase" type="boolean">
        Disable database selection (optional)
      </ParamField>

      <ParamField body="credentials.readOnlyIntent" type="boolean">
        Optional MSSQL read-only routing hint. When `true`, Databrain connects with read-only intent for MSSQL workloads.
      </ParamField>
    </Accordion>

    <Accordion title="SingleStore">
      <ParamField body="credentials.host" type="string" required>
        Database hostname or IP address
      </ParamField>

      <ParamField body="credentials.port" type="number" required>
        Database port number (1-65535)
      </ParamField>

      <ParamField body="credentials.user" type="string" required>
        Database username
      </ParamField>

      <ParamField body="credentials.password" type="string" required>
        Database password
      </ParamField>

      <ParamField body="credentials.database" type="string" required>
        Database name
      </ParamField>
    </Accordion>

    <Accordion title="Databricks">
      <ParamField body="credentials.serverHostname" type="string" required>
        Databricks server hostname
      </ParamField>

      <ParamField body="credentials.httpPath" type="string" required>
        Databricks HTTP path
      </ParamField>

      <ParamField body="credentials.token" type="string" required>
        Databricks access token
      </ParamField>
    </Accordion>

    <Accordion title="Elasticsearch">
      <ParamField body="credentials.server_type" type="string" required>
        Server type: `"elastic-cloud"`, `"open-cloud"`, or `"self-managed"`
      </ParamField>

      <ParamField body="credentials.cloud_id" type="string">
        Cloud ID (required if server\_type is `"elastic-cloud"` or `"open-cloud"`)
      </ParamField>

      <ParamField body="credentials.server_url" type="string">
        Server URL (required if server\_type is `"self-managed"`)
      </ParamField>

      <ParamField body="credentials.username" type="string">
        Username (required unless `disableAuth` is `true`)
      </ParamField>

      <ParamField body="credentials.password" type="string">
        Password (required unless `disableAuth` is `true`)
      </ParamField>

      <ParamField body="credentials.disableAuth" type="boolean">
        Disable authentication (optional, default `false`). Only valid when server\_type is `"self-managed"`.
      </ParamField>

      <ParamField body="credentials.isIgnoreVerifyCert" type="boolean">
        Ignore certificate verification (optional)
      </ParamField>

      <ParamField body="credentials.isIgnoreSsl" type="boolean">
        Ignore SSL (optional)
      </ParamField>
    </Accordion>

    <Accordion title="OpenSearch">
      <ParamField body="credentials.server_type" type="string" required>
        Server type: `"elastic-cloud"`, `"open-cloud"`, or `"self-managed"`
      </ParamField>

      <ParamField body="credentials.cloud_id" type="string">
        Cloud ID (required if server\_type is `"elastic-cloud"` or `"open-cloud"`)
      </ParamField>

      <ParamField body="credentials.server_url" type="string">
        Server URL (required if server\_type is `"self-managed"`)
      </ParamField>

      <ParamField body="credentials.username" type="string">
        Username (required unless `disableAuth` is `true`)
      </ParamField>

      <ParamField body="credentials.password" type="string">
        Password (required unless `disableAuth` is `true`)
      </ParamField>

      <ParamField body="credentials.disableAuth" type="boolean">
        Disable authentication (optional, default `false`). Only valid when server\_type is `"self-managed"`.
      </ParamField>

      <ParamField body="credentials.isIgnoreVerifyCert" type="boolean">
        Ignore certificate verification (optional)
      </ParamField>

      <ParamField body="credentials.isIgnoreSsl" type="boolean">
        Ignore SSL (optional)
      </ParamField>
    </Accordion>

    <Accordion title="Firebolt">
      <ParamField body="credentials.client_id" type="string" required>
        Firebolt client ID
      </ParamField>

      <ParamField body="credentials.client_secret" type="string" required>
        Firebolt client secret
      </ParamField>

      <ParamField body="credentials.account" type="string" required>
        Firebolt account name
      </ParamField>

      <ParamField body="credentials.database" type="string" required>
        Database name
      </ParamField>

      <ParamField body="credentials.engineName" type="string" required>
        Engine name
      </ParamField>

      <ParamField body="credentials.schema" type="string">
        Schema name (optional)
      </ParamField>
    </Accordion>

    <Accordion title="Athena">
      <ParamField body="credentials.database" type="string" required>
        Athena database name
      </ParamField>

      <ParamField body="credentials.outputBucket" type="string" required>
        S3 output bucket for query results
      </ParamField>

      <ParamField body="credentials.s3AccessKeyId" type="string" required>
        AWS access key ID
      </ParamField>

      <ParamField body="credentials.s3Region" type="string" required>
        AWS region
      </ParamField>

      <ParamField body="credentials.s3SecretAccessKey" type="string" required>
        AWS secret access key
      </ParamField>

      <ParamField body="credentials.datasourceId" type="string">
        Datasource ID (optional)
      </ParamField>
    </Accordion>

    <Accordion title="Trino">
      <ParamField body="credentials.host" type="string" required>
        Trino hostname or IP address
      </ParamField>

      <ParamField body="credentials.port" type="number" required>
        Database port number (1-65535)
      </ParamField>

      <ParamField body="credentials.catalog" type="string" required>
        Trino catalog name
      </ParamField>

      <ParamField body="credentials.schema" type="string" required>
        Schema name
      </ParamField>

      <ParamField body="credentials.username" type="string" required>
        Username
      </ParamField>

      <ParamField body="credentials.password" type="string" required>
        Password
      </ParamField>

      <ParamField body="credentials.sshTunnel" type="string">
        SSH tunnel setting: `"enable"` or `"disable"` (optional)
      </ParamField>

      <ParamField body="credentials.sshHost" type="string">
        SSH host (required if sshTunnel is `"enable"`)
      </ParamField>

      <ParamField body="credentials.sshPort" type="number">
        SSH port (required if sshTunnel is `"enable"`)
      </ParamField>

      <ParamField body="credentials.sshUsername" type="string">
        SSH username (required if sshTunnel is `"enable"`)
      </ParamField>

      <ParamField body="credentials.sshPrivateKey" type="string">
        SSH private key (required if sshTunnel is `"enable"`)
      </ParamField>
    </Accordion>

    <Accordion title="CSV">
      <ParamField body="credentials.name" type="string" required>
        Name for the CSV datasource
      </ParamField>
    </Accordion>

    <Accordion title="AWS S3">
      <ParamField body="credentials.bucketName" type="string" required>
        S3 bucket name
      </ParamField>

      <ParamField body="credentials.datasetPath" type="string">
        Path within the bucket (optional, can be empty string)
      </ParamField>

      <ParamField body="credentials.s3Region" type="string" required>
        AWS region (e.g., `"us-east-1"`)
      </ParamField>

      <ParamField body="credentials.tableLevel" type="string">
        Table level: `"File"` or `"Folder"` (optional)
      </ParamField>

      <ParamField body="credentials.s3AccessKeyId" type="string" required>
        AWS access key ID
      </ParamField>

      <ParamField body="credentials.s3SecretAccessKey" type="string" required>
        AWS secret access key
      </ParamField>
    </Accordion>
  </AccordionGroup>
</ParamField>

## Response

<ResponseField name="name" type="string">
  The name of the updated datasource (same as credentials.name).
</ResponseField>

<ResponseField name="error" type="null">
  Error field, null when successful. Not included in successful responses.
</ResponseField>

## Examples

<Panel>
  <RequestExample>
    ```bash cURL - PostgreSQL Example theme={"dark"}
    curl --request PUT \
      --url https://api.usedatabrain.com/api/v2/datasource \
      --header 'Authorization: Bearer dbn_live_abc123...' \
      --header 'Content-Type: application/json' \
      --data '{
        "datasourceType": "postgres",
        "credentials": {
          "name": "production-postgres",
          "host": "new-db.example.com",
          "port": 5432,
          "username": "dbuser",
          "password": "newpassword",
          "database": "analytics",
          "schema": "public"
        }
      }'
    ```

    ```bash cURL - Snowflake Example theme={"dark"}
    curl --request PUT \
      --url https://api.usedatabrain.com/api/v2/datasource \
      --header 'Authorization: Bearer dbn_live_abc123...' \
      --header 'Content-Type: application/json' \
      --data '{
        "datasourceType": "snowflake",
        "credentials": {
          "name": "analytics-snowflake",
          "host": "account.snowflakecomputing.com",
          "username": "user@example.com",
          "role": "ANALYST",
          "warehouse": "COMPUTE_WH",
          "database": "ANALYTICS",
          "schema": "PUBLIC",
          "credentials": "username/password",
          "password": "updatedpassword"
        }
      }'
    ```

    ```bash cURL - MSSQL Example theme={"dark"}
    curl --request PUT \
      --url https://api.usedatabrain.com/api/v2/datasource \
      --header 'Authorization: Bearer dbn_live_abc123...' \
      --header 'Content-Type: application/json' \
      --data '{
        "datasourceType": "mssql",
        "credentials": {
          "name": "production-mssql",
          "server": "sqlserver.example.com",
          "port": 1433,
          "user": "sqluser",
          "password": "updatedpassword",
          "database": "analytics",
          "readOnlyIntent": true
        }
      }'
    ```

    ```bash cURL - CockroachDB Example theme={"dark"}
    curl --request PUT \
      --url https://api.usedatabrain.com/api/v2/datasource \
      --header 'Authorization: Bearer dbn_live_abc123...' \
      --header 'Content-Type: application/json' \
      --data '{
        "datasourceType": "cockroachdb",
        "credentials": {
          "name": "production-cockroachdb",
          "host": "cockroach.example.com",
          "port": 26257,
          "username": "dbuser",
          "password": "updatedpassword",
          "database": "analytics",
          "schema": "public"
        }
      }'
    ```

    ```bash cURL - OpenSearch Example theme={"dark"}
    curl --request PUT \
      --url https://api.usedatabrain.com/api/v2/datasource \
      --header 'Authorization: Bearer dbn_live_abc123...' \
      --header 'Content-Type: application/json' \
      --data '{
        "datasourceType": "opensearch",
        "credentials": {
          "name": "production-opensearch",
          "server_type": "self-managed",
          "server_url": "https://opensearch.example.com:9200",
          "username": "admin",
          "password": "updatedpassword"
        }
      }'
    ```

    ```bash cURL - Elasticsearch Example theme={"dark"}
    curl --request PUT \
      --url https://api.usedatabrain.com/api/v2/datasource \
      --header 'Authorization: Bearer dbn_live_abc123...' \
      --header 'Content-Type: application/json' \
      --data '{
        "datasourceType": "elasticsearch",
        "credentials": {
          "name": "production-elasticsearch",
          "server_type": "elastic-cloud",
          "cloud_id": "my-deployment:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyQ...",
          "username": "elastic",
          "password": "updatedpassword"
        }
      }'
    ```

    ```bash cURL - Trino Example theme={"dark"}
    curl --request PUT \
      --url https://api.usedatabrain.com/api/v2/datasource \
      --header 'Authorization: Bearer dbn_live_abc123...' \
      --header 'Content-Type: application/json' \
      --data '{
        "datasourceType": "trino",
        "credentials": {
          "name": "production-trino",
          "host": "trino.example.com",
          "port": 8080,
          "catalog": "hive",
          "schema": "analytics",
          "username": "trinouser",
          "password": "updatedpassword"
        }
      }'
    ```

    ```bash cURL - Update With Tenancy Settings theme={"dark"}
    curl --request PUT \
      --url https://api.usedatabrain.com/api/v2/datasource \
      --header 'Authorization: Bearer dbn_live_abc123...' \
      --header 'Content-Type: application/json' \
      --data '{
        "datasourceType": "postgres",
        "credentials": {
          "name": "production-postgres",
          "host": "db.example.com",
          "port": 5432,
          "username": "dbuser",
          "password": "newpassword",
          "database": "analytics",
          "schema": "public"
        },
        "tenancySettings": {
          "tenancyLevel": "TABLE",
          "clientColumnType": "STRING",
          "schemaName": "public",
          "tableName": "clients",
          "tableClientNameColumn": "client_name",
          "tablePrimaryKeyColumn": "client_id"
        }
      }'
    ```

    ```javascript Node.js theme={"dark"}
    const response = await fetch('https://api.usedatabrain.com/api/v2/datasource', {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer dbn_live_abc123...',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        datasourceType: 'postgres',
        credentials: {
          name: 'production-postgres',
          host: 'new-db.example.com',
          port: 5432,
          username: 'dbuser',
          password: 'newpassword',
          database: 'analytics',
          schema: 'public'
        }
      })
    });

    const data = await response.json();
    if (data.error) {
      console.error('Error:', data.error);
    } else {
      console.log('Datasource updated:', data.name);
    }
    ```

    ```python Python theme={"dark"}
    import requests

    response = requests.put(
        'https://api.usedatabrain.com/api/v2/datasource',
        headers={
            'Authorization': 'Bearer dbn_live_abc123...',
            'Content-Type': 'application/json'
        },
        json={
            'datasourceType': 'postgres',
            'credentials': {
                'name': 'production-postgres',
                'host': 'new-db.example.com',
                'port': 5432,
                'username': 'dbuser',
                'password': 'newpassword',
                'database': 'analytics',
                'schema': 'public'
            }
        }
    )

    data = response.json()
    if data.get('error'):
        print('Error:', data['error'])
    else:
        print('Datasource updated:', data['name'])
    ```
  </RequestExample>

  <ResponseExample>
    ```json 200 - Success theme={"dark"}
    {
      "name": "production-postgres"
    }
    ```

    ```json 400 - Bad Request theme={"dark"}
    {
      "error": {
        "code": "INVALID_REQUEST_BODY",
        "message": "Invalid credentials for postgres: \"host\" is required",
        "status": 400
      }
    }
    ```

    ```json 400 - Datasource Not Found theme={"dark"}
    {
      "error": {
        "code": "DATASOURCE_NAME_ERROR",
        "message": "Invalid datasource name",
        "status": 400
      }
    }
    ```

    ```json 400 - Connection Test Failed theme={"dark"}
    {
      "error": {
        "code": "CREDENTIAL_TEST_FAILED",
        "message": "Failed to connect to datasource",
        "status": 400
      }
    }
    ```

    ```json 401 - Unauthorized theme={"dark"}
    {
      "error": {
        "code": "AUTHENTICATION_ERROR",
        "message": "AUTHENTICATION_ERROR",
        "status": 401
      }
    }
    ```

    ```json 500 - Tenancy Settings Failed theme={"dark"}
    {
      "error": {
        "code": "TENANCY_SETTINGS_UPDATE_FAILED",
        "message": "Failed to update tenancy settings",
        "status": 500
      }
    }
    ```
  </ResponseExample>
</Panel>

## Error Codes

| Error Code                       | HTTP Status | Description                                             |
| -------------------------------- | ----------- | ------------------------------------------------------- |
| `INVALID_REQUEST_BODY`           | 400         | Missing required fields or invalid credential structure |
| `DATASOURCE_NAME_ERROR`          | 400         | Datasource not found                                    |
| `CREDENTIAL_TEST_FAILED`         | 400         | Connection test failed                                  |
| `AUTHENTICATION_ERROR`           | 401         | Invalid or missing service token                        |
| `SCHEMA_CACHE_FAILED`            | 500         | Schema caching failed                                   |
| `DATASOURCE_NOT_FOUND`           | 404         | The specified datasource does not exist                 |
| `TENANCY_SETTINGS_CREATE_FAILED` | 500         | Failed to create tenancy settings for the datasource    |
| `TENANCY_SETTINGS_UPDATE_FAILED` | 500         | Failed to update existing tenancy settings              |
| `INTERNAL_SERVER_ERROR`          | 500         | Server error occurred                                   |

## Next Steps

<CardGroup cols={2}>
  <Card title="List Datasources" icon="list" href="/developer-docs/helpers/api-reference/list-datasources">
    View all datasources to verify the update
  </Card>

  <Card title="Sync Datasource" icon="sync" href="/developer-docs/helpers/api-reference/sync-datasource">
    Manually sync the datasource schema if needed
  </Card>

  <Card title="Create Datasource" icon="plus" href="/developer-docs/helpers/api-reference/create-datasource">
    Create a new datasource instead of updating
  </Card>

  <Card title="Delete Datasource" icon="trash" href="/developer-docs/helpers/api-reference/delete-datasource">
    Remove a datasource you no longer need
  </Card>
</CardGroup>
