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.

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
INTERNAL_SERVER_ERROR500Server error occurred

Next Steps