Changes the billing method of an ApsaraDB for RDS instance.

You can only change the billing method from pay-as-you-go to subscription.

  • Pay-as-you-go billing is ideal for short-term use. You can release your pay-as-you-go instance to reduce costs when you no longer need it.
  • Subscription billing is ideal for long-term use, because it is more cost-effective than pay-as-you-go billing. Longer subscription periods have larger discounts.

Before you call this operation, make sure that the following requirements are met:

  • The instance uses pay-as-you-go billing.
  • The instance is in the Running state.
  • The instance does not have due payments generated from previous billing changes.
  • The instance does not use a phased-out type. If the instance type has been phased out, you must upgrade the instance to an available type before you change its billing method. For more information, see Primary instance types and Change the specifications of an ApsaraDB RDS MySQL instance.

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 ModifyDBInstancePayType

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

DBInstanceId String Yes rm-uf6wjk5xxxxxx

The ID of the instance.

PayType String Yes Prepaid

The billing method of the instance. Set the value to Prepaid.

Period String Yes Year

The billing cycle of the instance. Valid values:

  • Year
  • Month
UsedTime Integer No 2

The duration of the instance.

  • If you set the Period parameter to Year, the value of the UsedTime parameter ranges from 1 to 3.
  • If you set the Period parameter to Month, the value of the UsedTime parameter ranges from 1 to 9.

Response parameters

Parameter Type Example Description
OrderId Long 205395023430728

The ID of the order.

Examples

Sample requests

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

Sample success responses

XML format

<ModifyDBInstancePayTypeResponse>
  <RequestId>E8C56392-C175-4731-A7F3-9BFA0C77D96F</RequestId>
  <OrderId>205395023430728</OrderId>
</ModifyDBInstancePayTypeResponse>

JSON format

{
    "RequestId": "E8C56392-C175-4731-A7F3-9BFA0C77D96F",
    "OrderId": 205395023430728
}

Error codes

HTTP status code Error code Error message Description
400 InvalidPaymentMethod.Missing No payment method is specified for your account. We recommend that you add a payment method. The error message returned because your account does not have a valid payment method. Add a valid payment method and try again.

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