Skip to main content
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"
}
PUT
https://api.usedatabrain.com
/
api
/
v2
/
datasource
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 an existing datasource’s credentials or configuration. The API validates the new credentials, tests the connection, and automatically refreshes the cached schema.
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.

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. Go to your Databrain dashboard and open Settings.
  2. Navigate to Settings.
  3. Find the Service Tokens section.
  4. Click the “Generate Token” button to generate a new service token if you don’t have one already.
  5. Use this token as the Bearer value in your Authorization header.

Headers

Authorization
string
required
Bearer token for API authentication. Use your API key from the data app.
Authorization: Bearer dbn_live_abc123...
Content-Type
string
required
Must be set to application/json for all requests.
Content-Type: application/json

Request Body

datasourceType
string
required
The type of datasource. Must match the existing datasource type. See Create Datasource for supported types.
credentials
object
required
Updated connection credentials for the datasource. Must include the name field matching the existing datasource name.
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.
credentials.name
string
required
The name of the existing datasource to update. Must match exactly as it was created.
tenancySettings
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.
tenancySettings.tenancyLevel
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.
tenancySettings.clientColumnType
string
Data type of the client identifier column. Must be either NUMBER or STRING.Required when tenancyLevel is TABLE.
tenancySettings.schemaName
string
Schema name where the client mapping table is located.Required when tenancyLevel is TABLE.
tenancySettings.tableName
string
Name of the table that contains client mapping information.Required when tenancyLevel is TABLE.
tenancySettings.tableClientNameColumn
string
Column name in the mapping table that stores the client identifier.Required when tenancyLevel is TABLE.
tenancySettings.tablePrimaryKeyColumn
string
Primary key column of the client mapping table.Required when tenancyLevel is TABLE.

Datasource-Specific Credentials

The credentials structure is the same as in Create Datasource. You must provide all required fields for the datasource type, even if only some values are changing.
When updating credentials, you must provide all required fields for the datasource type. Partial updates are not supported - provide the complete credential structure.

Response

name
string
The name of the updated datasource (same as credentials.name).
error
null
Error field, null when successful. Not included in successful responses.

Examples

Error Codes

Error CodeHTTP StatusDescription
INVALID_REQUEST_BODY400Missing required fields or invalid credential structure
DATASOURCE_NAME_ERROR400Datasource not found
CREDENTIAL_TEST_FAILED400Connection test failed
AUTHENTICATION_ERROR401Invalid or missing service token
SCHEMA_CACHE_FAILED500Schema caching failed
DATASOURCE_NOT_FOUND404The specified datasource does not exist
TENANCY_SETTINGS_CREATE_FAILED500Failed to create tenancy settings for the datasource
TENANCY_SETTINGS_UPDATE_FAILED500Failed to update existing tenancy settings
INTERNAL_SERVER_ERROR500Server error occurred

Next Steps