Datasource APIs
Update a datasource
Replace the credentials or tenancy of a datasource you already connected.
Use it to change a password, a host, or the tenancy setup. Databrain tests the new credentials and reads the schema again.
curl --request PUT https://api.usedatabrain.com/api/v2/datasource \ --header "Authorization: Bearer $DATABRAIN_SERVICE_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "datasourceType": "postgres", "credentials": { "name": "Sales warehouse", "host": "db.example.com", "port": 5432, "username": "databrain_reader", "password": "<new password>", "database": "analytics", "schema": "public" } }'Auth
A service token. See Authentication.
Limits
10 requests in 5 minutes per organization, shared with create, sync and schema discovery.
ApiTokenAuthorizationBearer <token>A service token or a data app API token.
Body
The body is the same as Create a datasource, with the same credential fields per type. These rules are different:
credentials.namepicks the datasource to update. You cannot rename a datasource with this call.credentialsreplaces all stored credentials. Send every required field again, not only the ones that change.datasourceTypeis used only to check and test the credentials. It does not change the type of the datasource. Send the type it already has.tenancySettingsis optional. If you leave outtenancyLevel, the stored level stays.- Microsoft Fabric (
microsoft fabric) can be updated here, withserver,port,database,clientId, anduserandpasswordorclientSecret.
One of the types in the table below, in lower case.
snowflakepostgrespostgresqlcockroachdbredshiftmysqlmongodbclickhousesinglestorebigquerydatabrickselasticsearchopensearchmssqlawss3csvfireboltathenatrinomicrosoft fabricConnection fields for the type. credentials.name is the datasource name and must be unique in your organization.
52 fields in credentials
The datasource name, unique in your organization.
For postgres, mysql, mongodb, clickhouse, singlestore, snowflake, trino. See Credentials by type.
For postgres, mysql, mongodb, clickhouse, singlestore, mssql, trino. See Credentials by type.
For postgres, snowflake, trino. See Credentials by type.
For postgres, mysql, mongodb, clickhouse, singlestore, mssql, snowflake, elasticsearch, opensearch, trino. See Credentials by type.
For postgres, singlestore, mssql, snowflake, athena, firebolt. See Credentials by type.
For postgres, snowflake, firebolt, trino. See Credentials by type.
For postgres. See Credentials by type.
For postgres, mssql, trino. See Credentials by type.
For postgres, mssql, trino. See Credentials by type.
For postgres, mssql, trino. See Credentials by type.
For postgres, mssql, trino. See Credentials by type.
For mysql, mongodb, clickhouse, singlestore, mssql. See Credentials by type.
For mssql. See Credentials by type.
For mssql. See Credentials by type.
For mssql. See Credentials by type.
For snowflake. See Credentials by type.
For snowflake. See Credentials by type.
For snowflake, databricks. See Credentials by type.
For snowflake. See Credentials by type.
For snowflake. See Credentials by type.
For bigquery. See Credentials by type.
For bigquery. See Credentials by type.
For bigquery. See Credentials by type.
For bigquery. See Credentials by type.
For databricks. See Credentials by type.
For databricks. See Credentials by type.
For databricks. See Credentials by type.
For databricks. See Credentials by type.
For elasticsearch, opensearch. See Credentials by type.
elastic-cloudopen-cloudself-managedFor elasticsearch, opensearch. See Credentials by type.
For elasticsearch, opensearch. See Credentials by type.
For elasticsearch, opensearch. See Credentials by type.
For elasticsearch, opensearch. See Credentials by type.
For awss3. See Credentials by type.
For awss3. See Credentials by type.
For athena. See Credentials by type.
For firebolt. See Credentials by type.
For firebolt. See Credentials by type.
For firebolt. See Credentials by type.
For firebolt. See Credentials by type.
For trino. See Credentials by type.
databricks with OAuth service principal, and microsoft fabric: the app's client id.
microsoft fabric: the Microsoft Entra tenant id. Can be empty.
elasticsearch and opensearch, self-managed only: true connects without a username and password.
falseAWS region of the bucket. Required for awss3 and athena.
AWS access key id. Required for awss3 and athena.
AWS secret access key. Required for awss3 and athena.
athena only. Optional.
Tenancy for this datasource.
6 fields in tenancySettings
TABLE (a tenant column) or DATABASE (a schema or database per tenant)
Required for TABLE. Schema of the table that lists your tenants.
Required for TABLE. Table that lists your tenants.
Required for TABLE. Column with the tenant name.
Required for TABLE. Column with the tenant id, the value you send as clientId
Response
{ "name": "Sales warehouse"}The response can also have warnings, as on create.
Errors
| Status | error.code | Why |
|---|---|---|
| 400 | INVALID_REQUEST_BODY | A field is missing, unknown or wrong, or the host is refused |
| 400 | DATASOURCE_NAME_ERROR | No datasource has this credentials.name |
| 400 | DATASOURCE_NOT_FOUND | The datasource was removed while you updated it |
| 400 | CREDENTIAL_TEST_FAILED | Databrain could not connect with the new credentials. Nothing was changed |
| 400 | TENANCY_SETTINGS_CREATE_FAILED or TENANCY_SETTINGS_UPDATE_FAILED | The credentials were saved, the tenancy was not |
| 400 | SCHEMA_CACHE_FAILED | Credentials and tenancy were saved, the schema was not read. Run sync |
| 403 | DATABRICKS_OAUTH_NOT_ENABLED | Databricks OAuth is not on for your organization |
| 429 | Rate limit |
The steps are not one transaction. A later step can fail after an earlier one is saved.
For errors that every endpoint returns, see Authentication.
curl -X PUT 'https://api.usedatabrain.com/api/v2/datasource' \ -H 'Content-Type: application/json' \ -d '{ "datasourceType": "postgres", "credentials": { "name": "Sales warehouse", "host": "db.example.com", "port": 5432, "username": "databrain_reader", "password": "<new password>", "database": "analytics", "schema": "public" }}'{ "name": "Sales warehouse"}