tencent cloud

APIs

CreateDBInstanceHour

Download
フォーカスモード
フォントサイズ
最終更新日: 2026-05-19 16:03:10

1. API Description

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

This API is used to create a pay-as-you-go TencentDB for MongoDB instance.

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: CreateDBInstanceHour.
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.
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.

ReplicateSetNum Yes Integer
  • Specifies the number of replica sets during replica set instance creation. This parameter can only be 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.
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.
MongoVersion Yes String

Refers to version information. For supported versions, use the interface DescribeSpecInfo to query.

  • MONGO_40_WT: MongoDB 4.0 WiredTiger engine version.
  • MONGO_42_WT: MongoDB 4.2 WiredTiger engine version.
  • MONGO_44_WT: MongoDB 4.4 WiredTiger engine version.
  • MONGO_50_WT: MongoDB 5.0 WiredTiger engine version.
  • MONGO_60_WT: MongoDB 6.0 WiredTiger engine version.
  • MONGO_70_WT: MongoDB 7.0 WiredTiger engine version.
  • MONGO_80_WT: MongoDB 8.0 WiredTiger engine version.
MachineCode Yes String

Recommended product specification types:

  • GE.LD.T1: Local disk (Common I).
  • GE.CD.T1: Cloud disk (Common I).

Product allowlist specification types:

  • HIO10G: Local disk (High IO 10G).
  • HCD: Cloud disk (Cloud disk edition).

Note: Allowlist specification types are under allowlist control. If needed, submit a ticket to apply.

GoodsNum Yes Integer

Number of instances. The minimum value is 1, and the maximum value is 30.

Zone Yes String

AZ information. The input format must be ap-guangzhou-2.

  • For details, use the interface DescribeSpecInfo to obtain them.
  • This parameter is the primary AZ. If multi-AZ deployment is used, Zone must be one of AvailabilityZoneList.
ClusterType Yes String

Instance architecture type.

  • REPLSET (replica set)
  • SHARD (sharded cluster)
VpcId No String

VPC ID.

  • Only supports configuration of private networks. A private network in the same region as the instance must be selected. Log in to the VPC console to obtain a usable VPC ID.
  • After successful instance creation, VPC replacement is allowed. For detailed operations, see Changing the Network.
SubnetId No String

Subnet ID of the VPC.

  • You must specify a subnet within the selected private network. Log in to the VPC console to obtain the subnet ID.
  • After the instance is successfully created, replacement of the private network and subnet is allowed. For detailed operations, please refer to Network Change.
Password No String

Instance password. The requirements are as follows:

  • Character count is [8,32].
  • Enter characters within [A,Z], [a,z], [0,9].
  • Special characters include: exclamation mark "!", at "@", pound sign "#", percent sign "%", caret "^", asterisk "*", brackets "()", underscore "_".
  • Cannot set a single letter or number.
ProjectId No Integer

Project ID.

Tags.N No Array of TagInfo

Instance tag information.

Clone No Integer

Instance type.

  • 1: Formal instance.
  • 3: Read-only instance.
  • 4: Disaster recovery instance.
  • 5: Clone instance. Note: RestoreTime is a required item when you clone an instance.
Father No String

Parent instance ID.

  • When the Clone parameter is 3 or 4, that is, the instance is read-only or a disaster recovery instance, this parameter must be configured.
  • Log in to the MongoDB console and copy the parent instance ID in 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 within the same region as the database instance.

RestoreTime No String

Rollback time of the cloned instance.

  • 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, English, digits, underscores (_), and hyphens (-) are supported, with a maximum length of 128 characters. When purchasing database instances in batches, you can efficiently set instance names by using custom pattern strings and automatically ascending numeric suffixes.

  • 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). InstanceName requires "prefix{R:x}". For example, cmgo{R:3}. If the purchase quantity is set to 5, the instance names will be cmgo3, cmgo4, cmgo5, cmgo6, and cmgo7.
  • Composite pattern string: prefix1{R:x} + prefix2{R:y} + ⋯ + fixed suffix, where x and y are the starting numbers for each prefix. InstanceName requires a composite pattern string. For example, cmgo{R:10}_node{R:12}_db. If the batch purchase quantity is set to 5, the instance names will be cmgo10_node12_db, cmgo11_node13_db, cmgo12_node14_db, cmgo13_node15_db, and cmgo14_node16_db.
AvailabilityZoneList.N No Array of String

For cloud database instances in multi-AZ deployment, specify the availability zone list.

  • 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].
  • Use the DescribeSpecInfo API to access cloud databases and obtain availability zone information planned for different regions, so that you can assign valid AZs.
  • Nodes in multi-AZ deployment can only be deployed in 3 different availability zones. Deploying most nodes of a cluster in the same availability zone is not supported. For example, a 3-node cluster does not support deploying 2 nodes in the same zone.
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. Valid values: 2 (for 1 core), 4 (for 2 cores), 8 (for 4 cores), 16 (for 8 cores), and 32 (for 16 cores).
MongosNodeNum No Integer

Number of Mongos nodes. This parameter is required during sharded cluster instance purchase.

  • For single-AZ deployment instances, the quantity range is [3,32].
  • For instances deployed across multiple availability zones, the quantity range is [6,32].
ReadonlyNodeNum No Integer

Number of read-only nodes. Value ranges from 0 to 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

Availability zone of the Hidden node. To deploy instances across availability zones, you must configure this parameter.

ParamTemplateId No String

Parameter template ID.

  • A parameter template is a collection of preset specific parameters applicable to quick configuration of new MongoDB instances. Proper use of parameter templates can effectively improve database deployment efficiency and operating performance.
  • The parameter template ID can be obtained through the DescribeDBInstanceParamTpl API. Please select the parameter template ID corresponding to your instance version and architecture.
CpuCore No Integer

Instance CPU core size. Unit: C. Call the DescribeSpecInfo API to obtain specific saleable CPU specifications.
Note: CPU size must be set for common I Instance Type.

3. Output Parameters

Parameter Name Type Description
DealId String

Order ID.

InstanceIds Array of String

List of instance created 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 Creating a TencentDB for MongoDB Instance (Pay-as-You-Go)

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: CreateDBInstanceHour
<Common request parameters>

{
    "Zone": "ap-guangzhou-3",
    "GoodsNum": 1,
    "Clone": 1,
    "Memory": 4,
    "ClusterType": "REPLSET",
    "Volume": 250,
    "NodeNum": 2,
    "ReplicateSetNum": 1,
    "MachineCode": "HIO10G",
    "MongoVersion": "MONGO_50_WT"
}

Output Example

{
    "Response": {
        "RequestId": "eaf9b19d-5ad4-4ca2-9fc4-a319aeb9181f",
        "DealId": "20190709160000003502416120946732",
        "InstanceIds": [
            "cmgo-m26c****"
        ]
    }
}

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.ClusterTypeError Invalid instance type.
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.PasswordRuleFailed The password is non-compliant.
InvalidParameterValue.PostPaidInstanceBeyondLimit The number of postpaid instances in a single region exceeds the limit.
InvalidParameterValue.ProjectNotFound The project does not exist.
InvalidParameterValue.RegionError Invalid region
InvalidParameterValue.ReplicaSetNumError Incorrect number of replica sets (shards).
InvalidParameterValue.SpecNotOnSale Incorrect purchasable specification.
InvalidParameterValue.StatusAbnormal The instance is in a status where operations are not allowed.
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.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック