Modifies the billing method for up to 16 disks that are attached to an instance.

Description

After you change the billing method, automatic payment is enabled by default. Make sure that your account has sufficient balance. Otherwise, your order becomes invalid and you have to cancel this order. If your account balance is insufficient, you can set the AutoPay parameter to false to generate a normal order. Then, you can log on to the ECS console to pay for the order.

When you call this operation, note that:

  • Changing the billing method from Subscription to Pay-As-You-Go is suitable for Subscription-based disks that are attached to a Subscription-based instance.
  • Changing the billing method from Pay-As-You-Go to Subscription is suitable for Pay-As-You-Go data disks that are attached to a Subscription-based or Pay-As-You-Go instance.
  • The instances cannot be in the Stopped state due to overdue payments.
  • You can modify the billing method for each disk three times at most. The refunding of price difference cannot exceed three times.
  • The price difference is refunded to the payment account you used. Price difference of coupon purchases are not refunded.
  • The billing method of a disk cannot be modified for at least five minutes after it has been modified.

Debugging

You can use API Explorer to perform debugging. API Explorer allows you to perform various operations to simplify API usage. For example, you can retrieve APIs, call APIs, and dynamically generate SDK example code.

Request parameters

Name Type Required Example Description
DiskIds String Yes [“d-xxxxxxxxx”, “d-yyyyyyyyy”, … “d-zzzzzzzzz”]

The list of disk IDs. The parameter is a JSON-formatted array. You can specify a maximum of 16 IDs. Separate multiple IDs with commas (,).

InstanceId String Yes i-instanceid1

The ID of the instance that the disk is attached to.

RegionId String Yes cn-hangzhou

The ID of the region to which the instance belongs. You can call DescribeRegions to view the latest regions of Alibaba Cloud.

Action String No ModifyDiskChargeType

The operation that you want to perform. Set the value to ModifyDiskChargeType.

AutoPay Boolean No true

Indicates whether automatic payment is enabled. Valid values:

  • true (default): Automatic payment is enabled. Make sure that your account has sufficient balance. Otherwise, your order becomes invalid and you have to cancel this order.
  • false: No payment is made and only an order is generated. If your account has insufficient funds, the system generates a normal unpaid order. You can log on to the ECS console to complete the payment.
ClientToken String No 123e4567-e89b-12d3-a456-426655440000

A client token. It is used to ensure the idempotency of requests. The value of this parameter is generated by the client and is unique among different requests. It can contain a maximum of 64 ASCII characters. For more information, see How to ensure idempotency.

DiskChargeType String No PostPaid

The billing method for disks. Valid values:

  • PrePaid (default): changes the billing method from Pay-As-You-Go to Subscription.
  • PostPaid: changes the billing method from Subscription to Pay-As-You-Go.

Response parameters

Name Type Example Description
OrderId String 1111111111111111111111110

The ID of a generated order.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=ModifyDiskChargeType
&DiskIds=["d-diskid1"]
&InstanceId=i-instanceid1
&RegionId=cn-hangzhou 
&AutoPay=true 
&ClientToken=123e4567-e89b-12d3-a456-426655440000
&DiskChargeType=PostPaid
&<Common request parameters>

Successful response examples

XML format

<ModifyDiskChargeType>
  <RequestId>04F0F334-1335-436C-A1D7-6C044FE73368</RequestId> 
  <Order>1011111111111111</Order>
</ModifyDiskChargeType>

JSON format

{
	"RequestId":"04F0F334-1335-436C-A1D7-6C044FE73368",
	"Order":1011111111111111
}

Error codes

HTTP status code Error code Error message Description
404 InvalidRegionId.NotFound The RegionId provided does not exist. The error message returned when the specified region ID does not exist.
400 InvalidInstanceType.ValueNotSupported The specified InstanceType is not supported. The error message returned when you are not authorized to use the specified instance type.
400 ChargeTypeViolation The operation is not permitted due to charge type of the instance. The error message returned when the billing method of the instance does not support this operation.
400 InvalidInstance.PurchaseNotFound The specified Instance has no purchase. The error message returned when the specified instance cannot be purchased.
400 InvalidInstance.UnPaidOrder The specified Instance has unpaid order. The error message returned when the specified instance has outstanding orders. You must pay for the orders before proceeding.
400 Account.Arrearage Your account has been in arrears. The error message returned when your account balance is insufficient. You must top up your account before proceeding.
400 InvalidInstanceType.ValueUnauthorized The specified InstanceType is not Supported. The error message returned when the specified instance type does not support this operation.
400 OrderCreationFailed Create Order failed, please check your parameters and try it later. The error message returned when the order failed to be created. Check your parameters and try again later.
400 Throttling Request was denied due to request throttling, please try again after 5 minutes. The error message returned when the request is denied due to throttling.
404 PaymentMethodNotFound No billing method has been registered on the account. The error message returned when you have not selected a billing method.
404 InvalidRamRole.NotFound The specified parameter RAMRoleName does not exist. The error message returned when the specified RAM role name does not exist.
400 InstanceDowngrade.QuotaExceed Quota of instance downgrade is exceed. The error message returned when the instance has been downgraded the allowed times.
404 InvalidDiskIds.NotFound Some of the specified data disks do not exist. The error message returned when the specified data disk does not exist.
404 InvalidDiskIds.NotPortable The specified DiskId is not portable. The error message returned when the specified disk does not support the Portable attribute.
403 InvalidAccountStatus.NotEnoughBalance Your account does not have enough balance. The error message returned when your account balance is insufficient. You must top up your account before proceeding.
403 InvalidInstanceChargeType.NotFound The chargeType of the instance does not support this operation. The error message returned when the billing method of the instance does not support this operation.

View error codes