You can call the TransformDBInstancePayType operation to change the billing method of an ApsaraDB RDS instance.

Note
  • If you change the billing method of an instance from subscription to pay-as-you-go, a refund is provided. The refund amount is equal to the remaining subscription fee deducted by an amount of service fee. For more information, see Switch an ApsaraDB RDS for MySQL instance from subscription to pay-as-you-go.
  • If the balance of your Alibaba Cloud account is insufficient, you cannot change the billing method of an instance from pay-as-you-go to subscription.
  • This operation is not supported for instances whose specification change orders are not finished.
  • This operation is not supported for instances that are created in dedicated clusters.

ApsaraDB RDS supports the following two billing methods:

  • Subscription: A subscription instance is an instance for which you pay an upfront fee. For long-term use, the subscription billing method is more cost-effective than the pay-as-you-go billing method. You are offered lower prices for longer subscription periods.
  • Pay-as-you-go: A pay-as-you-go instance is an instance for which you are charged per hour based on your resource usage. The hourly fee is calculated based on the instance type that you specify in the purchase order and is deducted from the balance of your Alibaba Cloud account. For short-term use, we recommend that you select the pay-as-you-go billing method. If you no longer need a pay-as-you-go instance, you can release the instance to reduce costs.

For more information about the billing methods, see Pricing, billable items, and billing methods.

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 TransformDBInstancePayType

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

ClientToken String No ETnLKlblzczshOTUbOCzxxxxxxxxxx

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

DBInstanceId String Yes rm-uf6wjk5xxxxxx

The ID of the instance.

UsedTime Integer No 1

The subscription period of the instance. Valid values:

  • If you set the Period parameter to Year, the value of the UsedTime parameter ranges from 1 to 5.
  • If you set the Period parameter to Month, the value of the UsedTime parameter ranges from 1 to 9.
Note This parameter must be specified if you set the PayType parameter to Prepaid.
PayType String Yes Prepaid

The billing method of the instance. Valid values:

  • Postpaid: pay-as-you-go
  • Prepaid: subscription
Period String No Month

The subscription type of the instance. Valid values:

  • Year: yearly subscription
  • Month: monthly subscription
Note This parameter must be specified if you set the PayType parameter to Prepaid.
BusinessInfo String No None

The extended business information of the instance.

AutoRenew String No true

Specifies whether to enable auto-renewal for the instance. Valid values:

  • true: Auto-renewal is enabled.
  • false: Auto-renewal is disabled.
Note
  • This parameter is valid only when you change the billing method from pay-as-you-go to subscription.
  • All strings except true are considered false.

Response parameters

Parameter Type Example Description
DBInstanceId String rm-uf6wjk5xxxxxx

The ID of the instance.

RequestId String 5E6E09DE-5B12-4BFF-A55E-1C86EDE06D9A

The ID of the request.

ExpiredTime String 2020-04-20T10:00:00Z

The time at which the instance expires.

Note If you change the billing method from subscription to pay-as-you-go, this parameter is not returned.
OrderId Long 205157600280623

The ID of the order.

ChargeType String Prepaid

The billing method of the instance.

Examples

Sample requests

http(s)://rds.aliyuncs.com/?Action=TransformDBInstancePayType
&DBInstanceId=rm-uf6wjk5xxxxxx
&PayType=Prepaid
&UsedTime=3
&Period=Month
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<TransformDBInstancePayTypeResponse>
<ChargeType>Prepaid</ChargeType>
<DBInstanceId>rm-uf6wjk5xxxxxx</DBInstanceId>
<ExpiredTime>2020-04-20T10:00:00Z</ExpiredTime>
<OrderId>205157600280623</OrderId>
<RequestId>5E6E09DE-5B12-4BFF-A55E-1C86EDE06D9A</RequestId>
</TransformDBInstancePayTypeResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "ChargeType" : "Prepaid",
  "DBInstanceId" : "rm-uf6wjk5xxxxxx",
  "ExpiredTime" : "2020-04-20T10:00:00Z",
  "OrderId" : 205157600280623,
  "RequestId" : "5E6E09DE-5B12-4BFF-A55E-1C86EDE06D9A"
}

Error codes

HTTP status code Error code Error message Description
400 InvalidDBInstanceName.NotFound The specified DB instance name does not exist. The error message returned because the name of the instance cannot be found.
400 InvalidInstanceUseType.NotSupport Specified instanceUseType does not support in RDS. The error message returned because the instance is a child instance.
400 InvalidOrderCharge.NotSupport The specified order charge does not support in RDS. The error message returned because the value of the PayType parameter is invalid. The valid values of this parameter are Prepaid and Postpaid. The value Prepaid indicates the subscription billing method, and the value Postpaid indicates the pay-as-you-go billing method.
400 InvalidOrderTask.NotSupport The Current InstanceId exist Order Task in RDS. The error message returned because the instance has orders that are not finished. Try again later.
400 IncorrectDBInstanceType Current DB instance type does not support this operation. The error message returned because this operation is not supported when the instance is in the current state.
400 IncompleteAccountInfo Your information is incomplete. Complete your information before the operation. The error message returned because your account information is incomplete. Log on to the Account Center console and specify all account information items that are labeled with an asterisk (*).
400 IncompleteTaxInfo Your tax information is incomplete. Complete your information before the operation. The error message returned because your tax information is incomplete. Specify all tax information that is required.
400 InvalidPaymentMethod.Incomplete No payment method is specified for your account. We recommend that you add a payment method. The error message returned because no valid payment method is provided within your Alibaba Cloud account. Add a valid payment method and try again.
400 InvalidPaymentMethod.Missing Your payment method is incomplete. We recommend that you add a payment method. The error message returned because no valid payment method is provided within the current Alibaba Cloud account. Add a valid payment method and try again.
400 InsuffcientBalanceOrBankAccount Add a payment method or add funds to the prepayment balance. Get started by creating an instance. The error message returned because no valid payment method is provided within the current Alibaba Cloud account. Add a valid payment method or funds and try again.
400 InvalidPaymentMethod.Missing No payment method is specified for your account. We recommend that you add a payment method. The error message returned because no valid payment method is provided within your Alibaba Cloud account. Add a valid payment method and try again.
400 OrderTaskAlreadyExists Order task already exists. The error message returned because the order already exists.
400 InvalidOldInstanceType.NotSupport Specified oldInstanceType does not support in RDS. The error message returned because this operation is not supported for the database engine version of the instance.
400 OperationDenied.TimeLimit The interval between the two conversion operations must be greater than 15 minutes. The error message returned because the time interval between this operation and the previous operation is less than or equal to 15 minutes.
400 InvalidResource.Format The specified parameter Resource is not valid. The error message returned because the specified resource is invalid.
400 InvalidPayType.Format The specified parameter PayType is not valid. The error message returned because the value of the PayType parameter is invalid.
400 InvalidUsedTime.Format The specified parameter UsedTime is not valid. The error message returned because the UsedTime parameter is not specified.
403 OperationDenied.LockMode The operation is not permitted when the instance locked. The error message returned because the instance is locked. The balance of your Alibaba Cloud account may be insufficient. Add funds to the account to unlock the instance and try again.

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