Updated on 2024-08-15 GMT+08:00

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 usage details by referring to Resource Bill.

  • 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.

URI

GET /v2/bills/customer-bills/res-fee-records

The following table describes the parameters.

Table 1 Message header parameter

Parameter

Mandatory

Type

Maximum Length

Description

X-Language

No

String

10

Language.

en_US: English

zh_CN: Chinese

Table 2 Request parameters

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:

  • 1: Yearly/monthly
  • 3: Pay-per-use
  • 10: Reserved instances

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, eu-west-101.

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.

  • 1: expenditure-purchase
  • 2: expenditure-renewal
  • 3: expenditure-change
  • 4: refund-unsubscription
  • 5: expenditure-use
  • 8: expenditure-auto-renewal
  • 9: adjustment-compensation
  • 12: Expenditure-hourly billing
  • 13: expenditure--unsubscription service charge
  • 14: expenditure-month-end deduction for support plan
  • 15: expenditure-tax
  • 16: adjustment-deduction
  • 17: expenditure-difference amount (min. guaranteed-actual)
    NOTE:

    Expenditure-difference amount (min. guaranteed-actual) determines the fees that a customer needs to pay if the customer does not reach the minimum expenditure limit stipulated in the signed contract. This rule is applicable to direct sales customers and referral customers who use postpaid method.

  • 20: refund-change
  • 24: refund-changing to Pay-Per-Use
  • 100: refund-unsubscription tax
  • 101: adjustment-tax compensation
  • 102: adjustment-tax deduction

If this parameter is not included or is left empty, it cannot be used as a filter criterion.

offset

No

Integer

0 to 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 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.

  • 0: ID of a default project
  • – 1: The service does not support enterprise project management.

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.

  • true: Yes
  • false: No

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.

  • oneself: Query the resource consumption records of an enterprise itself.
  • sub_customer: Query the resource consumption records of enterprise's sub-customers.
  • all: Query the resource consumption records of an enterprise and its sub-customers.

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:
  • This parameter is invalid if method is not set to sub_customer.
  • If method is set to sub_customer, this parameter must be specified.

trade_id

No

String

64

Order or transaction ID.

  • This parameter indicates an order ID if the bill type is 1, 2, 3, 4, or 8.
  • For other bill types, this parameter indicates a transaction ID that uniquely identifies a fee deduction dimension.

    For example, this parameter represents bills when fees are deducted at the end of a month. Otherwise, this parameter represents receivables.

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

20

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:
  • This parameter value must be in the month specified by parameter cycle.
  • bill_date_begin and bill_date_end must be set at the same time. Otherwise, resources are queried only by cycle.
  • This field does not take effect when statistics are collected by billing cycle type.

bill_date_end

No

String

20

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:
  • This parameter value must be in the month specified by parameter cycle.
  • bill_date_begin and bill_date_end must be set at the same time. Otherwise, resources are queried only by cycle.
  • This field does not take effect when statistics are collected by billing cycle type.

statistic_type

No

Integer

-

Statistics type. The default value is 3.

  • 1: By billing cycle
  • 3: By details

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.myhuaweicloud.eu/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

Table 3 ResFeeRecordV2

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.

  • 1: expenditure-purchase
  • 2: expenditure-renewal
  • 3: expenditure-change
  • 4: refund-unsubscription
  • 5: expenditure-use
  • 8: expenditure-auto-renewal
  • 9: adjustment-compensation
  • 12: Expenditure-hourly billing
  • 13: expenditure--unsubscription service charge
  • 14: expenditure-month-end deduction for support plan
  • 15: expenditure-tax
  • 16: adjustment-deduction
  • 17: expenditure-difference amount (min. guaranteed-actual)
    NOTE:

    Expenditure-difference amount (min. guaranteed-actual) determines the fees that a customer needs to pay if the customer does not reach the minimum expenditure limit stipulated in the signed contract. This rule is applicable to direct sales customers and referral customers who use postpaid method.

  • 20: refund-change
  • 24: refund-changing to Pay-Per-Use
  • 100: refund-unsubscription tax
  • 101: adjustment-tax compensation
  • 102: adjustment-tax deduction

