Modifies the billing method of dedicated hosts.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes ModifyDedicatedHostsChargeType

The operation that you want to perform. For API requests that are initiated by using the HTTP or HTTPS methods, the Action parameter is required. Set the value to ModifyDedicatedHostsChargeType.

DedicatedHostIds String Yes ["dh-bp181e5064b5sotr****","dh-bp18064b5sotrr9c****"]

The ID of the dedicated host. The value can be a JSON array that consists of up to 100 instance IDs. Separate multiple instance IDs with commas (,).

RegionId String Yes cn-hangzhou

The region ID of the dedicated host. You can call the DescribeRegions operation to query the most recent region list.

Period Integer No 1

The duration for which you want to extend the subscription. Valid values:

  • 1, 2, 3, and 4 if PeriodUnit is set to Week
  • 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36, 48, and 60 if PeriodUnit is set to Month
PeriodUnit String No Month

The unit of the extension duration (Period). Valid values:

  • Week
  • Month

Default value: Month.

DryRun Boolean No false

Specifies whether to only validate the request. Valid values:

  • true: After receiving the request, the system only validates the request. The system does not modify the billing method of the specified dedicated hosts even if the request is valid. To validate the request, the system checks whether your AccessKey pair is valid, the RAM user (if used) is authorized, and required parameters are specified. If the request is invalid, the error code that indicates the reason is returned. If the request is valid, the DryRunOperation error code is returned.
  • false: The system validates the request after receiving the request. If the request is valid, the 2XX HTTP status code is returned and the billing method of the specified dedicated hosts is modified.

Default value: false.

AutoPay Boolean No false

Specifies whether automatic payment is enabled. Valid values:

  • true: Automatic payment is enabled. Make sure that your account has sufficient balance. Otherwise, your order becomes invalid and is canceled.
  • False: Automatic payment is disabled. An order is generated.

Default value: true.

Note If your account balance is insufficient, you can set the AutoPay parameter to false to generate an unpaid order. Then, you can log on to the ECS console to complete the payment for the order.
DedicatedHostChargeType String No PrePaid

The new billing method. Valid values:

  • PrePaid: changes the billing method from pay-as-you-go to subscription.
  • PostPaid: changes the billing method from subscription to pay-as-you-go.

Default value: PrePaid.

ClientToken String No e4567-e89b-12d3-a456-426655440000

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value. However, you must make sure that it is unique among different requests. The value of ClientToken can contain only ASCII characters. It cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

DetailFee Boolean No false

Specifies whether to return the billing details of the order when the billing method is changed from subscription to pay-as-you-go.

Default value: false.

Response parameters

Parameter Type Example Description
FeeOfInstances Array

The billing details of the order.

FeeOfInstance
Currency String CNY

The unit of currency for the bill.

Fee String 0

The total fees.

InstanceId String dh-bp181e5064b5sotrr****

The ID of the dedicated host.

OrderId String 20413515388****

The ID of the order.

RequestId String B61C08E5-403A-46A2-96C1-F7B1216DB10C

The ID of the request.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=ModifyDedicatedHostsChargeType
&RegionId=cn-hangzhou
&InstanceIds=["dh-bp181e5064b5sotr****","dh-bpe5064b5sotrr9c****"]
&Period=1
&PeriodUnit=Month
&AutoPay=false
&IncludeAllDisks=true
&ClientToken=e4567-e89b-12d3-a456-426655440000
&<Common request parameters>

Sample success responses

XML format

<ModifyDedicatedHostsChargeTypeResponse>
      <RequestId>B61C08E5-403A-46A2-96C1-F7B1216DB10C</RequestId>
      <OrderId>20413515388****</OrderId>
      <FeeOfInstances>
            <FeeOfInstance>
                  <Fee>0</Fee>
                  <InstanceId>dh-bp181e5064b5sotr****</InstanceId>
                  <Currency>CNY</Currency>
            </FeeOfInstance>
            <FeeOfInstance>
                  <Fee>0</Fee>
                  <InstanceId>dh-bp181e5064b5sotr****</InstanceId>
                  <Currency>CNY</Currency>
            </FeeOfInstance>
      </FeeOfInstances>
</ModifyDedicatedHostsChargeTypeResponse>

