Viewing Resource Expenditures
Function
This API can be used to query expenditures of each resource for a customer on the self-built platform.
Postpaid customers who have enabled the monthly settlement can log in to Billing Center to query their resource expenditures by referring to Resource Expenditures.
There is an hour-level delay for resource expenditure details.
- You can query data from the past three years.
Constraints
- This API can be invoked using the customer AK/SK or token only.
- This API can be used to query resource expenditure records generated in the same month.
- The data queried for the current month cannot be used for reconciliation. The final bill of the current month can be viewed and exported after 10:00 on the fourth day of the following month. Situations, such as, bill delay, refunds, bill adjustment, and outstanding amount write-off, may occur during a month.
Debugging
You can debug the API in API Explorer which supports automatic authentication. API Explorer can automatically generate and debug example SDK code.
URI
GET /v2/bills/customer-bills/res-fee-records
The following table describes the parameters.
Parameter |
Mandatory |
Type |
Maximum Length |
Description |
---|---|---|---|---|
X-Language |
No |
String |
10 |
Language. en_US: English zh_CN: Chinese |
Parameter |
Mandatory |
Type |
Maximum Length |
Description |
---|---|---|---|---|
cycle |
Yes |
String |
10 |
Billing cycle of the queried resource consumption records, which is in YYYY-MM format (GMT+08:00). |
charge_mode |
No |
String |
4 |
Billing mode. The options are as follows:
If this parameter is not included in the request parameters, it cannot be used as a filter criterion. It cannot be left empty or set to "" or null. |
cloud_service_type |
No |
String |
64 |
Cloud service type code. For example, the cloud service type code of OBS is hws.service.type.obs. To obtain a specific service type, call the API in Querying Cloud Service Types. If this parameter is not included in the request parameters, it cannot be used as a filter criterion. If this parameter is left empty or is set to "", it can be used as a filter criterion. |
region |
No |
String |
64 |
Cloud service region code, for example, ap-southeast-1. Obtain the value from the Region column in Regions and Endpoints. If this parameter is not included in the request parameters, it cannot be used as a filter criterion. If this parameter is left empty or is set to "", it can be used as a filter criterion. |
bill_type |
No |
Integer |
- |
Bill type.
If this parameter is not included or is left empty, it cannot be used as a filter criterion. |
offset |
No |
Integer |
0 to a maximum integer |
Offset, which starts from 0. The default value is 0.
NOTE:
This parameter is used for pagination. Retain its default value 0 if pagination is not required. offset indicates the offset relative to the first data record among all that meets the conditions configured. If you set offset to 1, the second and subsequent data records are returned. For example, if there are 10 records that meet query conditions, when you set limit to 10 and offset to 1, the second to the tenth records are returned. If there are 20 records that meet query conditions, when you set offset to 0 and limit to 10 for the first page and set offset to 10 and limit to 10 for the second page, then each page will respectively have 10 records. |
limit |
No |
Integer |
1–1000 |
Maximum number of records in each query. The default value is 10. |
resource_id |
No |
String |
64 |
Resource ID. If this parameter is not included in the request parameters, it cannot be used as a filter criterion. If this parameter is left empty or is set to "", it can be used as a filter criterion. |
enterprise_project_id |
No |
String |
64 |
Enterprise project ID.
If this parameter is not included in the request, is left empty, or is set to "" or null, it cannot be used as a filter criterion. |
include_zero_record |
No |
Boolean |
- |
Whether to return records for which the amount due is 0.
If this parameter is not included or is left empty, it cannot be used as a filter criterion. |
method |
No |
String |
64 |
Method of querying resource consumption records.
If this parameter is not included in the request parameters or is left empty, the default value is all. If this parameter is set to all and an enterprise has no customers, the enterprise queries its own resource usage details. |
sub_customer_id |
No |
String |
64 |
Enterprise member account ID. If this parameter is set to "", it cannot be used as a filter criterion.
NOTE:
|
trade_id |
No |
String |
64 |
Order or transaction ID.
If this parameter is not included in the request parameters, it cannot be used as a filter criterion. If this parameter is left empty or is set to "", it can be used as a filter criterion.
NOTE:
This field does not take effect when statistics are collected by billing cycle type. |
bill_date_begin |
No |
String |
10 |
Start date for querying the resource consumption records, which is in YYYY-MM-DD format (GMT+08:00). If this parameter is not included in the request parameters, is left empty, or is set to "", the first day of the billing cycle is used.
NOTE:
|
bill_date_end |
No |
String |
10 |
End date for querying the resource consumption records, which is in YYYY-MM-DD format (GMT+08:00). If this parameter is not included in the request parameters, is left empty, or is set to "", the last day of the billing cycle is used.
NOTE:
|
statistic_type |
No |
Integer |
- |
Statistics type. The default value is 3.
If this parameter is not included in the request or is set to null, the default value 3 is used. |
Request Message
Request Parameters
None
Example Request
GET https://bss-intl.myhuaweicloud.com/v2/bills/customer-bills/res-fee-records?cycle=2020-09&charge_mode=1&method=sub_customer&sub_customer_id=05b5fef62300d2ad0f98c00befba72c0&trade_id= CS1908201442ZLEPW476&bill_date_begin=2020-09-01&bill_date_end=2020-09-30&statistic_type=1 HTTP/1.1 Content-Type: application/json X-Auth-Token: MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ
Response Message
Response Parameters
Parameter |
Type |
Maximum Length |
Description |
---|---|---|---|
error_code |
String |
16 |
Status code. For details, see Status code. This parameter is returned only when a failure occurs. |
error_msg |
String |
1024 |
Error description. This parameter is returned only when a failure occurs. |
fee_records |
List<ResFeeRecordV2> |
- |
Resource usage record. For details, see Table 3. |
total_count |
Integer |
- |
Number of result sets. This parameter is returned only when the query is successful. |
currency |
String |
3 |
Currency. USD |
Parameter |
Type |
Maximum Length |
Description |
---|---|---|---|
bill_date |
String |
20 |
Date when a resource consumption is recorded. Format: YYYY-MM-DD. The value is based on the GMT+08:00 time zone. |
bill_type |
Integer |
- |
Bill type.
|
customer_id |
String |
64 |
Account ID of the customer who has consumption records.
|
region |
String |
64 |
Cloud service region code, for example, ap-southeast-1. Obtain the value from the Region column in Regions and Endpoints. |
region_name |
String |
64 |
Region name, for example, CN-Hong Kong. Obtain the value from the Region column in Regions and Endpoints.. |
cloud_service_type |
String |
64 |
Cloud service type code. For example, the cloud service type code of OBS is hws.service.type.obs. |
resource_type |
String |
64 |
Resource type code. For example, the resource type code of ECS is hws.resource.type.vm. |
cloud_service_type_name |
String |
200 |
Cloud service type. For example, the cloud service type of ECS is Elastic Cloud Server. |
resource_type_name |
String |
200 |
Resource type. For example, the resource type of ECS is Cloud Host. |
effective_time |
String |
32 |
Start time of using the resource corresponding to the fee. This field is valid only when the resource is billed on a pay-per-use basis. It is reserved for resources billed on a yearly/monthly basis. Format: yyyy-MM-dd'T'HH:mm:ss'Z' (UTC time is used.) |
expire_time |
String |
32 |
End time of using the resource corresponding to the fee. This field is valid only when the resource is billed on a pay-per-use basis. It is reserved for resources billed on a yearly/monthly basis. Format: yyyy-MM-dd'T'HH:mm:ss'Z' (UTC time is used.) |
resource_id |
String |
128 |
Resource ID. |
resource_name |
String |
256 |
Resource name.
NOTE:
The return value of this parameter is manually entered by the user when placing a resource order. Internationalization is not supported. |
resource_tag |
String |
8,192 |
Resource tag. |
product_id |
String |
64 |
Product ID. |
product_name |
String |
256 |
Product name. |
product_spec_desc |
String |
512 |
Product specification description. |
sku_code |
String |
64 |
SKU code, which uniquely identifies the resource specification in a bill. |
spec_size |
BigDecimal |
- |
Product size, which is available only for linear products.
NOTE:
Linear products are those whose size must be specified during a subscription. For example, you can select 10 GB or 20 GB during a disk subscription. |
spec_size_measure_id |
Integer |
- |
Product size unit, which is available only for linear products. To obtain the unit, call the API in Querying Measurement Units. |
trade_id |
String |
64 |
Order or transaction ID, which is the unique identifier of a fee deduction dimension. |
id |
String |
256 |
Unique ID This value of the unique ID will not be returned when statistics are collected by billing cycle type. |
trade_time |
String |
32 |
Transaction time Format: yyyy-MM-dd'T'HH:mm:ss'Z' (UTC time is used.) |
enterprise_project_id |
String |
128 |
Enterprise project ID.
|
enterprise_project_name |
String |
256 |
Enterprise project name.
NOTE:
The return value of this parameter is manually entered by users. Internationalization is not supported. |
charge_mode |
String |
32 |
Billing mode. The options are as follows:
|
order_id |
String |
64 |
Order ID.
NOTE:
This parameter is available only for yearly/monthly resources. |
period_type |
String |
- |
Period type. The value can be:
|
usage_type |
String |
- |
Usage type, which can be obtained by calling the API described in Querying Usage Types. |
usage |
BigDecimal |
- |
Resource usage.
NOTE:
If the resource type is yearly/monthly resources, resource usage is not returned. |
usage_measure_id |
Integer |
- |
Resource usage measurement unit, which can be obtained by calling the API described in Querying Measurement Units.
NOTE:
If the resource type is yearly/monthly resources, the resource usage measurement unit is not returned. |
free_resource_usage |
BigDecimal |
- |
Package usage. |
free_resource_measure_id |
Integer |
- |
Usage measurement unit in a package, which can be obtained by calling the API described in Querying Measurement Units. |
ri_usage |
BigDecimal |
- |
Reserved instance usage. |
ri_usage_measure_id |
Integer |
- |
Unit (reserved instance usage). |
unit_price |
BigDecimal |
- |
Unit price.
|
unit |
String |
64 |
The unit of unit price.
NOTE:
|
official_amount |
BigDecimal |
- |
List price, which is the sales price of a product with no commercial discounts and promotion discounts used on the HUAWEI CLOUD official website. |
discount_amount |
BigDecimal |
- |
Discount, which is offered to customers when they use cloud services, for example, commercial discounts, partner-granted discounts, and promotional discount. |
amount |
BigDecimal |
- |
Amount, which is the money a customer should pay for used cloud services after discounts (including cash coupons) are used. It is accurate to eight decimal places.
NOTE:
The value of amount is equal to the sum of the values of cash_amount, credit_amount, coupon_amount, flexipurchase_coupon_amount, stored_card_amount, bonus_amount, debt_amount, and adjustment_amount. |
cash_amount |
BigDecimal |
- |
Amount paid in cash. |
credit_amount |
BigDecimal |
- |
Amount paid using the credit. |
coupon_amount |
BigDecimal |
- |
Amount paid using the cash coupon. |
flexipurchase_coupon_amount |
BigDecimal |
- |
Amount paid using the flexi-purchase coupon. |
stored_card_amount |
BigDecimal |
- |
Amount paid using the values-stored card. |
bonus_amount |
BigDecimal |
- |
Bonus payment amount (used for the bonus that is not cleared on the live network). |
debt_amount |
BigDecimal |
- |
Debt. |
adjustment_amount |
BigDecimal |
- |
Adjustment amount. |
measure_id |
Integer |
- |
Unit.
|
formula |
String |
2048 |
Formula for calculating the actual payment amount. Currently, only the following scenarios are involved:
NOTE:
|
sub_service_type_code |
String |
64 |
Service type code of a child service that is attached to an ECS. |
sub_service_type_name |
String |
200 |
Service type name of a child service that is attached to an ECS. |
sub_resource_type_code |
String |
64 |
Resource type code of a child resource that is attached to an ECS. |
sub_resource_type_name |
String |
200 |
Resource type name of a child resource that is attached to an ECS. |
sub_resource_id |
String |
64 |
Resource ID of a child resource that is attached to an ECS. If the resource is a reserved instance, this parameter indicates a reserved instance ID. |
sub_resource_name |
String |
256 |
Resource name of a child resource that is attached to an ECS. If the resource is a reserved instance, this parameter indicates a reserved instance name.
NOTE:
The return value of this parameter is manually entered by the user when placing a resource order. Internationalization is not supported. |
HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 Content-Length: length Date: response time { "fee_records": [ { "bill_date": "2020-12-21", "bill_type": 3, "customer_id": "8caf348df5fa4529aba5aea760608845", "region": "ap-southeast-1", "region_name": "CN North-Beijng1", "cloud_service_type": "hws.service.type.ebs", "resource_type": "hws.resource.type.volume", "effective_time": "2020-12-21T07:34:32Z", "expire_time": "2022-12-21T15:59:59Z", "resource_id": null, "resource_name": null, "resource_tag": null, "product_id": "90301-686007-0--0", "product_name": "", "product_spec_desc": "", "sku_code": "SAS", "spec_size": 300.0, "spec_size_measure_id": 17, "trade_id": "CS2012211533IQJR1", "id": "037e8a2b-bde9******eb5153cba_1", "trade_time": "2020-06-10T19:03:28Z", "enterprise_project_id": "0", "enterprise_project_name": "default", "charge_mode": "1", "order_id": "CS2012211533IQJR1", "period_type": "19", "usage_type": null, "usage": null, "usage_measure_id": null, "free_resource_usage": null, "free_resource_measure_id": null, "ri_usage": null, "ri_usage_measure_id": null, "unit_price": null, "unit": null, "official_amount": 2516.0, "discount_amount": 452.88, "amount": 2063.12, "cash_amount": 2063.12, "credit_amount": 0.0, "coupon_amount": 0.0, "flexipurchase_coupon_amount": 0.0, "stored_card_amount": 0.0, "bonus_amount": 0.0, "debt_amount": 0.0, "adjustment_amount": null, "measure_id": 1, "sub_service_type_code": null, "sub_service_type_name": null, "sub_resource_type_code": null, "sub_resource_type_name": null, "sub_resource_id": null, "sub_resource_name": null, "formula": "(1 year)[Number of periods]/(1)[Period conversion] x (100 GB)[Resource specifications] x (1.08 dollars/GB/year)[Unit price] - 21.60 [Discount] - 0.00[Cash coupon used]" }, { "bill_date": "2020-12-21", "bill_type": 1, "customer_id": "8caf348df5fa4529aba5aea760608845", "region": "cn-north-1", "region_name": "CN North-Beijng1", "cloud_service_type": "hws.service.type.ebs", "resource_type": "hws.resource.type.volume", "effective_time": "2020-12-21T07:28:12Z", "expire_time": null, "resource_id": null, "resource_name": null, "resource_tag": null, "product_id": "90301-526111-0--0", "product_name": "EVS_SATA_5 years", "product_spec_desc": "EVS_SATA_LXH01|100.0 GB", "sku_code": "SATA_LXH01", "spec_size": 100.0, "spec_size_measure_id": 17, "trade_id": "CS2012211528IP5Q1", "id": "037e8a2b-bde9-******-5f9eb5153cba_1", "trade_time": "2020-06-10T17:03:28Z", "enterprise_project_id": "0", "enterprise_project_name": "default", "charge_mode": "1", "order_id": "CS2012211528IP5Q1", "period_type": "19", "usage_type": null, "usage": null, "usage_measure_id": null, "free_resource_usage": null, "free_resource_measure_id": null, "ri_usage": null, "ri_usage_measure_id": null, "unit_price": null, "unit": null, "official_amount": 4.0, "discount_amount": 0, "amount": 4.0, "cash_amount": 4.0, "credit_amount": 0.0, "coupon_amount": 0.0, "flexipurchase_coupon_amount": 0.0, "stored_card_amount": 0.0, "bonus_amount": 0.0, "debt_amount": 0.0, "adjustment_amount": null, "measure_id": 1, "formula": "(1 year)[Number of periods]/(1)[Period conversion] x (100 GB)[Resource specifications] x (1.08 dollars/GB/year)[Unit price] - 21.60 [Discount] - 0.00[Cash coupon used]" } ], "total_count": 40, "currency": "USD" }
Status code
- 4xx: This class of HTTP status code is intended for situations in which the error seems to have been caused by the client, for example, the request contains bad syntax or incorrect parameters. You must ensure the request is correct.
- 5xx: This class of HTTP status code is intended for cases in which the Huawei Cloud server is aware that it has encountered an error or is otherwise incapable of performing the request. In this case, contact Huawei Cloud customer service.
HTTP Value |
Error Code |
Description |
---|---|---|
400 |
CBC.0100 |
Parameter error. |
403 |
CBC.0151 |
Access denied. |
500 |
CBC.0999 |
Unknown error occurred. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot