Overview
Creates a data source. The request must include the X-Ob-Project-Id and X-Ob-Org-Id headers.
API details
Constraints
The caller must have an AccessKey to access the multi-cloud API. For information about how to obtain the AccessKey ID and AccessKey Secret, see Manage AccessKeys.
Request path
POST /api/v2/datasource/datasources
Request parameters
Header
Parameter |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| X-Ob-Project-Id | String | Yes | Project ID. | proj-xxxxxxxx |
| X-Ob-Org-Id | String | Yes | Organization ID. | org-xxxxxxxx |
Body
The request body must include all three groups of fields: common required fields, data source type-specific fields, and network access fields.
Common required fields
Parameter |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| name | String | Yes | Data source name, 1 to 128 characters long. It cannot start or end with whitespace or end with a period. | my-mysql |
| databaseType | String | Yes | Database type. Valid values: OB_MYSQL, OB_ORACLE, MYSQL, ORACLE, POSTGRESQL, TIDB, and KAFKA. |
MYSQL |
| instanceType | String | Yes | Instance product type, such as OB_CLOUD_CLUSTER, ALIYUN_RDS, AWS_RDS, or ALIYUN_SELF_MANAGED. |
ALIYUN_RDS |
| cloudProvider | String | Yes | Cloud provider. Valid values: ALIYUN, HUAWEI, AWS, GCP, and AZURE. |
ALIYUN |
| region | String | Yes | Region code, for example, zone-xxxx. |
zone-xxxx |
| networkAccessType | String | Yes | Network access method. Valid values: INNER, PRIVATE_LINK, PUBLIC_NETWORK, and PEERING. |
PUBLIC_NETWORK |
| description | String | No | Description. The frontend limits this field to 200 characters. | Tenant for business transactions |
| deployMode | String | No | Deployment mode. Valid value: SAAS. This field can be omitted. |
SAAS |
The following table lists the cloud providers supported for each database type:
Database type |
Supported cloud providers |
Description |
|---|---|---|
OB_MYSQL, OB_ORACLE |
ALIYUN, AWS, AZURE, GCP, HUAWEI |
HUAWEI does not support self-managed databases. |
MYSQL, ORACLE, TIDB |
ALIYUN, AWS, AZURE, GCP |
— |
POSTGRESQL, KAFKA |
ALIYUN, AWS, GCP |
— |
Database account fields
Parameter |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| username | String | Conditional | Database login username. Required for all data source types except KAFKA. | root |
| password | String | Conditional | Database login password in plaintext. Required for all data source types except KAFKA. | your-password |
Data source type-specific fields
Parameter |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| databaseName | String | Conditional | Database name. Required when databaseType=POSTGRESQL. |
app_db |
| serviceName | String | Conditional | Oracle service name. Required when databaseType=ORACLE. |
ORCLPDB1 |
| instanceId | String | Conditional | OceanBase instance ID. Required for a multi-tenant OceanBase instance or OB_CLOUD_OLAP. |
ob-cluster-example |
| tenantId | String | Conditional | OceanBase tenant ID. Required for a multi-tenant OceanBase instance or OB_CLOUD_TENANT. |
ob-tenant-example |
| instanceName | String | No | OceanBase instance name. | Business cluster |
| tenantName | String | No | OceanBase tenant name. | mysql_tenant |
| accessPoints | Array | Conditional | List of Kafka connection endpoints. Required when databaseType=KAFKA. |
See the Kafka examples. |
| kafkaId | Long | No | ID of the associated Kafka data source. Used only when databaseType=TIDB. |
10001 |
| kafkaTopic | String | Conditional | Kafka topic. Required when databaseType=TIDB and kafkaId is not null. |
tidb_cdc_topic |
| cdcDataFormat | String | Conditional | TiDB CDC data format. Valid values: tidbOpenProtocol and tidbBinlog. |
tidbOpenProtocol |
Additional fields for self-managed OceanBase databases
Parameter |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| sysTenantUsername | String | Conditional | System tenant username. Required for a self-managed OceanBase database accessed over a public network or PrivateLink. | sys_user@sys#ob_cluster |
| sysTenantPassword | String | Conditional | System tenant password in plaintext. Required for a self-managed OceanBase database accessed over a public network or PrivateLink. | your-sys-password |
| logProxyIp | String | Conditional | LogProxy address. Required for a self-managed OceanBase database accessed over a public network. | logproxy.example.com |
| logProxyPort | Integer | Conditional | LogProxy port. Required for a self-managed OceanBase database accessed over a public network. | 2983 |
| logProxyEndpointServiceName | String | Conditional | LogProxy private endpoint service name. Required for a self-managed OceanBase database accessed over PrivateLink. | REPLACE_WITH_LOGPROXY_ENDPOINT_SERVICE |
| logProxyEndpointServicePort | Integer | Conditional | LogProxy private endpoint service port. Required for a self-managed OceanBase database accessed over PrivateLink. | 2983 |
Network access fields (required depending on networkAccessType)
PEERING supports only ALIYUN, AWS, and GCP.
Parameter |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| host | String | Conditional | Connection address. Required for non-KAFKA data sources when the network access method is PUBLIC_NETWORK or PEERING. |
rm-xxx.mysql.rds.aliyuncs.com |
| port | Integer | Conditional | Connection port. Required for non-KAFKA data sources when the network access method is PUBLIC_NETWORK or PEERING. |
3306 |
| endpointServiceName | String | Conditional | Private endpoint service name. Required for non-KAFKA data sources when the network access method is PRIVATE_LINK. |
REPLACE_WITH_ENDPOINT_SERVICE |
| endpointServicePort | Integer | Conditional | Private endpoint service port. Required for non-KAFKA data sources when the network access method is PRIVATE_LINK. |
3306 |
| vpcId | String | Conditional | ID of the VPC that contains the target data source. Required for PEERING. |
vpc-target-example |
| vpcCidr | String | Conditional | CIDR block of the target VPC. Required for PEERING. |
10.20.0.0/16 |
| vpcPeeringId | String | Conditional | Peering connection ID. Required for PEERING. |
peering-example |
Response parameters
Field |
Type |
Description |
|---|---|---|
| success | Boolean | Whether the request succeeded. |
| httpStatus | String | HTTP status code. |
| data | DataSource | Created data source object, without plaintext passwords. |
Examples
The following examples show typical request bodies for different data source types. Each request body must include common required fields, data source type-specific fields, and network access fields. Save the JSON for the relevant example as request.json, replace the resource information, and send the request.
Request example
curl --digest -u '<your AK:SK>' \
--request POST \
--url 'https://api-cloud.oceanbase.com/api/v2/datasource/datasources' \
-H 'Content-Type: application/json' \
-H 'X-Ob-Project-Id: <project ID>' \
-H 'X-Ob-Org-Id: <organization ID>' \
--data @request.json
Save the JSON from the example you need as request.json, then run the preceding command.
Example 1: OceanBase Cloud MySQL (cluster mode, internal network)
{
"name": "ob_mysql_source",
"databaseType": "OB_MYSQL",
"instanceType": "OB_CLOUD_CLUSTER",
"cloudProvider": "ALIYUN",
"region": "zone-xxxx",
"networkAccessType": "INNER",
"instanceId": "ob-cluster-example",
"tenantId": "ob-tenant-mysql-example",
"instanceName": "Business cluster",
"tenantName": "mysql_tenant",
"username": "app_user",
"password": "REPLACE_WITH_DB_PASSWORD",
"description": "OceanBase MySQL tenant for business transactions"
}
Example 2: MySQL (Alibaba Cloud RDS, public network)
{
"name": "mysql_source",
"databaseType": "MYSQL",
"instanceType": "ALIYUN_RDS",
"cloudProvider": "ALIYUN",
"region": "zone-xxxx",
"networkAccessType": "PUBLIC_NETWORK",
"host": "mysql.example.com",
"port": 3306,
"username": "app_user",
"password": "REPLACE_WITH_DB_PASSWORD"
}
Example 3: PostgreSQL (Alibaba Cloud RDS, public network)
{
"name": "postgresql_source",
"databaseType": "POSTGRESQL",
"instanceType": "ALIYUN_RDS",
"cloudProvider": "ALIYUN",
"region": "zone-xxxx",
"networkAccessType": "PUBLIC_NETWORK",
"host": "postgresql.example.com",
"port": 5432,
"databaseName": "app_db",
"username": "app_user",
"password": "REPLACE_WITH_DB_PASSWORD"
}
Example 4: Oracle (AWS RDS, public network)
{
"name": "oracle_source",
"databaseType": "ORACLE",
"instanceType": "AWS_RDS",
"cloudProvider": "AWS",
"region": "ap-southeast-1",
"networkAccessType": "PUBLIC_NETWORK",
"host": "oracle.example.com",
"port": 1521,
"serviceName": "ORCLPDB1",
"username": "APP_USER",
"password": "REPLACE_WITH_DB_PASSWORD"
}
Example 5: TiDB (self-managed, public network, without an associated Kafka data source)
{
"name": "tidb_source",
"databaseType": "TIDB",
"instanceType": "ALIYUN_SELF_MANAGED",
"cloudProvider": "ALIYUN",
"region": "zone-xxxx",
"networkAccessType": "PUBLIC_NETWORK",
"host": "tidb.example.com",
"port": 4000,
"username": "app_user",
"password": "REPLACE_WITH_DB_PASSWORD"
}
Example 6: TiDB (self-managed, public network, with Kafka CDC)
{
"name": "tidb_cdc_source",
"databaseType": "TIDB",
"instanceType": "ALIYUN_SELF_MANAGED",
"cloudProvider": "ALIYUN",
"region": "zone-xxxx",
"networkAccessType": "PUBLIC_NETWORK",
"host": "tidb.example.com",
"port": 4000,
"username": "app_user",
"password": "REPLACE_WITH_DB_PASSWORD",
"kafkaId": 10001,
"kafkaTopic": "tidb_cdc_topic",
"cdcDataFormat": "tidbOpenProtocol"
}
Example 7: Kafka (self-managed on Alibaba Cloud, public network, SASL authentication)
{
"name": "kafka_source",
"databaseType": "KAFKA",
"instanceType": "ALIYUN_SELF_MANAGED",
"cloudProvider": "ALIYUN",
"region": "zone-xxxx",
"networkAccessType": "PUBLIC_NETWORK",
"accessPoints": [
{ "type": "PRIMARY", "address": "broker1.example.com", "port": 9092 },
{ "type": "PRIMARY", "address": "broker2.example.com", "port": 9092 }
],
"saslAuthPlugin": {
"enableSASL": true,
"saslMechanism": "SCRAM_SHA_256",
"username": "kafka_user",
"password": "REPLACE_WITH_KAFKA_PASSWORD"
},
"sslPlugin": { "enableSSL": false }
}
Example 8: Kafka (AWS MSK, PrivateLink)
{
"name": "kafka_private_source",
"databaseType": "KAFKA",
"instanceType": "AWS_SELF_MANAGED",
"cloudProvider": "AWS",
"region": "ap-southeast-1",
"networkAccessType": "PRIVATE_LINK",
"accessPoints": [
{
"type": "PRIVATE_LINK",
"endpointServiceName": "REPLACE_WITH_BROKER1_ENDPOINT_SERVICE",
"endpointServicePort": 9092,
"address": "broker1.internal.example.com",
"port": 9092
}
],
"saslAuthPlugin": { "enableSASL": false },
"sslPlugin": { "enableSSL": false }
}
Example 9: Kafka (self-managed, public network, SASL and SSL authentication)
{
"name": "kafka_sasl_ssl_source",
"databaseType": "KAFKA",
"instanceType": "ALIYUN_SELF_MANAGED",
"cloudProvider": "ALIYUN",
"region": "zone-xxxx",
"networkAccessType": "PUBLIC_NETWORK",
"accessPoints": [
{ "type": "PRIMARY", "address": "broker1.example.com", "port": 9093 },
{ "type": "PRIMARY", "address": "broker2.example.com", "port": 9093 }
],
"saslAuthPlugin": {
"enableSASL": true,
"saslMechanism": "SCRAM_SHA_256",
"username": "kafka_user",
"password": "REPLACE_WITH_KAFKA_PASSWORD"
},
"sslPlugin": {
"enableSSL": true,
"certFileId": "REPLACE_WITH_UPLOADED_CERT_FILE_ID",
"certFileName": "client-truststore.jks",
"certSslPassword": "REPLACE_WITH_TRUSTSTORE_PASSWORD",
"disableIdentificationAlgorithm": false
}
}
Example 10: OceanBase MySQL (self-managed, public network, SYS account and LogProxy)
{
"name": "ob_mysql_self_public_source",
"databaseType": "OB_MYSQL",
"instanceType": "ALIYUN_SELF_MANAGED",
"cloudProvider": "ALIYUN",
"region": "zone-xxxx",
"networkAccessType": "PUBLIC_NETWORK",
"host": "obproxy.example.com",
"port": 2883,
"username": "app_user@mysql_tenant#ob_cluster",
"password": "REPLACE_WITH_TENANT_PASSWORD",
"sysTenantUsername": "sys_user@sys#ob_cluster",
"sysTenantPassword": "REPLACE_WITH_SYS_PASSWORD",
"logProxyIp": "logproxy.example.com",
"logProxyPort": 2983
}
Example 11: OceanBase MySQL (self-managed, PrivateLink, LogProxy endpoint service)
{
"name": "ob_mysql_self_private_source",
"databaseType": "OB_MYSQL",
"instanceType": "ALIYUN_SELF_MANAGED",
"cloudProvider": "ALIYUN",
"region": "zone-xxxx",
"networkAccessType": "PRIVATE_LINK",
"endpointServiceName": "REPLACE_WITH_OB_ENDPOINT_SERVICE",
"endpointServicePort": 2883,
"username": "app_user@mysql_tenant#ob_cluster",
"password": "REPLACE_WITH_TENANT_PASSWORD",
"sysTenantUsername": "sys_user@sys#ob_cluster",
"sysTenantPassword": "REPLACE_WITH_SYS_PASSWORD",
"logProxyEndpointServiceName": "REPLACE_WITH_LOGPROXY_ENDPOINT_SERVICE",
"logProxyEndpointServicePort": 2983
}
Example 12: MySQL (PEERING connection)
{
"name": "mysql_peering_source",
"databaseType": "MYSQL",
"instanceType": "ALIYUN_SELF_MANAGED",
"cloudProvider": "ALIYUN",
"region": "zone-xxxx",
"networkAccessType": "PEERING",
"vpcId": "vpc-target-example",
"vpcCidr": "10.20.0.0/16",
"vpcPeeringId": "peering-example",
"host": "10.20.1.10",
"port": 3306,
"username": "app_user",
"password": "REPLACE_WITH_DB_PASSWORD"
}
Response example
{
"success": true,
"httpStatus": "OK",
"data": {
"id": 1001,
"uuid": "ds-uuid-xxx",
"name": "my-mysql",
"projectId": "proj-xxx",
"creatorUid": "123456",
"cloudProvider": "ALIYUN",
"region": "zone-xxxx",
"databaseType": "MYSQL",
"instanceType": "ALIYUN_RDS",
"networkAccessType": "PUBLIC_NETWORK",
"username": "root",
"host": "rm-xxx.mysql.rds.aliyuncs.com",
"port": 3306,
"visible": true,
"createTime": "2026-06-30T10:00:00+08:00",
"updateTime": "2026-06-30T10:00:00+08:00"
}
}
