tencent cloud

ModifyDBInstanceSpec
Last updated: 2025-12-03 10:41:57
ModifyDBInstanceSpec
Last updated: 2025-12-03 10:41:57

1. API Description

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

This API is used to adjust the TencentDB for MongoDB instance configuration. 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: ModifyDBInstanceSpec.
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.
InstanceId Yes String Instance ID. Log in to the TencentDB for MongoDB console, and copy the instance ID from the instance list.
Memory No Integer Memory size after instance configuration changes, in GB. If this parameter is left blank, the default value is the current memory size of the instance. For the currently supported memory specifications, see Product Specifications.
Note: Memory and disk configurations should be upgraded or downgraded simultaneously, meaning that Memory and Volume should be modified at the same time.
Volume No Integer Hard disk size after instance configuration changes, in GB. If this parameter is left blank, the default value is the current disk size of the instance. For the currently supported disk capacity, see Product Specifications.
- Memory and disk configurations should be upgraded or downgraded at the same time, meaning that Memory and Volume should be modified at the same time.
- During configuration downgrade, the disk capacity after changes should be greater than 1.2 times the used disk capacity.
NodeNum No Integer Number of Mongod nodes after instance changes (excluding read-only nodes).
- Number of replica set nodes. The value range of the number of nodes can be obtained through the response parameters MinNodeNum and MaxNodeNum of the DescribeSpecInfo API.
- Number of nodes per shard in a sharded cluster. The value range of the number of nodes can be obtained through the response parameters MinReplicateSetNodeNum and MaxReplicateSetNodeNum of the DescribeSpecInfo API.
Note: When the CPU and memory specifications of Mongod or Mongos nodes are changed, this parameter is not required, or enter the current number of Mongod or Mongos nodes (excluding read-only nodes).
ReplicateSetNum No Integer Number of shards after instance changes.
- The value range for the number of instance shards can be obtained through the response parameters MinReplicateSetNum and MaxReplicateSetNum of the DescribeSpecInfo API.
- The number of instance shards can only be increased and cannot be decreased.
InMaintenance No Integer Switch time for instance configuration modification.
- 0: Execute the configuration modification task immediately after the adjustment is completed. Default value: 0.
- 1: Execute the configuration modification task within the maintenance window.
Note: Adjusting the number of nodes and shards is unsupported within the maintenance window.
MongosMemory No String Memory size of the Mongos node after sharded cluster instance configuration changes, in GB. For the specifications supported by the instance, see Product Specifications.
AddNodeList.N No Array of AddNodeList List of nodes to be added, containing the node type and AZ information.
RemoveNodeList.N No Array of RemoveNodeList Deletes the node list.
Note: According to the consistency principle for nodes of each shard on a sharded cluster instance, specify the nodes on shard 0 for node deletion from the sharded cluster instance. For example, cmgo-9nl1czif_0-node-readonly0 will delete the first read-only node of each shard.

3. Output Parameters

Parameter Name Type Description
DealId String Order ID.
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 Adjusting the Configuration of a TencentDB for MongoDB Instance

This example shows you how to adjust the configuration of a TencentDB for MongoDB instance.

Input Example

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

{
    "InstanceId": "cmgo-p8vn****",
    "Volume": 250,
    "Memory": 4
}

Output Example

{
    "Response": {
        "RequestId": "d88095e5-50e8-4245-a0cf-993a536f9b20",
        "DealId": "7142863"
    }
}

Example2 Deleting Secondary Nodes from a TencentDB for MongoDB Instance

This example shows you how to delete 2 secondary nodes in total from Guangzhou Zone 2 and Zone 3. The final number of nodes changes to 3.

Input Example

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

{
    "InstanceId": "cmgo-abcdef",
    "Memory": 4,
    "Volume": 100,
    "OplogSize": 30,
    "NodeNum": 3,
    "ReplicateSetNum": 1,
    "InMaintenance": 1,
    "RemoveNodeList": [
        {
            "NodeName": "cmgo-3iecwbfx_0-node0",
            "Role": "SECONDARY",
            "Zone": "ap-guangzhou-2"
        },
        {
            "NodeName": "cmgo-3iecwbfx_0-node1",
            "Role": "SECONDARY",
            "Zone": "ap-guangzhou-3"
        }
    ]
}

Output Example

{
    "Response": {
        "DealId": "7142863",
        "RequestId": "d88095e5-50e8-4245-a0cf-993a536f9b20"
    }
}

Example3 Adding Secondary Nodes to a TencentDB for MongoDB Instance

This example shows you how to add 2 secondary nodes in total to Guangzhou Zone 2 and Zone 3. The final number of nodes changes to 5.

Input Example

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

{
    "InstanceId": "cmgo-p8vn****",
    "Memory": 4,
    "Volume": 100,
    "OplogSize": 30,
    "NodeNum": 5,
    "ReplicateSetNum": 1,
    "InMaintenance": 1,
    "AddNodeList": [
        {
            "Role": "SECONDARY",
            "Zone": "ap-guangzhou-2"
        },
        {
            "Role": "SECONDARY",
            "Zone": "ap-guangzhou-3"
        }
    ]
}

Output Example

{
    "Response": {
        "DealId": "7142863",
        "RequestId": "d88095e5-50e8-4245-a0cf-993a536f9b20"
    }
}

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.PermissionDenied The current sub-account has no permission to perform this operation.
InvalidParameter.ZoneClosed Instances are not purchasable in this AZ.
InvalidParameterValue.InvalidTradeOperation Billing error. Corresponding purchase/renewal/configuration change operations are not allowed for the current instance.
InvalidParameterValue.ModifyModeError Memory and disk must be upgraded or degraded simultaneously.
InvalidParameterValue.NotFoundInstance The instance was not found.
InvalidParameterValue.OplogSizeOutOfRange The OplogSize parameter is set incorrectly and should be between 10% and 90% of the disk capacity.
InvalidParameterValue.SetDiskLessThanUsed The disk size to be set cannot be less than 1.2 times the used disk capacity.
InvalidParameterValue.SpecNotOnSale Incorrect purchasable specification.
InvalidParameterValue.StatusAbnormal The instance is in a status where operations are not allowed.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback