All Products
Search
Document Center

Elastic Compute Service:ModifyInstanceChargeType

Last Updated:Feb 04, 2024

Changes the billing methods of instances between pay-as-you-go and subscription, or changes the billing method of all data disks that are attached to an instance from pay-as-you-go to subscription.

Operation description

Before you call this operation, make sure that you are familiar with the billing methods and pricing of Elastic Compute Service (ECS). For more information, see the Elastic Compute Service product page.

Take note of the following items:

  • The instances must be in the Running (Running) or Stopped (Stopped) state, and you cannot have overdue payments for them.

  • After you change the billing method, outstanding payments are automatically completed. Make sure that your account balance is sufficient. Otherwise, your order becomes invalid and is canceled. If your account balance is insufficient, you can set AutoPay to false to generate an unpaid order. Then, you can log on to the ECS console to pay for the order.

  • Change the billing method from subscription to pay-as-you-go:

    • Your ECS usage determines whether the billing method of an instance can be changed from subscription to pay-as-you-go.
    • After you change the billing method of an instance from subscription to pay-as-you-go, the new billing method remains in effect for the remaining lifecycle of the instance. The price difference is refunded to the payment account that you used. Vouchers that have been redeemed are not refundable.
    • Refund rule: You have a quota for the total refund amount each month, and unused balance of this quota is not carried forward into the next month. After you use up the refund quota of the current month, you can change the billing method only in the next month. The refund amount incurred when you change the billing method is calculated based on the following formula: Number of vCPUs × (Number of remaining days × 24 ± Number of remaining or elapsed hours).
  • Change the billing method from pay-as-you-go to subscription:

    • You can change the billing method of all data disks that are attached to an instance from pay-as-you-go to subscription.
    • This operation cannot be called for a pay-as-you-go instance that has an automatic release time set.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
InstanceIdsstringYes

The instance IDs. The value can be a JSON array that consists of up to 20 instance IDs. Separate the instance IDs with commas (,).

["i-bp67acfmxazb4p****","i-bp67acfmxazb4d****"]
RegionIdstringYes

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

cn-hangzhou
PeriodintegerNo

The renewal duration of the subscription instance. If the instance is hosted on a dedicated host, the renewal duration of the instance cannot exceed the subscription duration of the dedicated host. Valid values:

Valid values when PeriodUnit is set to Month: 1, 2, 3, 4, 5, 6, 7, 8, 9, and 12.

1
PeriodUnitstringNo

The unit of the renewal duration specified by Period. Valid values:

Month

Default value: Month.

Month
IncludeDataDisksbooleanNo

Specifies whether to change the billing method of all data disks attached to the instance from pay-as-you-go to subscription.

Default value: false.

false
DryRunbooleanNo

Specifies whether to perform only a dry run. Valid Values:

  • true: performs only a dry run. The system checks whether your AccessKey pair is valid, whether Resource Access Management (RAM) users are granted permissions, and whether the required parameters are specified. If the request fails the dry run, an error message is returned. If the request passes the dry run, the DryRunOperation error code is returned.
  • false: performs a dry run and performs the actual request. If the request passes the dry run, a 2xx HTTP status code is returned and the operation is performed.

Default value: false.

false
AutoPaybooleanNo

Specifies whether to automatically complete the payment. Valid values:

  • true: The payment is automatically completed. Make sure that your account balance is sufficient. Otherwise, your order becomes invalid and is canceled.
  • false: An order is generated but no payment is made.

Default value: true.

Note If your account balance is insufficient, you can set AutoPay to false to generate an unpaid order. Then, you can log on to the ECS console to pay for the order.
false
InstanceChargeTypestringNo

The new billing method. Valid values:

  • PrePaid
  • PostPaid

Default value: PrePaid.

PrePaid
ClientTokenstringNo

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

123e4567-e89b-12d3-a456-426655440000
IsDetailFeebooleanNo

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

Default value: false.

false

Response parameters

ParameterTypeDescriptionExample
object
OrderIdstring

The order ID.

20413515388****
RequestIdstring

The request ID.

B61C08E5-403A-46A2-96C1-F7B1216DB10C
FeeOfInstancesobject []

Details about the charges for the order.

InstanceIdstring

The instance ID.

i-bp67acfmxazb4p****
Currencystring

The unit of currency for the bill.

Alibaba Cloud China site (aliyun.com): CNY.

Alibaba Cloud International site (alibabacloud.com): USD.

CNY
Feestring

The cost value.

0

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
400InvalidInstance.UnpaidOrder%s-
400ThrottlingRequest was denied due to request throttling, try again later.-
400InstanceHasProcessingConvertOrder%s-
400InvalidParameter.InstanceIdsThe specified InstanceIds are invalid.The specified instance is invalid.
400InvalidParameter%sThe specified parameter is invalid.
400InvalidStatus.ValueNotSupported%sThe resource is in a state that does not support the current operation.
400InvalidInstanceChargeType.ValueNotSupported%sThe specified InstanceChargeType parameter is invalid.
400InvalidSpotStrategyThe specified spotStrategy is not valid.The specified SpotStrategy parameter is invalid.
400ExpiredInstanceThe specified instance has expired.-
400InstancesIdQuotaExceedThe maximum number of Instances is exceeded.-
400InvalidClientToken.ValueNotSupportedThe ClientToken provided is invalid.The specified ClientToken parameter is invalid.
400InvalidInstance.UnpaidOrderThe specified instance has unpaid order.The specified instance has a purchase order not paid for.
400InvalidInternetChargeType.ValueNotSupported%sThe specified InternetChargeType parameter is invalid.
400ReleaseTimeHaveBeenSetThe specified instance has been set released time.An automatic release time has been set for the specified instance.
400ThrottlingRequest was denied due to request throttling, please try again after 5 minutes.-
400Throttling%sYour request is being throttled.
400QuotaExceed.AfterpayInstanceThe maximum number of Pay-As-You-Go instances is exceeded: %s.-
400InvalidParameter.Bandwidth%sThe specified bandwidth value is invalid.
400QuotaExceed.RufundVcpuThe maximum number of refund vcpu is exceeded: %s.-
400InvalidPeriod.UnitMismatchThe specified Period must be correlated with the PeriodUnit.The specified Period value must fall within the valid value range that is determined based on the PeriodUnit parameter.
400InvalidImageType.NotSupported%s-
400InvalidPeriod.ExceededDedicatedHostInstance expired date can't exceed dedicated host expired date.-
400InvalidMarketImageChargeType.NotSupportThe specified chargeType of marketImage is unsupported.The billing method of the Alibaba Cloud Marketplace image is not supported.
400InvalidSystemDiskCategory.ValueNotSupported%sThe specified system disk category is invalid.
400InvalidAccountStatus.PayAmountLimitExceededYour account is being restricted, due to no default payment method is set or you has not being authorized.-
400InvalidInstance.NotFoundSystemDiskThe specified instance has no system disk.The specified instance does not have a system disk. Make sure that the instance has a system disk. You can call the DescribeInstances operation to query the details of the instance.
400AccountForbidden.ProductCreationLimitedThe commodity must be officially operated by Aliyun and in pay-as-you-go billing method.-
400Invalid.PrivatePoolOptions.MatchCriteriaTarget mode does not support this operation.The operation is not supported while the PrivatePoolOptions.MatchCriteria parameter is set to Target.
400InvalidPeriodThe specified period is not valid.The specified period is invalid.
400DISK_IN_DEDICATED_BLOCK_STORAGE_CLUSTERThe disk in dedicated block storage cluster is not allowed to do this operation.-
400NoPermission.PriceThe operation requires price permission. Please either apply for permission from your main account, or set the parameter AutoPay as true.-
400NoPermission.RefundThe operation requires refund permission. Please apply for permission from your main account.-
403InvalidInstance.TempBandwidthUpgradeCannot switch to Pay-As-You-Go during the period of temporary bandwidth upgrade.You cannot change the billing method of the instance to pay-as-you-go during the temporary bandwidth upgrade period.
403InvalidInstanceType.ValueNotSupportedThe specified InstanceType does not exist or beyond the permitted range.The specified instance type does not exist or you are not authorized to manage instances of this instance type.
403InstanceType.Offline%sThe operation is not supported while the instance type is retired or while resources of the instance type are insufficient.
403InvalidAccountStatus.NotEnoughBalanceYour account does not have enough balance.Your account balance is insufficient. Add funds to your account and try again.
403Account.ArrearageYour account has an outstanding payment.Your account has overdue payments.
403InvalidParameter.NotMatch%sA specified parameter is invalid. Check whether parameter conflicts exist.
403InvalidAction%sThe operation is invalid.
403QuotaExceed.PostPaidDiskLiving postPaid disks quota exceeded.-
403ImageNotSupportInstanceTypeThe specified instanceType is not supported by instance with marketplace image.The specified Alibaba Cloud Marketplace image does not support the instance type.
403InvalidInstanceType.PhasedOutThis instanceType is no longer offered.The specified instance type is retired.
403RealNameAuthenticationErrorYour account has not passed the real-name authentication yet.You have not completed real-name verification. Complete real-name verification and try again.
403InvalidOperation.NotSupportInstance on dedicated host not support modify charge type.-
403QuotaExceed.ElasticQuotaNo additional quota is available for the specified ECS instance type.The maximum number of instances of the specified instance type in the region has been reached. Reduce the quantity of instances that you want to purchase or try another region or instance type. Alternatively, you can go to the ECS console or Quota Center to request a quota increase.
403QuotaExceed.ElasticQuotaThe number of the specified ECS instances has exceeded the quota of the specified instance type.The maximum number of instances of the specified instance type in the region has been reached. Reduce the quantity of instances that you want to purchase or try another region or instance type. Alternatively, you can go to the ECS console or Quota Center to request a quota increase.
403QuotaExceed.ElasticQuotaThe number of vCPUs assigned to the ECS instances has exceeded the quota in the zone.The maximum number of vCPUs for all instance types has been reached. You can go to the ECS console or Quota Center to request a quota increase.
403QuotaExceed.ElasticQuotaThe number of the specified ECS instances has exceeded the quota of the specified instance type, or the number of vCPUs assigned to the ECS instances has exceeded the quota in the zone.The maximum number of instances of the specified instance type in the region has been reached, or the maximum number of vCPUs for all instance types has been reached. You can go to the ECS console or Quota Center to request a quota increase.
403PeriodNotSupported.InstanceOnManagedPrivateSpaceThe instance on ManagedPrivateSpace is not supported to modify chargeType.-
403UnsupportedIspChargeType%s-
404InvalidInstanceId.NotFoundThe specified instanceId does not exist.The specified instance does not exist.
500InternalErrorThe request processing has failed due to some unknown error, exception or failure.An internal error has occurred. Try again later.
500InternalErrorThe request processing has failed due to some unknown error.An internal error has occurred. Try again later.
500InvalidInstanceType.ValueUnauthorizedThe specified InstanceType is not authorized.You are not authorized to use the specified instance type.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-07-21The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 500 change
    delete Error Codes: 400
    delete Error Codes: 403
    delete Error Codes: 404