tencent cloud

CreateDBInstance
Last updated:2026-03-19 18:22:14
CreateDBInstance
Last updated: 2026-03-19 18:22:14

1. API Description

Domain name for API request: cdb.intl.tencentcloudapi.com.

This API is used to create a cloud database instance with an annual/monthly subscription, including primary instance, disaster recovery instance, and read-only instance. You can create a cloud database instance by importing instance specification, MySQL version number, purchase period, and quantity information.

This API is an asynchronous API. You can also use the query instance list API (https://www.tencentcloud.com/document/api/236/15872?from_cn_redirect=1) to query the instance details. When the Status of the instance is 1 and TaskStatus is 0, it means the instance has been delivered successfully.

  1. First, please use the API for the query (https://www.tencentcloud.com/document/api/236/17229?from_cn_redirect=1) to obtain the purchasable specifications of cloud databases, then please use the API for the query (https://www.tencentcloud.com/document/api/236/18566?from_cn_redirect=1) to query database price.
  2. You can create up to 100 instances at a time, with a maximum instance duration of 36 months.
  3. Support creating MySQL 5.5, MySQL 5.6, MySQL 5.7, and MySQL 8.0 versions.
  4. Support creating primary instance, read-only instance, disaster recovery instance.
  5. When ParamTemplateId or AlarmPolicyList is specified in the input parameters, you need to upgrade the SDK to the latest version to support it.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: CreateDBInstance.
Version Yes String Common Params. The value used for this API: 2017-03-20.
Region Yes String Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-bangkok, ap-beijing, ap-chengdu, ap-chongqing, ap-guangzhou, ap-hongkong, ap-jakarta, ap-nanjing, ap-seoul, ap-shanghai, ap-shanghai-fsi, ap-shenzhen-fsi, ap-singapore, ap-tokyo, eu-frankfurt, na-ashburn, na-siliconvalley, sa-saopaulo.
Memory Yes Integer Instance memory size in MB. You can use the DescribeDBZoneConfig API to query the supported memory specifications.
Volume Yes Integer Instance disk size in GB. You can use the DescribeDBZoneConfig API to query the supported disk specifications.
Period Yes Integer Instance validity period in months. Valid values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, 36.
GoodsNum Yes Integer Number of instances. Value range: 1-100. Default value: 1.
Zone No String For AZ information, please use the Obtain the Purchasable Specifications of Cloud Databases API to obtain the availability zones that can be created.
Description: If you create a single-node, two-node, or three-node instance, this parameter is required. Specify an availability zone. If you do not specify an availability zone, the system will automatically select one (possibly not the availability zone you want to deploy in). If you create a cloud disk edition instance, leave this parameter empty. Configure the availability zone for the read-write node and read-only node with parameter ClusterTopology.
UniqVpcId No String VPC ID. Please use Querying VPC list.
Description: If a cloud disk edition instance is created, this item is required and must be a VPC type. If this item is left blank, the system will select the default VPC.
UniqSubnetId No String Subnet ID in the private network. If UniqVpcId is set up, UniqSubnetId is required. Please use query subnet list.
Description: If this item is left empty, the system will select the default subnet in the Default VPC.
ProjectId No Integer Project ID. If this parameter is left empty, the default project will be used. When you purchase read-only instances and disaster recovery instances, the project ID is the same as that of the source instance by default.
Port No Integer Custom port. Port range: 1024-65535.
Description: If this item is left blank, it defaults to 3306.
InstanceRole No String Instance type. Supported values include: master - indicates the primary instance, dr - indicates the disaster recovery instance, ro - indicates the read-only instance.
Description: Select instance type. The master type is selected by default if left empty.
MasterInstanceId No String Instance ID, required when purchasing a read-only instance or disaster recovery instance. This field represents the primary instance ID of the read-only instance or disaster recovery instance. Please use the Query Instance List API to query the cloud database instance ID.
EngineVersion No String MySQL version, including 5.5, 5.6, 5.7, and 8.0. Please use the obtain the purchasable specifications of cloud databases API to get the version of the instance created.
Description: When creating a non-cloud disk edition instance, specify the instance version as needed (recommend 5.7 or 8.0). If this parameter is left empty, the default value is 8.0. If creating a cloud disk edition instance, this parameter can only be set to 5.7 or 8.0.
Password No String The root account password, which can contain 8-64 characters and must contain at least two of the following types of characters: letters, digits, and symbols _+-&=!@#$%^*(). This parameter applies to source instances but not to read-only or disaster recovery instances.
ProtectMode No Integer Data replication mode. Valid values: 0 (async replication), 1 (semi-sync replication), 2 (strong sync replication). Default value: 0.
DeployMode No Integer Multi-AZ or single-AZ. Valid values: 0 (single-AZ), 1 (multi-AZ). Default value: 0.
SlaveZone No String AZ information of standby database 1.
Description: For two-node and three-node instances, specify this parameter. If not specified, it defaults to the value of Zone. For cloud disk edition instances, this parameter is optional. Configure the availability zone for read-write nodes and read-only nodes with parameter ClusterTopology. Single-node instances are single availability zone and no need to specify this parameter.
ParamList.N No Array of ParamInfo Parameter list. The parameter format is ParamList.0.Name=auto_increment&ParamList.0.Value=1. You can query the configurable parameters by default by referring to Querying the Default Configurable Parameter List.
Description: table name case sensitivity can be enabled or disabled with parameter lower_case_table_names. A parameter value of 0 means enabling, and 1 means disabling. If not set, the default value is 0. For MySQL 8.0 edition instances, you need to set the lower_case_table_names parameter when creating an instance to turn on or off table name case sensitivity. Once created, the parameter cannot be modified, meaning table name case sensitivity cannot be changed after creation. Other database versions support modifying the lower_case_table_names parameter after the instance is created. For the function invocation method to set table name case sensitivity when creating an instance, please see example 3 in this document.
BackupZone No String Information of replica AZ 2, which is left empty by default. Specify this parameter when purchasing a source instance in the one-source-two-replica architecture.
AutoRenewFlag No Integer Auto-renewal flag. Available values are: 0 - no auto-renewal; 1 - auto-renewal. Default is 0.
MasterRegion No String Region information of the source instance, which is required when purchasing a read-only or disaster recovery instance.
SecurityGroup.N No Array of String Security group parameter. You can use the DescribeProjectSecurityGroups API to query the security group details of a project.
RoGroup No RoGroup Read-only instance parameter. This parameter must be passed in when purchasing read-only instances.
InstanceName No String Instance name. For multiple instances purchased at one time, they will be distinguished by the name suffix number, such as instnaceName=db and goodsNum=3, and their instance names are db1, db2, and db3, respectively.
ResourceTags.N No Array of TagInfo Instance tag information
DeployGroupId No String Placement group ID
ClientToken No String A string unique in 48 hours, which is supplied by the client to ensure that the request is idempotent. Its maximum length is 64 ASCII characters. If this parameter is not specified, the idempotency of the request cannot be guaranteed.
DeviceType No String Instance isolation type. Supported values include "UNIVERSAL" - general-purpose instance, "EXCLUSIVE" - dedicated instance, "BASIC_V2" - ONTKE single-node instance, "CLOUD_NATIVE_CLUSTER" - standard type for cloud disk edition, "CLOUD_NATIVE_CLUSTER_EXCLUSIVE" - enhanced for cloud disk edition. Default to general-purpose instance if not specified.
Description: If a cloud disk edition instance is created, this parameter is required.
ParamTemplateId No Integer Parameter template id.
Remark: If you use a custom parameter template ID, you can input the custom parameter template ID. If you plan to use the default parameter template, inputting the parameter template ID is invalid, and you need to set ParamTemplateType.
AlarmPolicyList.N No Array of Integer Array of alarm policy IDs, which can be obtained through the OriginId field in the return value of the DescribeAlarmPolicy API of TCOP.
InstanceNodes No Integer The number of nodes of the instance. To purchase a read-only instance or a basic instance, set this parameter to 1 or leave it empty. To purchase a three-node instance, set this parameter to 3 or specify the BackupZone parameter. If the instance to be purchased is a source instance and both BackupZone and this parameter are left empty, the value 2 will be used, which indicates the source instance will have two nodes.
Cpu No Integer The number of the instance CPU cores. If this parameter is left empty, it will be subject to the Memory value.
AutoSyncFlag No Integer Whether to automatically start disaster recovery synchronization. This parameter takes effect only for disaster recovery instances. Valid values: 0 (no), 1 (yes). Default value: 0.
CageId No String Financial cage ID.
ParamTemplateType No String Default parameter template type. Supported values include: "HIGH_STABILITY" - high-stability template, "HIGH_PERFORMANCE" - high-performance template.
Remark: If you need to use the TencentDB for MySQL default parameter template, set up ParamTemplateType.
AlarmPolicyIdList.N No Array of String The array of alarm policy names, such as ["policy-uyoee9wg"]. If the AlarmPolicyList parameter is specified, this parameter is invalid.
DryRun No Boolean Whether to only pre-check this request. true: Send a check request without creating an instance. Check items include whether required parameters are filled, request format, and service limit. If the check failed, return the corresponding error code; if the check passed, return RequestId. false: Send a normal request and create the instance directly after passing the check.
Defaults to false.
EngineType No String Instance engine type. Valid values: InnoDB (default), RocksDB.
Vips.N No Array of String The list of IPs for sources instances. Only one IP address can be assigned to a single source instance. If all IPs are used up, the system will automatically assign IPs to the remaining source instances that do not have one.
DataProtectVolume No Integer Data protection space size of the cloud disk edition instance in GB. Setting range is 1 - 10.
ClusterTopology No ClusterTopology Cloud disk edition node topology configuration.
Description: If a cloud disk edition instance is purchased, this parameter is required. Set the RW and RO node topology for the cloud disk edition instance. The RO node scope is 1-5. Set at least 1 RO node.
DiskType No String Disk Type. This parameter can be specified for single-node (cloud disk edition) or cloud disk edition instance. CLOUD_SSD means SSD Cloud Block Storage, CLOUD_HSSD refers to enhanced SSD cloud disk, and CLOUD_PREMIUM indicates high-performance cloud block storage.
Description: The supported regions for the hard disk type of single-node (cloud disk edition) and cloud disk edition instances vary slightly. For the specific support situation, refer to Regions and Availability Zones.
DestroyProtect No String Turn on or off instance destruction protection. on - enabled, off - disabled.

3. Output Parameters

Parameter Name Type Description
DealIds Array of String Billing sub-order ID
InstanceIds Array of String List of instance IDs
RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Purchasing a Primary Instance

Input Example

POST / HTTP/1.1
Host: cdb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateDBInstance
<Common request parameters>

{
    "Memory": 1000,
    "Volume": 200,
    "Period": 12,
    "GoodsNum": 1,
    "Zone": "ap-guangzhou-ziyan3",
    "UniqVpcId": "vpc-grpykq9v",
    "UniqSubnetId": "subnet-aq06sf6a",
    "Port": 3306,
    "InstanceRole": "master",
    "Password": "190228bh",
    "ProtectMode": 1,
    "DeployMode": 0,
    "SlaveZone": "ap-guangzhou-ziyan3",
    "SecurityGroup": [
        "sg-9c3k3gtd"
    ],
    "InstanceName": "test_create-api2",
    "InstanceNodes": 2,
    "Cpu": 1,
    "EngineType": "InnoDB"
}

Output Example

{
    "Response": {
        "DealIds": [
            "20251117217021754844851"
        ],
        "InstanceIds": [
            "cdb-4wixd9pn"
        ],
        "RequestId": "bae642bd-305a-40fe-b64c-356dc809977b"
    }
}

Example2 Purchase a read-only instance

This example shows you how to purchase a source instance.

Input Example

POST / HTTP/1.1
Host: cdb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateDBInstance
<Common request parameters>

{
    "RoGroup": {
        "RoGroupMode": "allinone",
        "RoGroupName": "jersey",
        "RoMaxDelayTime": 5,
        "MinRoInGroup": 1,
        "RoOfflineDelay": 1
    },
    "GoodsNum": 1,
    "InstanceRole": "ro",
    "MasterInstanceId": "cdb-fn3f9xpx",
    "Period": 1,
    "Volume": 100,
    "Memory": 4000
}

Output Example

{
    "Response": {
        "RequestId": "6EF60BEC-0242-43AF-BB20-270359FB54A7",
        "DealIds": [
            "20171205110051"
        ],
        "InstanceIds": [
            "cdbro-hlpl4ik9"
        ]
    }
}

Example3 Set table name case sensitivity when creating an instance

This example shows you how to purchase a read-only instance.

Input Example

POST / HTTP/1.1
Host: cdb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateDBInstance
<Common request parameters>

{
    "Memory": 1000,
    "Volume": 25,
    "Period": 1,
    "GoodsNum": 1,
    "Zone": "ap-beijing-3",
    "UniqVpcId": "vpc-4pagx2lk",
    "UniqSubnetId": "subnet-a2eaqb1t",
    "InstanceRole": "master",
    "EngineVersion": "8.0",
    "ParamList": [
        {
            "Name": "lower_case_table_names",
            "Value": "0"
        }
    ],
    "DeviceType": "UNIVERSAL",
    "Cpu": 1,
    "EngineType": "InnoDB"
}

Output Example

{
    "Response": {
        "RequestId": "6166b535-64e8-4372-86fc-d6e25791f4fc",
        "InstanceIds": [
            "cdb-grq113rc"
        ],
        "DealIds": [
            "20250519054092411681521"
        ]
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
CdbError Backend or process error.
FailedOperation.StatusConflict Task status conflict.
InternalError.CauthError Authentication failed.
InternalError.CdbError System error.
InternalError.DatabaseAccessError Internal database error.
InternalError.DfwError Security group operation error.
InternalError.FtpError File transfer exception
InternalError.TradeError Transaction system error.
InternalError.UndefinedError Unknown error
InternalError.VpcError VPC or subnet error.
InvalidParameter Parameter error.
InvalidParameter.InstanceNotFound The instance does not exist.
OperationDenied Operation denied.
OperationDenied.ActionNotSupport Unsupported operation.
OperationDenied.OtherOderInProcess There are other orders being submitted. Please try again later.
OperationDenied.UserHasNoStrategy This account is not authorized to access the requested resource.
OperationDenied.WrongPassword Incorrect password or verification failed.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback