GetApiPrice

Updated at:

Queries pricing based on the target OpenAPI and its request parameters.

Operation description

Configure RAM permissions for pricing queries

When using a RAM user or RAM role to call GetApiPrice on the Alibaba Cloud China site, the administrator must grant the AliyunCloudControlAPIPricingAccess system policy to the identity that initiates the request. When calling the operation through the CLI, SDK, or MCP, if you use the credentials of a RAM user, grant the permissions to the user. If you use the temporary STS credentials obtained by assuming a role, grant the permissions to the assumed RAM role.

  1. Log on to the RAM console as an administrator, go to Identities > Users or Identities > Roles, find the calling identity, and click Grant Permission. If multiple RAM users share the permissions, you can also grant the permissions to their user group.

  2. Search for and select AliyunCloudControlAPIPricingAccess in System Policy, and then confirm the authorization.

  3. Retry the GetApiPrice operation by using the same identity. You can use the ECS cloud disk example in this topic to verify the configuration. When CreateDisk is the target API for pricing, if both success and price.success are true, the pricing is successfully retrieved. This example only queries the pricing and does not require permissions to create a cloud disk.

This policy also grants direct pricing query permissions for the pricing entry point and the following services. The current version includes 13 RAM actions. For the latest actions, refer to the policy content in the RAM console.

ServiceRAM action
Cloud Controlcloudcontrol:GetApiPrice
ECSecs:DescribePrice, ecs:DescribeInstanceModificationPrice, ecs:DescribeRenewalPrice
BSSbss:DescribePrice
RDSrds:DescribePrice, rds:DescribeRenewalPrice
ECIeci:DescribeContainerGroupPrice
ENSens:DescribePrice
ESAesa:DescribeRatePlanPrice
ECDecd:DescribePrice, ecd:DescribeMultiPrice
EMR Serverless StarRockssr:QueryPriceV1

Troubleshoot insufficient permissions

  • When you receive InvalidRamUser.NoPermission, check the Message and AccessDeniedDetail in the error response. Use AuthPrincipalType and AuthPrincipalDisplayName to verify the calling identity, and use AuthAction to verify the denied operation.

  • If NoPermissionType is ImplicitDeny and the denied operation is listed in the preceding table, make sure that the system policy is granted to the RAM user or role used for the current request. If it is ExplicitDeny, the administrator must first check the matched deny policy. A new allow policy cannot override an explicit deny.

  • If the denied operation is reading existing resources, such as reading a snapshot when querying pricing based on snapshot configurations, the administrator must grant the required read permissions based on the action and resource scope in the error message.

  • For further troubleshooting, keep the RequestId of the current request. If the pricing result contains price.upstreamRequestId, provide it to the administrator as well.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST /api/v1/price/quote HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The pricing request body. Submit it as a JSON object that contains the following fields:

  • popCode (required): the code of the service to which the target OpenAPI belongs, such as Ecs.

  • popVersion (required): the API version of the target OpenAPI, such as 2014-05-26.

  • apiName (required): the name of the target OpenAPI, such as CreateDisk. These three fields together identify the target API for pricing.

  • parameters (required, JSON object): the combination of request parameters for the target API, which are the business parameters used in the API call for which you want to estimate the cost. Specify the parameter names, types, and structures based on the documentation of the target API. Provide the configurations required for the current pricing, such as the region, resource specifications, capacity, quantity, subscription duration, and billing method. The specific parameters depend on the target API. Missing parameters required for pricing may result in a failure to retrieve the pricing.

  • language (optional): the language of the result message. Valid values: zh for Chinese and en for English. Default value: zh.

For example, if popCode is Ecs, popVersion is 2014-05-26, and apiName is CreateDisk, you must specify the parameters for the ECS CreateDisk operation in parameters. In the example on this page, RegionId, ZoneId, DiskCategory, and Size specify the region, zone, category, and capacity of the cloud disk to be priced. These business parameters are placed in the parameters object, while popCode, popVersion, apiName, and language are placed at the top level of the request body.

GetApiPrice queries the pricing based on these configurations and does not perform resource operations such as creating or modifying resources by calling the target API. The preceding example does not actually create a cloud disk.

{"popCode":"Ecs","popVersion":"2014-05-26","apiName":"CreateDisk","parameters":{"RegionId":"cn-hangzhou","ZoneId":"cn-hangzhou-i","DiskCategory":"cloud_essd","Size":40},"language":"zh"}

Response elements

Element

Type

Description

Example

object

The response to the pricing inquiry, which includes the result code, result message, pricing data, and request ID.

success

boolean

Indicates whether a valid cost conclusion is obtained. The value is true if the pricing is successful or no pricing inquiry is required. The value is false if pricing is not supported or fails. Before using the specific pricing amount, check price.success.

code

string

The pricing result code. Success indicates that the pricing inquiry is successful. PricingNotRequired indicates that the API call does not incur fees and no pricing inquiry is required. PricingNotSupported indicates that the API or the current parameter combination does not support pricing inquiries. For other values, refer to the message for the cause of failure.

Success

message

string

The pricing result message for the current inquiry. The message language is specified by the language parameter in the request body. The default language is Chinese.

Pricing inquiry successful

price

object

The pricing data. Check price.success first. If the value is true, you can read totalAmount, billingUnit, and usageCharges to display the pricing, and read priceSummary or components to view the cost details. This field is not returned when no pricing inquiry is required or pricing is not supported.

pricingMode

string

The pricing mode for the current inquiry. Valid values:

  • single: Standard single pricing. For details, see priceSummary.

  • composite: Combines multiple pricing quotes to calculate the cost.

  • delta: Calculates the cost difference before and after a configuration change. For the composite and delta modes, see components for details.

single

success

boolean

Indicates whether an available quote is successfully obtained. Use the pricing amount in the price object only when this value is true.

currency

string

The currency of the current quote. For example, CNY indicates Chinese Yuan.

CNY

calculatedAmount

number

The fixed cost amount obtained from composite or delta pricing. When a valid amount is returned, it is equal to totalAmount. The caller can uniformly read totalAmount as the final quote.

28.89

totalAmount

number

The final amount of fixed costs for the current inquiry. For the currency, see currency. For the billing unit, see billingUnit. Use this field only when price.success is true. Costs billed based on actual usage are not included in this field. For the unit price of usage-based costs, see usageCharges. For the cost composition, see chargeComposition. The caller should directly read this field as the final quote for the entire inquiry.

59.86

originalAmount

number

The pre-discount amount of fixed costs in the current standard single quote. For the currency, see currency. For the billing unit, see billingUnit. This field is returned when the pricing is successful and the original price information is provided. It is empty for composite pricing, delta pricing, or when the original price cannot be provided. For the pre-discount unit price of usage-based costs, see usageCharges[].originalPricePerUnit.

85.14

discountAmount

number

The discount amount for fixed costs, which is originalAmount minus totalAmount. This field is returned only when both fields have values. A value of 0 indicates that the two amounts are equal. An empty value does not indicate whether a discount exists. Discounts for usage-based costs are not included in this field.

25.28

billingUnit

string

The billing unit for fixed costs, which applies to totalAmount, originalAmount, and discountAmount. Examples include Hour and 1 Month. This field is empty when no billing unit is provided for the current quote. This field only describes the unit for fixed costs. For the unit of usage-based costs, see usageCharges[].unit.

1 Month

usageCharges

array<object>

The list of unit prices for usage-based costs in the entire inquiry, such as the price per GB of traffic or per CU. These costs are calculated separately based on actual usage and are not included in totalAmount. For standard single pricing, the content is the same as priceSummary.usageCharges. For multiple itemized quotes, it aggregates the unit prices from each quote in components. Avoid duplicate calculation for the same cost item in the outer layer and the details. This field is empty or not returned when there are no usage-based cost items.

object

moduleCode

string

The code of the cost item, such as TrafficOut or NatCu. It corresponds to the moduleCode in the pricing details modules.

NatCu

unit

string

The usage unit, such as GB, CU, or 10,000 requests. pricePerUnit indicates the price per unit of usage.

CU

pricePerUnit

number

The discounted price per unit of usage. For the usage unit, see unit. For the currency, see price.currency. You can estimate the cost by multiplying pricePerUnit by the estimated usage. This cost is not included in totalAmount.

0.1955

originalPricePerUnit

number

The pre-discount price per unit of usage. For the usage unit, see unit. For the currency, see price.currency. This field is empty when not provided. The difference between this field and pricePerUnit is the discount amount per unit of usage.

0.23

assumedQuantity

number

The estimated usage used for the cost estimation of this item. For the unit, see unit. When this field has a value, assumedQuantityCost is also returned. This quantity is used for estimation, and the actual cost depends on the actual usage.

1000

assumedQuantityCost

number

The cost calculated based on the estimated usage, which is pricePerUnit multiplied by assumedQuantity. This amount is for estimation only and is not included in totalAmount. The actual cost depends on the actual usage.

195.5

chargeComposition

string

The cost composition of the entire inquiry. Valid values:

  • recurring_only: Only fixed costs are included.

  • usage_only: Only usage-based costs are included. In this case, a totalAmount of 0 indicates no fixed costs rather than free of charge. The actual cost depends on the unit price in usageCharges and the actual usage.

  • mixed: Both fixed and usage-based costs are included. When the value is mixed, display the fixed costs and usage unit prices separately.

recurring_only

priceSummary

object

The pricing details of a standard single inquiry, including the amount, billing unit, cost composition, and usage unit price of the current quote. This field is not returned for composite or delta pricing. Refer to components instead. For the final quote of the entire inquiry, see totalAmount. You can also read the usage unit prices uniformly from the outer usageCharges.

currency

string

The currency of the current quote. For example, CNY indicates Chinese Yuan.

CNY

tradePrice

number

The discounted transaction amount of the current quote. This field is empty when not provided. For the final quote of the entire inquiry, read price.totalAmount.

176.0

originalPrice

number

The pre-discount amount of the current quote. When comparing discounts, use the discounted amount with the same currency, billing cycle, quantity, and cost scope. This field is empty when the original price information is not provided.

176.0

moduleSum

number

The total discounted amount of fixed costs for the current quote, which is not yet multiplied by quantity. It does not include usage-based costs.

59.86

effectiveModuleSum

number

The total discounted amount of fixed costs calculated based on quantity, which is moduleSum multiplied by quantity. It does not include usage-based costs. For the final quote, read price.totalAmount.

59.86

quantity

number

The quantity used to calculate the fixed costs of the current quote. The default value is 1. effectiveModuleSum equals moduleSum multiplied by quantity. When the quote amount already includes the required quantity, this field is 1, and the invoker does not need to multiply by the resource count.

1

pricingUnit

string

The billing unit, such as Hour, 1 Month, 12 Month, or GB·Month. It specifies the billing unit corresponding to moduleSum. This field is empty when the unit is not provided for the current quote.

1 Month

modules

array<object>

The detail list of each cost item in the current quote, such as instance, disk, and network costs.

object

moduleCode

string

The code of the cost item, such as InstanceType. You can use this code to map the cost items in modules and usageCharges.

InstanceType

costAfterDiscount

number

The discounted amount of this cost item. For recurring cost items, it indicates the periodic cost corresponding to the current quote. For usage-based cost items, if quantityUsedForQuote has a value, it indicates the total cost for that quantity. For the price per unit of usage, read the corresponding usageCharges[].pricePerUnit.

19.86

originalCost

number

The pre-discount amount of this cost item, which corresponds to costAfterDiscount.

45.14

invoiceDiscount

number

The discount amount of this cost item. This field is empty when not provided. An empty field does not indicate that no discount is applied.

25.28

unitPrice

number

The unit price of this cost item. This field is empty when not provided. An empty field does not indicate that the item is free of charge. For the unit price of usage-based costs, read usageCharges[].pricePerUnit.

0.5

billingMode

string

The billing method of this cost item. Valid values:

  • recurring: Billed by epoch and included in fixed costs.

  • usage: Billed based on actual usage and not included in fixed costs. For the unit price, see usageCharges[].pricePerUnit.

recurring

usageUnit

string

The usage unit when billed based on actual usage, such as GB or CU. It is consistent with the corresponding usageCharges[].unit. For the price per unit of usage, see usageCharges[].pricePerUnit.

CU

quantityUsedForQuote

number

The usage quantity corresponding to the quote of this cost item. When this field has a value, costAfterDiscount indicates the total cost for this quantity. This quantity is used to explain the quote amount, and the actual cost depends on the actual usage. For the price per unit of usage, see usageCharges[].pricePerUnit.

1000

usageCharges

array<object>

The list of unit prices for usage-based costs in the current quote. Each record specifies the cost item, usage unit, and unit price. The corresponding costs are not included in moduleSum or effectiveModuleSum. This field is empty or not returned when there are no usage-based cost items.

object

moduleCode

string

The code of the cost item, such as TrafficOut or NatCu. It corresponds to the moduleCode in the pricing details modules.

NatCu

unit

string

The usage unit, such as GB, CU, or 10,000 requests. pricePerUnit indicates the price per unit of usage.

CU

pricePerUnit

number

The discounted price per unit of usage. For the usage unit, see unit. For the currency, see price.currency. You can estimate the cost by multiplying pricePerUnit by the estimated usage. This cost is not included in totalAmount.

0.1955

originalPricePerUnit

number

The pre-discount price per unit of usage. For the usage unit, see unit. For the currency, see price.currency. This field is empty when not provided. The difference between this field and pricePerUnit is the discount amount per unit of usage.

0.23

assumedQuantity

number

The estimated usage used for the cost estimation of this item. For the unit, see unit. When this field has a value, assumedQuantityCost is also returned. This quantity is used for estimation, and the actual cost depends on the actual usage.

1000

assumedQuantityCost

number

The cost calculated based on the estimated usage, which is pricePerUnit multiplied by assumedQuantity. This amount is for estimation only and is not included in totalAmount. The actual cost depends on the actual usage.

195.5

chargeComposition

string

The cost composition of the current quote. Valid values:

  • recurring_only: Only fixed costs are included.

  • usage_only: Only usage-based costs are included. In this case, a totalAmount of 0 indicates no fixed costs, and the usage is still billed based on actual usage.

  • mixed: Both fixed and usage-based costs are included. This field only describes the current quote. For the cost composition of the entire inquiry, see price.chargeComposition.

recurring_only

upstreamRequestId

string

The identifier of the pricing request, which can be used for reconciliation and troubleshooting. This field may be returned regardless of whether the pricing request succeeds or fails. For the request ID of the GetApiPrice call, see the top-level requestId in the response.

30E7066E-AE6F-4E59-AFE6-11386CE3AFA7

errorCode

string

The error code returned when the pricing request fails, such as InvalidParameter. This field is empty when price.success is true.

InvalidParameter

errorMessage

string

The description of the reason for the pricing failure. You can use this description along with the errorCode to check parameters or troubleshoot issues. This field is empty when price.success is true.

The parameter values do not meet the requirements. Check the request parameters

components

object

The individual quotes involved in composite or delta pricing, such as quotes for instances and storage, or quotes for original and new configurations. The names in the object distinguish different quotes, and the specific names depend on the actual response. This field is used to view the cost breakdown. For the final quote of the entire pricing request, see totalAmount. You can obtain the unit prices for usage from the outer-level usageCharges. This field is empty or not returned for a standard single pricing request.

{"default":{"currency":"CNY","moduleSum":59.86,"quantity":1,"effectiveModuleSum":59.86,"pricingUnit":"1 Month","chargeComposition":"recurring_only"}}

object

The detailed information of an itemized quote. You can use this information to view the amount, cost breakdown, and unit prices for usage of the quote.

currency

string

The currency of the current quote. For example, CNY indicates Chinese Yuan.

CNY

tradePrice

number

The discounted transaction amount of the current quote. This field is empty when not provided. For the final quote of the entire inquiry, read price.totalAmount.

176.0

originalPrice

number

The pre-discount amount of the current quote. When comparing discounts, use the discounted amount with the same currency, billing cycle, quantity, and cost scope. This field is empty when the original price information is not provided.

176.0

moduleSum

number

The total discounted amount of fixed costs for the current quote, which is not yet multiplied by quantity. It does not include usage-based costs.

59.86

effectiveModuleSum

number

The total discounted amount of fixed costs calculated based on quantity, which is moduleSum multiplied by quantity. It does not include usage-based costs. For the final quote, read price.totalAmount.

59.86

quantity

number

The quantity used to calculate the fixed fee for this quote. Default value: 1. effectiveModuleSum = moduleSum × quantity. If the quoted amount already includes the required quantity, this field is 1, and you do not need to multiply it by the resource count when you invoke the API.

1

pricingUnit

string

The billing unit, such as Hour, 1 Month, 12 Month, or GB·Month. It specifies the billing unit corresponding to moduleSum. This field is empty when the unit is not provided for the current quote.

1 Month

modules

array<object>

The detail list of each cost item in the current quote, such as instance, disk, and network costs.

object

moduleCode

string

The code of the cost item, such as InstanceType. You can use this code to map the cost items in modules and usageCharges.

InstanceType

costAfterDiscount

number

The discounted amount of this cost item. For recurring cost items, it indicates the periodic cost corresponding to the current quote. For usage-based cost items, if quantityUsedForQuote has a value, it indicates the total cost for that quantity. For the price per unit of usage, read the corresponding usageCharges[].pricePerUnit.

19.86

originalCost

number

The pre-discount amount of this cost item, which corresponds to costAfterDiscount.

45.14

invoiceDiscount

number

The discount amount of this cost item. This field is empty when not provided. An empty field does not indicate that no discount is applied.

25.28

unitPrice

number

The unit price of this cost item. This field is empty when not provided. An empty field does not indicate that the item is free of charge. For the unit price of usage-based costs, read usageCharges[].pricePerUnit.

0.5

billingMode

string

The billing method for this cost item. Valid values:

  • recurring: Billed by time period and included in the fixed fee.

  • usage: Billed by actual usage and not included in the fixed fee. For the unit price, see usageCharges[].pricePerUnit.

recurring

usageUnit

string

The usage unit when billed based on actual usage, such as GB or CU. It is consistent with the corresponding usageCharges[].unit. For the price per unit of usage, see usageCharges[].pricePerUnit.

CU

quantityUsedForQuote

number

The usage quantity corresponding to the quote of this cost item. When this field has a value, costAfterDiscount indicates the total cost for this quantity. This quantity is used to explain the quote amount, and the actual cost depends on the actual usage. For the price per unit of usage, see usageCharges[].pricePerUnit.

1000

usageCharges

array<object>

The list of unit prices for usage-based costs in the current quote. Each record specifies the cost item, usage unit, and unit price. The corresponding costs are not included in moduleSum or effectiveModuleSum. This field is empty or not returned when there are no usage-based cost items.

object

moduleCode

string

The code of the cost item, such as TrafficOut or NatCu. It corresponds to the moduleCode in the pricing details modules.

NatCu

unit

string

The usage unit, such as GB, CU, or 10,000 requests. pricePerUnit indicates the price per unit of usage.

CU

pricePerUnit

number

The discounted price per unit of usage. For the usage unit, see unit. For the currency, see price.currency. You can estimate the cost by multiplying pricePerUnit by the estimated usage. This cost is not included in totalAmount.

0.1955

originalPricePerUnit

number

The pre-discount price per unit of usage. For the usage unit, see unit. For the currency, see price.currency. This field is empty when not provided. The difference between this field and pricePerUnit is the discount amount per unit of usage.

0.23

assumedQuantity

number

The estimated usage used for the cost estimation of this item. For the unit, see unit. When this field has a value, assumedQuantityCost is also returned. This quantity is used for estimation, and the actual cost depends on the actual usage.

1000

assumedQuantityCost

number

The cost calculated based on the estimated usage, which is pricePerUnit multiplied by assumedQuantity. This amount is for estimation only and is not included in totalAmount. The actual cost depends on the actual usage.

195.5

chargeComposition

string

The cost composition of the current quote. Valid values:

  • recurring_only: Only fixed costs are included.

  • usage_only: Only usage-based costs are included. In this case, a totalAmount of 0 indicates no fixed costs, and the usage is still billed based on actual usage.

  • mixed: Both fixed and usage-based costs are included. This field only describes the current quote. For the cost composition of the entire inquiry, see price.chargeComposition.

recurring_only

requestId

string

The request ID of the GetApiPrice call, which can be used for troubleshooting.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

Examples

Success response

JSON format

{
  "success": false,
  "code": "Success",
  "message": "Pricing inquiry successful",
  "price": {
    "pricingMode": "single",
    "success": false,
    "currency": "CNY",
    "calculatedAmount": 28.89,
    "totalAmount": 59.86,
    "originalAmount": 85.14,
    "discountAmount": 25.28,
    "billingUnit": "1 Month",
    "usageCharges": [
      {
        "moduleCode": "NatCu",
        "unit": "CU",
        "pricePerUnit": 0.1955,
        "originalPricePerUnit": 0.23,
        "assumedQuantity": 1000,
        "assumedQuantityCost": 195.5
      }
    ],
    "chargeComposition": "recurring_only",
    "priceSummary": {
      "currency": "CNY",
      "tradePrice": 176,
      "originalPrice": 176,
      "moduleSum": 59.86,
      "effectiveModuleSum": 59.86,
      "quantity": 1,
      "pricingUnit": "1 Month",
      "modules": [
        {
          "moduleCode": "InstanceType",
          "costAfterDiscount": 19.86,
          "originalCost": 45.14,
          "invoiceDiscount": 25.28,
          "unitPrice": 0.5,
          "billingMode": "recurring",
          "usageUnit": "CU",
          "quantityUsedForQuote": 1000
        }
      ],
      "usageCharges": [
        {
          "moduleCode": "NatCu",
          "unit": "CU",
          "pricePerUnit": 0.1955,
          "originalPricePerUnit": 0.23,
          "assumedQuantity": 1000,
          "assumedQuantityCost": 195.5
        }
      ],
      "chargeComposition": "recurring_only"
    },
    "upstreamRequestId": "30E7066E-AE6F-4E59-AFE6-11386CE3AFA7",
    "errorCode": "InvalidParameter",
    "errorMessage": "The parameter values do not meet the requirements. Check the request parameters",
    "components": {
      "key": {
        "currency": "CNY",
        "tradePrice": 176,
        "originalPrice": 176,
        "moduleSum": 59.86,
        "effectiveModuleSum": 59.86,
        "quantity": 1,
        "pricingUnit": "1 Month",
        "modules": [
          {
            "moduleCode": "InstanceType",
            "costAfterDiscount": 19.86,
            "originalCost": 45.14,
            "invoiceDiscount": 25.28,
            "unitPrice": 0.5,
            "billingMode": "recurring",
            "usageUnit": "CU",
            "quantityUsedForQuote": 1000
          }
        ],
        "usageCharges": [
          {
            "moduleCode": "NatCu",
            "unit": "CU",
            "pricePerUnit": 0.1955,
            "originalPricePerUnit": 0.23,
            "assumedQuantity": 1000,
            "assumedQuantityCost": 195.5
          }
        ],
        "chargeComposition": "recurring_only"
      }
    }
  },
  "requestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidRamUser.NoPermission GetApiPrice access denied. %s

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.