Updated on 2025-07-28 GMT+08:00

Querying Bill Summary

Function

This API can be used by customers to query their expenditure summaries on the self-built platform. The expenditure data is summarized by month.

For details about how to log in to the Billing Center to query bill summary, see Viewing Summary Data in Bill Summary.

  • The bills displayed for an enterprise master account include the expenditure data of its member accounts.
  • You can query data from the past three years.
  • An enterprise master account needs required authorization from independent accounting members to view their expenditure information. For details about how to request such authorization, see Changing Member Account Permissions.

Constraints

This API can only be invoked using the customer AK/SK or token.

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/monthly-sum

The following table describes the parameters.

Table 1 Parameters

Parameter

Mandatory

Type

Maximum Length/Value Range

Description

bill_cycle

Yes

String

A maximum of 8 characters

Billing cycle of the expenditure summary, which is in YYYY-MM format (GMT+08:00).

service_type_code

No

String

A maximum of 64 characters

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 or is left empty, it cannot be used as a filter criterion.

enterprise_project_id

No

String

A maximum of 64 characters

Enterprise project ID.

If this parameter is not included or is left empty, it cannot be used as a filter criterion. If this parameter is set to null, it can be used as a filter criterion. This parameter cannot be set to "".

method

No

String

A maximum of 64 characters

Query method.

  • oneself: Query the expenditure data of the enterprise master account itself.
  • sub_customer: Query the expenditure data of enterprise member accounts associated with the enterprise master account.
  • all: Query the expenditure data of both the enterprise master account and its associated member accounts.

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 there are no member accounts associated, the expenditure data of the enterprise master account itself is queried.

NOTE:

An enterprise master account needs required authorization from independent accounting members to view their expenditure information. For details about how to request such authorization, see Changing Member Account Permissions.

sub_customer_id

No

String

A maximum of 64 characters

ID of an enterprise member account.

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.

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

Number of queried records each time. The default value is 10.

Request Message

Request Parameters

None

Example Request

GET https://bss-intl.myhuaweicloud.com/v2/bills/customer-bills/monthly-sum?bill_cycle=2020-07&method=sub_customer&sub_customer_id=05b5fef62300d2ad0f98c00befba72c0&offset=0&limit=10 HTTP/1.1
Content-Type: application/json
X-Auth-Token: MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ

Response Message

Response parameters

Parameter

Type

Maximum Length/Value Range

Description

error_code

String

A maximum of 20 characters

Error code. For details, see Status Codes.

This parameter is returned only when a failure occurs.

error_msg

String

A maximum of 2,000 characters

Error description.

This parameter is returned only when a failure occurs.

total_count

Integer

-

Number of the total records. The value must be greater than or equal to 0.

bill_sums

List<BillSumRecordInfo>

-

Bill information. For details, see Table 2.

consume_amount

Bigdecimal

-

Total amount (including unsubscriptions).

debt_amount

Bigdecimal

-

Monthly-paid user: monthly settlement (For details about monthly settlement, click here.)

Non-monthly-paid subscriber: outstanding amount

coupon_amount

Bigdecimal

-

Cash coupon amount.

flexipurchase_coupon_amount

Bigdecimal

-

Flexi-purchase coupon amount. This parameter is reserved.

stored_value_card_amount

Bigdecimal

-

Stored-value card amount. This parameter is reserved.

cash_amount

Bigdecimal

-

Balance in the cash account.

credit_amount

Bigdecimal

-

Balance in the credit account.

writeoff_amount

Bigdecimal

-

Write-off amount.

measure_id

Integer

-

Unit.

  • 1: Yuan/Dollar

currency

String

A maximum of 4 characters

Currency.

USD

Table 2 BillSumRecordInfo

Parameter

Type

Maximum Length/Value Range

Description

bill_cycle

String

A maximum of 8 characters

Billing cycle of the expenditure summary, which is in YYYY-MM format (GMT+08:00).

bill_type

Integer

-

Bill type.

  • 1: expenditure
  • 2: refund
  • 3: adjustment

customer_id

String

A maximum of 64 characters