customer_id

String

64

Account ID of the customer who has consumption records.

  • If a common account or enterprise member account is used to query consumption records, only the ID of the customer itself is displayed.
  • If an enterprise master account is used to query consumption records, the consumption records of its own and its member accounts can be queried. The ID of a master or member account will be displayed.

region

String

64

Cloud service region code, for example, eu-west-101.

region_name

String

64

Region name, for example, EU-Ireland. .

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.

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.

resource_id

String

128

Resource ID.

resource_name

String

256

Resource name.

resource_tag

String

1024

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

enterprise_project_id

String

128

Enterprise project ID.

  • 0: ID of a default project
  • null: The service does not support enterprise project management.

enterprise_project_name

String

256

Enterprise project name.

charge_mode

String

32

Billing mode. The options are as follows:

  • 1: Yearly/monthly
  • 3: Pay-per-use
  • 10: Reserved instances

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:

  • 19: Year
  • 20: Month
  • 24: Day
  • 25: Hour
  • 5: One-off

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 price of a pay-per-use product is returned only in the simple pricing scenario.
  • Unit price of a yearly/monthly product is returned only in the following scenarios:
    • Yearly/monthly subscription, renewal, specification downsizing, specification upgrade, and capacity expansion
    • Simple pricing
  • Unit price of a reserved instance is returned only in the following scenarios:
    • Subscription, renewal, specification downsizing, specification upgrade, capacity expansion, and pay-per-use
    • Simple pricing

unit

String

64

The unit of unit price.

  • The unit of linear products is USD/{linear unit}/month or USD/{linear unit}/hour.
  • The unit of non-linear products is USD/month or USD/hour.
NOTE:
  • The linear unit is the unit of linear products (those come in sizes). For example, the linear unit of the hard disk is GB, and that of the bandwidth is Mbit/s.

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.

  • 1: Dollar

formula

String

2048

Formula for calculating the actual payment amount. Currently, only the following scenarios are involved:

  • Non-linear pricing for pay-per-use resources

    {Usage}[Usage]/{Unit conversion rate}[Unit conversion] x {Unit price}[Unit price] - {Discounted amount}[Discounted amount] - {Truncated amount}[Truncated amount] - {Cash coupon used}[Cash coupon used]

  • Linear pricing for pay-per-use resources

    {Usage}[Usage]/{Unit conversion rate}[Unit conversion] x {Linear size}[Specifications] x {Unit price}[Unit price] - {Discounted amount}[Discounted amount] - {Truncated amount}[Truncated amount] - {Cash coupon used}[Cash coupon used]

  • Non-linear pricing for yearly/monthly subscriptions and renewals

    {Number of periods}[Number of periods]/{Period conversion rate}[Period conversion] x {Unit price}[Unit price] - {Discounted amount}[Discounted amount] - {Cash coupon used}[Cash coupon used]

  • Linear pricing for yearly/monthly subscriptions and renewals

    {Number of periods}[Number of periods]/{Period conversion rate}[Period conversion] x {Linear size}[Specification] x {Unit price}[Unit price] - {Discounted amount}[Discounted amount] - {Cash coupon used}[Cash coupon used]

  • Non-linear pricing for yearly/monthly subscriptions (one-off) and renewals

    {Unit price}[Unit price] - {Discounted amount}[Discounted amount] - {Cash coupon used}[Cash coupon used]

  • Linear pricing for yearly/monthly subscriptions (one-off) and renewals

    {Linear size}[Specifications] x {Unit price}[Unit price] - {Discounted amount} [Discounted amount] - {Cash coupon used}[Cash coupon used]

NOTE:
  • The actual payment amount is equal to the difference between amount and coupon_amount.
  • When statistic_type is set to 1 (by billing cycle type), the formula for calculating the actual payment amount will not be returned.

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.

Example Response
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": "eu-west-101",
            "region_name": "EU-Dublin",
            "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-48******9eb5153cba_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,
            "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": "eu-west-101",
            "region_name": "EU-Dublin",
            "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-48******9eb5153cba_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,
            "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]"
        }
    ],
    "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.