JSON format

{
    "RequestId":"B61C08E5-403A-46A2-96C1-F7B1216DB10C",
    "OrderId":"20413515388****",
    "FeeOfInstances":
    {
        "FeeOfInstance":[
            {
                "Fee":"0",
                "InstanceId":"dh-bp181e5064b5sotr****",
                "Currency":"CNY"
            },
            {
                "Fee":"0",
                "InstanceId":"dh-bp181e5064b5sotr****",
                "Currency":"CNY"
            }
        ]
    }
}

Error codes

HttpCode Error code Error message Description
400 InvalidParameter.InstanceIds The specified InstanceIds are invalid. The error message returned because the specified InstanceId parameter is invalid.
400 InvalidParameter %s The error message returned because the specified parameter is invalid.
400 InvalidStatus.ValueNotSupported %s The error message returned because the operation is not supported while the resource is in the current state.
400 InvalidInstanceChargeType.ValueNotSupported %s The error message returned because the billing method is not supported. Change the billing method and try again.
400 ExpiredInstance The specified instance has expired. The error message returned because the specified instance has expired.
400 InstancesIdQuotaExceed The maximum number of Instances is exceeded. The error message returned because the maximum number of instances has been reached.
400 InvalidClientToken.ValueNotSupported The ClientToken provided is invalid. The error message returned because the specified ClientToken parameter is invalid.
403 InvalidInstanceType.ValueNotSupported The specified InstanceType does not exist or beyond the permitted range. The error message returned because the specified instance type does not exist or you are not authorized to manage the instance type.
403 InstanceType.Offline %s The error message returned because the instance type is retired or in short supply.
500 InternalError The request processing has failed due to some unknown error, exception or failure. The error message returned because an internal error has occurred. Try again later. If the error persists, submit a ticket.
400 ReleaseTimeHaveBeenSet The specified instance has been set released time. The error message returned because an automatic release time has been set for the specified instance.
403 InvalidAccountStatus.NotEnoughBalance Your account does not have enough balance. The error message returned because your account balance is insufficient. Add funds to your account before you proceed.
403 Account.Arrearage Your account has an outstanding payment. The error message returned because your account has overdue payments.
400 Throttling Request was denied due to request throttling, please try again after 5 minutes. The error message returned because your request is denied due to throttling. Try again after 5 minutes.
403 InvalidParameter.NotMatch %s The error message returned because a specified parameter is invalid. Check whether parameter conflicts exist.
403 InvalidAction %s The error message returned because this operation is invalid.
400 Throttling %s The error message returned because the request is denied due to throttling.
400 QuotaExceed.AfterpayInstance The maximum number of Pay-As-You-Go instances is exceeded: %s The error message returned because the pay-as-you-go resources of the specified instance type are insufficient. Reduce the number of instances to be created.
400 InvalidPeriod.UnitMismatch The specified Period must be correlated with the PeriodUnit. The error message returned because the duration for which the subscription is extended is not associated with PeriodUnit.
400 InvalidImageType.NotSupported %s The error message returned because the specified image type is invalid. Check whether the region supports this image type.
400 InvalidPeriod.ExceededDedicatedHost Instance expired date can't exceed dedicated host expired date. The error message returned because the expiration date of the instance is later than that of the dedicated host.
403 QuotaExceed.PostPaidDisk Living postPaid disks quota exceeded. The error message returned because the number of pay-as-you-go disks has reached the upper limit.
403 ImageNotSupportInstanceType The specified instanceType is not supported by instance with marketplace image. The error message returned because the specified Alibaba Cloud Marketplace image does not support the instance type.
403 InvalidInstanceType.PhasedOut This instanceType is no longer offered. The error message returned because the specified instance type is no longer available.
400 InvalidSystemDiskCategory.ValueNotSupported %s The error message returned because the operation is not applicable to the specified system disk type.
500 InternalError The request processing has failed due to some unknown error. The error message returned because an internal error has occurred. Try again later. If the error persists, submit a ticket.
403 RealNameAuthenticationError Your account has not passed the real-name authentication yet. The error message returned because you have not completed the real-name verification. Complete the real-name authentication and try again.

For a list of error codes, visit the API Error Center.