tencent cloud

云数据库 MongoDB

动态与公告
产品动态
公告
新手指引
产品简介
产品概述
产品优势
应用场景
集群架构
产品规格
产品功能
地域和可用区
名词解释
购买指南
计费概述
产品定价
计费公式
欠费说明
备份空间计费
变配计费说明
快速入门
快速创建实例
连接 MongoDB 实例
读写数据库
操作指南
访问管理
管理实例
节点管理
版本升级
网络配置
系统监控
备份与回档
数据库审计
数据安全
SSL 认证
日志管理
数据库管理
多可用区部署
只读灾备
参数配置
回收站
任务管理
诊断优化
数据迁移指引
实践教程
索引优化解决读写性能瓶颈
分片集群 Mongos 负载不均解析及应对方案
分片集群使用注意事项
MongoDB 协议实例读写示例
基于 CVM 连接 MongoDB 进行数据导入导出的方法
3.6版本实例反复创建和删除同名数据库时报错怎么办
无法连接 MongoDB 解决方法
删减分片任务:进度确认与异常排查指南
性能调优
运维开发指南
开发规范
3.2版本分片集群命令支持情况
3.6版本命令支持情况
开发运维
故障处理
慢查询增多
连接数超限
API 文档
History
Introduction
API Category
Making API Requests
Instance APIs
Backup APIs
Account APIs
Other APIs
Task APIs
Introduction
Data Types
Error Codes
SDK 参考
Shell连接示例
PHP 连接示例
Node.js连接示例
Java 连接示例
Python连接示例
Python 读写示例
Go 连接示例
PHP 重连示例
产品性能
测试环境
测试方法
测试结果
常见问题
费用相关问题
功能特性问题
分片集群问题
实例相关问题
回档备份问题
连接相关问题
数据迁移问题
其他常见问题
相关协议
服务等级协议
Terms of Service
词汇表
联系我们

CreateDBInstanceHour

PDF
聚焦模式
字号
最后更新时间: 2026-01-13 21:48:12

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 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.
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. 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.
MachineCode Yes String Product specification type.
- HIO10G: general high-I/O 10GE type.
- HCD: cloud disk type.
GoodsNum Yes Integer Number of instances. The minimum value is 1, and the maximum value is 30.
Zone Yes String AZ information in the format of ap-guangzhou-2
- For more information, query through the DescribeSpecInfo API.
- If multi-AZ deployment is enabled, this parameter refers to the primary AZ and must be one of the values of AvailabilityZoneList.
ClusterType Yes String Instance architecture type
- REPLSET: Replica set
- SHARD: Sharded cluster
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.
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.
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. 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
- This parameter is required for a cloned instance in the format of 2021-08-13 16:30:00.
- Time range for rollback: You can roll back data in the last 7 days.
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 2 GB, 2-core 4 GB, 4-core 8 GB, 8-core 16 GB, and 16-core 32 GB 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 where the hidden node resides, which is required in cross-AZ instance deployment.
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 the 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 (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.

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