All Products
Search
Document Center

Expenses and Costs:QueryAccountBill

Last Updated:Nov 11, 2025

Queries account spending within a billing cycle and aggregates the data by resource owner.

Operation description

  • Data for the current month is for reference only. Do not use it for reconciliation. The final bill for the current month is available to view or export after 12:00 on the third day of the next month. This delay accounts for mid-month events such as delayed billing, refunds, bill adjustments, and overdue payment write-offs.

  • Data from the last 18 months is available.

  • Billing data is updated 24 hours after actual resource consumption. Information related to instance IDs, such as instance configurations, instance types, instance nicknames, resource groups, public IP addresses, private IP addresses, and zones, is updated with a 48-hour delay.

  • Billing data does not include the costs of attached resources, such as domain names, buckets, and elastic IP addresses (EIPs), for products such as CDN, OSS, and Internet Shared Bandwidth. To view statistics that include data for attached resources, go to Split Bill.

  • For Alibaba Cloud Communications products, detailed data is available only from June 2020 onwards. For HiChina products, such as Domain Names and trademarks, detailed data is available only from November 2020 onwards.

  • Each account is limited to 10 queries per second. If a timeout occurs, retry the request.

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

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

bss:QueryAccountBill

get

*All Resource

*

  • bssapi:ProductCode

  • bssapi:ProductType

None

Request parameters

Parameter

Type

Required

Description

Example

BillingCycle

string

Yes

The billing date. Format: YYYY-MM.

2018-07

PageNum

integer

No

The page number. The default value is 1.

1

PageSize

integer

No

The number of entries per page. The default value is 20. The maximum value is 300.

20

IsGroupByProduct

boolean

No

Specifies whether to aggregate the results by product code.

  • true: Results are aggregated by product code.

  • false: Results are not aggregated by product code.

Default value: false.

false

ProductCode

string

No

The product code.

rds

BillOwnerId

integer

No

The ID of the account that owns and actually uses the resource.

122

Granularity

string

No

The granularity for querying the bill. Valid values:

  • MONTHLY: Queries bills on a monthly basis. Corresponds to the monthly bills in Expenses & Costs > Bills > Bill Details.

  • DAILY: Queries bills on a daily basis. Corresponds to the daily bills in Expenses & Costs > Bills > Bill Details.

Note

If you set Granularity to DAILY, you must also specify the BillingDate parameter.

MONTHLY

BillingDate

string

No

The billing date. This parameter is required only when you set Granularity to DAILY. Format: YYYY-MM-DD.

2021-06-01

Response elements

Element

Type

Description

Example

object

Code

string

The status code.

Success

Message

string

The error message.

Successful!

RequestId

string

The request ID.

3BFC23FE-A182-4D96-A1E4-7521B30B8E43

Success

boolean

Indicates whether the request was successful.

true

Data

object

The returned data.

PageNum

integer

The page number.

1

BillingCycle

string

The billing cycle. Format: YYYY-MM.

2020-03

AccountID

string

The account ID.

1857xxxxx489

PageSize

integer

The number of entries displayed per page.

20

TotalCount

integer

The total number of records.

1

AccountName

string

The account name.

test@test.aliyunid.com

Items

object

Item

array<object>

The bill details.

object

PipCode

string

The product code. This is the same as the product code in the User Center.

rds

BillingDate

string

The billing date.

2021-03-01

ProductName

string

The product name.

Note

This parameter is returned only when IsGroupByProduct is set to true.

rds

OwnerName

string

The AccountName of the resource owner. This is used in multi-account payment scenarios.

aligzncloudtest2

Currency

string

The currency. Valid values:

  • CNY

  • USD

  • JPY

CNY

BillAccountName

string

The name of the account to which the bill belongs.

test@test.aliyunid.com

SubscriptionType

string

The subscription type of the product.

  • Subscription: subscription

  • PayAsYouGo: pay-as-you-go

Note

This parameter is returned only when IsGroupByProduct is set to true.

PayAsYouGo

BizType

string

The business type.

trusteeship

OwnerID

string

The AccountID of the resource owner. This is used in multi-account payment scenarios.

325434254

DeductedByCoupons

number

The amount deducted by coupons.

0

BillAccountID

string

The ID of the account to which the bill belongs.

1857xxxxx489

InvoiceDiscount

number

The discount amount.

0

CostUnit

string

The cost center.

未分配

PretaxGrossAmount

number

The pretax gross amount.

0

ProductCode

string

The product code.

Note

This parameter is returned only when IsGroupByProduct is set to true.

rds

Examples

Success response

JSON format

{
  "Code": "Success",
  "Message": "Successful!",
  "RequestId": "3BFC23FE-A182-4D96-A1E4-7521B30B8E43",
  "Success": true,
  "Data": {
    "PageNum": 1,
    "BillingCycle": "2020-03",
    "AccountID": "1857xxxxx489",
    "PageSize": 20,
    "TotalCount": 1,
    "AccountName": "test@test.aliyunid.com",
    "Items": {
      "Item": [
        {
          "PipCode": "rds",
          "BillingDate": "2021-03-01",
          "ProductName": "rds",
          "OwnerName": "aligzncloudtest2",
          "Currency": "CNY",
          "BillAccountName": "test@test.aliyunid.com",
          "SubscriptionType": "PayAsYouGo",
          "BizType": "trusteeship",
          "OwnerID": "325434254",
          "DeductedByCoupons": 0,
          "BillAccountID": "1857xxxxx489",
          "InvoiceDiscount": 0,
          "CostUnit": "未分配",
          "PretaxGrossAmount": 0,
          "ProductCode": "rds"
        }
      ]
    }
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.