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"
}
}'
{
"name": "production-postgres"
}
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"
}
}'
{
"name": "production-postgres"
}
Update the credentials and configuration of an existing datasource. The API validates and tests the new credentials before applying changes.
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"
}
}'
{
"name": "production-postgres"
}
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"
}
}'
{
"name": "production-postgres"
}
name field in the credentials. After updating, the schema will be automatically re-cached.PUT https://api.usedatabrain.com/api/v2/datasource
PUT <SELF_HOSTED_URL>/api/v2/datasource
Authorization: Bearer dbn_live_abc123...
application/json for all requests.Content-Type: application/json
name field matching the existing datasource name.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.Show Finding datasource names
Show Tenancy configuration details
TABLE or DATABASE.TABLE: Client mapping is stored in a specific table (most common)DATABASE: Each client has a separate database instancetenancySettings is provided. If tenancySettings is omitted, this field is not needed.NUMBER or STRING.Required when tenancyLevel is TABLE.tenancyLevel is TABLE.tenancyLevel is TABLE.tenancyLevel is TABLE.tenancyLevel is TABLE.datasourceType.Snowflake
your-account.snowflakecomputing.com)"username/password" or "Key-pair authentication""username/password")"Key-pair authentication")Postgres / Redshift
"enable" or "disable" (optional)"enable")"enable")"enable")"enable")CockroachDB
"enable" or "disable" (optional)"enable")"enable")"enable")"enable")BigQuery
"US", "EU")MySQL / MongoDB / ClickHouse
MSSQL
server not host for MSSQL.user not username for MSSQL.SingleStore
Databricks
Elasticsearch
"elastic-cloud", "open-cloud", or "self-managed""elastic-cloud" or "open-cloud")"self-managed")disableAuth is true)disableAuth is true)false). Only valid when server_type is "self-managed".OpenSearch
"elastic-cloud", "open-cloud", or "self-managed""elastic-cloud" or "open-cloud")"self-managed")disableAuth is true)disableAuth is true)false). Only valid when server_type is "self-managed".Firebolt
Athena
Trino
"enable" or "disable" (optional)"enable")"enable")"enable")"enable")CSV
AWS S3
"us-east-1")"File" or "Folder" (optional)| 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 |