tencent cloud

CreateDBInstance
最后更新时间:2025-12-03 10:42:14
CreateDBInstance
最后更新时间: 2025-12-03 10:42:14

1. API Description

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

This API is used to create a yearly/monthly subscription TencentDB for MongoDB instance. The DescribeSpecInfo API can be called to query and obtain the supported sales specifications.

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: 2019-07-25.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
NodeNum Yes Integer - Specifies the number of primary and secondary nodes for each replica set during replica set instance creation. Call the DescribeSpecInfo API to obtain the maximum and minimum number of nodes supported for each replica set.
- Specifies the number of primary and secondary nodes for each shard during sharded cluster instance creation. Call the DescribeSpecInfo API to obtain the maximum and minimum number of nodes supported for each shard.
Memory Yes Integer Instance memory size. Unit: GB. Call the DescribeSpecInfo API to obtain specific saleable memory specifications.
Volume Yes Integer Instance disk size. Unit: GB. Call the DescribeSpecInfo API to obtain the maximum and minimum disk sizes corresponding to each CPU specification.
MongoVersion Yes String Refers to version information. The DescribeSpecInfo API can be called to obtain detailed information about the supported versions.
- MONGO_40_WT: version of the MongoDB 4.0 WiredTiger storage engine.
- MONGO_42_WT: version of the MongoDB 4.2 WiredTiger storage engine.
- MONGO_44_WT: version of the MongoDB 4.4 WiredTiger storage engine.
- MONGO_50_WT: version of the MongoDB 5.0 WiredTiger storage engine.
- MONGO_60_WT: version of the MongoDB 6.0 WiredTiger storage engine.
- MONGO_70_WT: version of the MongoDB 7.0 WiredTiger storage engine.
GoodsNum Yes Integer Number of instances. The minimum value is 1, and the maximum value is 30.
Zone Yes String AZ information. Format: ap-guangzhou-2.
- Call the DescribeSpecInfo API to obtain the specific information.
- This parameter indicates the primary AZ. If multi-AZ deployment is adopted, the value of Zone should be one of the values of AvailabilityZoneList.
Period Yes Integer Specifies the purchase duration during the instance purchase, in months. Valid values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, and 36.
MachineCode Yes String Product specification type.
- HIO10G: general high-I/O 10GE type.
- HCD: cloud disk type.
ClusterType Yes String Instance architecture type.
- REPLSET: replica set.
- SHARD: sharded cluster.
ReplicateSetNum Yes Integer - Specifies the number of replica sets during replica set instance creation. This parameter can only be set to 1.
- Specifies the number of shards during sharded cluster instance creation. Call the DescribeSpecInfo API to query the range of shard quantity. The parameters MinReplicateSetNum and MaxReplicateSetNum in the returned data structure SpecItems correspond to the minimum value and maximum value, respectively.
ProjectId No Integer Project ID. - The default project is used if this parameter is not specified.
- The project ID can be obtained on the project management page in the TencentDB for MongoDB console.
VpcId No String VPC ID.
- Only VPC configuration is supported, and a VPC in the same region as the instance should be selected. Log in to the VPC console to obtain the available VPC ID.
- After successful instance creation, VPCs can be changed. For detailed operations, see Changing the Network.
SubnetId No String Subnet ID of the VPC.
- A subnet should be specified within the selected VPC. Log in to the VPC console to obtain the available subnet ID.
- After successful instance creation, VPCs and subnets can be changed. For detailed operations, see Changing the Network.
Password No String Instance password. The requirements are as follows:
- The number of characters should be in the range of [8, 32].
- Characters within the ranges [A,Z], [a,z], and [0,9] are allowed.
- Special characters that can be entered include exclamation marks (!), at signs (@), number signs (#), percent signs (%), carets (^), asterisks (*), brackets (()), and underscores (_).
- It cannot contain only the same letters or digits.
Tags.N No Array of TagInfo Instance tag information.
AutoRenewFlag No Integer Automatic renewal flag.
- 0: no automatic renewal.
- 1: automatic renewal.
AutoVoucher No Integer Whether to automatically select a voucher.
- 1: yes.
- 0: no. Default value: 0.
Clone No Integer Instance type.
- 1: formal instance.
- 3: read-only instance.
- 4: disaster recovery instance.
- 5: cloned instance. Note: For a cloned instance, RestoreTime is required.
Father No String Parent instance ID.
- This parameter is required when the value of the Clone parameter is set to 3 or 4, indicating a read-only or disaster recovery instance.
- Log in to the TencentDB for MongoDB console, and copy the parent instance ID from the instance list.
SecurityGroup.N No Array of String Security group ID. Log in to the security group console to obtain the ID of the security group in the same region as the database instance.
RestoreTime No String Rollback time of the cloned instance. It is required when the Clone value is 5 or 6. - This parameter is required for cloned instances. Format: 2021-08-13 16:30:00. - Rollback time range: Only data within the last 7 days can be rolled back.
InstanceName No String Instance name. Only Chinese characters, letters, digits, underscores (_), and delimiters (-) are supported, with a length of 128 characters. When database instances are purchased in batches, the automatic ascending feature is supported through the custom naming pattern string and numeric suffix to set instance names efficiently.
- Basic mode: prefix + automatic ascending number (starting from 1 by default). Only a custom instance name prefix is required for lnstanceName. For example, it can be set to cmgo. If the purchase quantity is set to 5, after purchase, the instances will be sequentially named cmgo1, cmgo2, cmgo3, cmgo4, and cmgo5, respectively.
- Custom starting number mode: prefix + {R:x} (x is the custom starting number). Prefix{R:x} is required for InstanceName. For example, cmgo{R:3}. If the purchase quantity is set to 5, the instance names will be sequentially named cmgo3, cmgo4, cmgo5, cmgo6, and cmgo7.
- Composite pattern string: prefix 1{R:x} + prefix 2{R:y}+ ⋯ + fixed suffix, where x and y are the starting numbers of each prefix. A composite pattern string is required for instanceName. For example, cmgo{R:10}_node{R:12}_db. If the batch purchase quantity is set to 5, the instances will be sequentially named cmgo10_node12_db, cmgo11_node13_db, cmgo12_node14_db, cmgo13_node15_db, and cmgo14_node16_db.
AvailabilityZoneList.N No Array of String Specifies the list of AZs during multi-AZ deployment of TencentDB for MongoDB instances.
- For instances in multi-AZ deployment mode, the Zone parameter specifies the primary AZ, and AvailabilityZoneList specifies all AZs, including the primary AZ. Format: [ap-guangzhou-2,ap-guangzhou-3,ap-guangzhou-4].
- The DescribeSpecInfo API can be called to obtain AZs planned for TencentDB for MongoDB instances in different regions, helping you specify valid AZs.
- Nodes in multi-AZ deployment mode can only be deployed in 3 different AZs. Deploying most nodes of a cluster in the same AZ is not supported. For example, a 3-node cluster does not support deploying 2 nodes in the same AZ.
MongosCpu No Integer Number of Mongos node CPU cores. Valid values: 1, 2, 4, 8, and 16. This parameter is required during sharded cluster instance purchase.
MongosMemory No Integer Mongos node memory size.
- This parameter is required during sharded cluster instance purchase.
- Unit: GB. 1-core 2GB, 2-core 4GB, 4-core 8GB, 8-core 16GB, and 16-core 32GB are supported.
MongosNodeNum No Integer Number of Mongos nodes. This parameter is required during sharded cluster instance purchase.
- For instances in single-AZ deployment mode, the value range is [3,32].
- For instances in multi-AZ deployment mode, the value range is [6,32].
ReadonlyNodeNum No Integer Number of read-only nodes. Value ranges: [0,5].
ReadonlyNodeAvailabilityZoneList.N No Array of String Array of AZs of read-only nodes. This parameter is required for instances in multi-AZ deployment mode when ReadonlyNodeNum is not set to 0.
HiddenZone No String AZ of the hidden node. This parameter is required for instances in multi-AZ deployment mode.
ParamTemplateId No String Parameter template ID.
- A parameter template is a collection of predefined parameter values that can be used to quickly configure new MongoDB instances. Proper use of parameter templates can significantly enhance the deployment efficiency and operational performance of the database.
- The DescribeDBInstanceParamTpl API can be called to obtain the parameter template ID. Select the parameter template ID corresponding to the instance version and architecture.

3. Output Parameters

Parameter Name Type Description
DealId String Order ID.
InstanceIds Array of String List of IDs of created instances.
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 Creating a TencentDB for MongoDB Instance in Monthly Subscription Mode

This example applies only to version 4.0. For other versions, see the version description for the input parameters.

Input Example

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

{
    "VpcId": "vpc-0akbol5v",
    "GoodsNum": 1,
    "Zone": "ap-guangzhou-2",
    "ProjectId": 0,
    "MachineCode": "HIO10G",
    "Period": 1,
    "ClusterType": "REPLSET",
    "Volume": 250,
    "MongoVersion": "MONGO_40_WT",
    "NodeNum": 3,
    "ReplicateSetNum": 1,
    "Memory": 4,
    "SubnetId": "subnet-fyrtjbqw",
    "Password": "pwd123456"
}

Output Example

{
    "Response": {
        "RequestId": "d88095e5-50e8-4245-a0cf-993a536f9b20",
        "DealId": "7142863",
        "InstanceIds": [
            "cmgo-po5f899l"
        ]
    }
}

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
InvalidParameter Parameter error
InvalidParameter.PermissionDenied The current sub-account has no permission to perform this operation.
InvalidParameterValue.InvalidTradeOperation Billing error. Corresponding purchase/renewal/configuration change operations are not allowed for the current instance.
InvalidParameterValue.MachineTypeError Incorrect model.
InvalidParameterValue.MongoVersionError The instance version is incorrect.
InvalidParameterValue.NotFoundInstance The instance was not found.
InvalidParameterValue.PasswordRuleFailed The password is non-compliant.
InvalidParameterValue.ProjectNotFound The project does not exist.
InvalidParameterValue.RegionError Invalid region
InvalidParameterValue.ReplicaSetNumError Incorrect number of replica sets (shards).
InvalidParameterValue.SecondaryNumError Incorrect number of secondary nodes.
InvalidParameterValue.SpecNotOnSale Incorrect purchasable specification.
InvalidParameterValue.TagNotFound The specified tag was not found.
InvalidParameterValue.VpcIdOrSubnetIdNotFound The VPC (subnet) was not found.
InvalidParameterValue.ZoneClosed Instances are not purchasable in this AZ.
InvalidParameterValue.ZoneError Invalid availability zone
UnsupportedOperation.VersionNotSupport The current version does not support the operation.
本页内容是否解决了您的问题?
您也可以 联系销售 提交工单 以寻求帮助。

文档反馈