Account ID of the customer who has expenditure records.

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

resource_type_code

String

A maximum of 64 characters

Resource type code. For example, the resource type code of ECS is hws.resource.type.vm.

service_type_code

String

A maximum of 64 characters

Cloud service type code. For example, the cloud service type code of OBS is hws.service.type.obs.

resource_type_name

String

A maximum of 200 characters

Resource type. For example, the resource type of ECS is Cloud Host.

service_type_name

String

A maximum of 200 characters

Cloud service type. For example, the cloud service type of ECS is Elastic Cloud Server.

charging_mode

Integer

-

Billing mode. The options are as follows:

  • 1: yearly/monthly
  • 3: pay-per-use
  • 10: reserved instances
  • 11: savings plan

official_amount

Bigdecimal

-

List price.

official_discount_amount

Bigdecimal

-

Discounted amount.

truncated_amount

Bigdecimal

-

Truncated amount.

consume_amount

Bigdecimal

-

Amount.

Amount = List price – Discounted amount – Truncated amount

coupon_amount

Bigdecimal

-

Cash coupon amount.

flexipurchase_coupon_amount

Bigdecimal

-

Flexi-purchase coupon amount. This parameter is reserved.

stored_value_card_amount

Bigdecimal

-

Stored-value card amount. This parameter is reserved.

debt_amount

Bigdecimal

-

Monthly-paid user: monthly settlement (For details about monthly settlement, click here.)

Non-monthly-paid subscriber: outstanding amount

writeoff_amount

Bigdecimal

-

Write-off amount.

cash_amount

Bigdecimal

-

Balance in the cash account.

credit_amount

Bigdecimal

-

Balance in the credit account.

measure_id

Integer

-

Unit.

  • 1: Yuan/Dollar

Example Response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: length
Date: response time  
{
    "total_count": 2,
    "bill_sums": [
        {
            "bill_cycle": "2020-07",
            "bill_type": 1,
            "customer_id": "05b5fef62300d2ad0f98c00befba72c0",
            "resource_type_code": "hws.resource.type.bandwidth",
            "service_type_code": "hws.service.type.vpc",
            "charging_mode": 3,
            "official_amount": 7.0,
            "official_discount_amount": 0.0,
            "truncated_amount": 2.363856,
            "consume_amount": 7.0,
            "coupon_amount": 0.0,
            "flexipurchase_coupon_amount": 0.0,
            "stored_value_card_amount": 0.0,
            "debt_amount": 0.0,
            "writeoff_amount": 0.0,
            "cash_amount": 0.0,
            "credit_amount": 7.0,
            "measure_id": 1
        },
        {
            "bill_cycle": "2020-07",
            "bill_type": 1,
            "customer_id": "05b5fef62300d2ad0f98c00befba72c0",
            "resource_type_code": "hws.resource.type.kms",
            "service_type_code": "hws.service.type.kms",
            "resource_type_name": "Cloud Host",
            "service_type_name": "Elastic Cloud Server"
            "charging_mode": 3,
            "official_amount": 3524.424,
            "official_discount_amount": 0.0,
            "truncated_amount": 1244.424,
            "consume_amount": 2280.0,
            "coupon_amount": 0.0,
            "flexipurchase_coupon_amount": 0.0,
            "stored_value_card_amount": 0.0,
            "debt_amount": 0.0,
            "writeoff_amount": 0.0,
            "cash_amount": 0.0,
            "credit_amount": 2280.0,
            "measure_id": 1
        }
    ],
    "consume_amount": 16964.0,
    "debt_amount": 0.0,
    "coupon_amount": 464.0,
    "flexipurchase_coupon_amount": 0.0,
    "stored_value_card_amount": 0.0,
    "cash_amount": 1306.0,
    "credit_amount": 15194.0,
    "writeoff_amount": 0.0,
    "measure_id": 1,
    "currency": "USD"
}

Status Codes

  • 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 Status Code

Error Code

Description

400

CBC.0100

Incorrect parameter.

403

CBC.0151

Access denied.

500

CBC.0999

Other errors.