All Products
Search
Document Center

Expenses and Costs:QueryCostUnitResource

Last Updated:Aug 28, 2026

Queries the resource instances that are allocated to a cost center. If the unitId parameter is set to 0, the unallocated primary resource instances and sub-resource instances are queried.

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:QueryCostUnitResource

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

OwnerUid

integer

Yes

The user ID of the cost center owner.

23453245

UnitId

integer

Yes

The ID of the cost center.

235325

PageNum

integer

No

The number of the page to return.

1

PageSize

integer

No

The number of entries to return on each page.

20

Response elements

Element

Type

Description

Example

object

Code

string

The status code.

Success

Message

string

The error message.

Successful!

RequestId

string

The ID of the request.

04332CB7-9A57-4461-97E0-02821D044414

Success

boolean

Indicates whether the request was successful.

true

Data

object

The data returned.

PageNum

integer

The page number of the returned page.

1

PageSize

integer

The number of entries returned per page.

20

TotalCount

integer

The total number of returned entries.

12

ResourceInstanceDtoList

array<object>

The resource instances.

object

CommodityCode

string

The product code of the resource.

rds

ResourceUserName

string

The username of the resource owner.

test@test.aliyun.com

CommodityName

string

The commodity name of the resource.

ApsaraDB

ResourceUserId

integer

The user ID of the resource owner.

2424242134

ApportionName

string

The split name of the resource.

test

ApportionCode

string

The split code of the resource.

test

ResourceType

string

The type of the resource.

FPT_ossbag_absolute_Storage_bj

ResourceNick

string

The custom name of the resource.

testResource

ResourceTag

string

The tags of the resource.

testResource

ResourceId

string

The instance ID of the resource.

OSSBAG-cn-v0h1s4hma018

ResourceGroup

string

The resource group to which the resource belongs.

Default Resource Group

RelatedResources

string

The resources related to the resource instance.

oss

ResourceStatus

string

The status of the resource.

Available

PipCode

string

The code of the service. The code is the same as that in Cost Center.

rds

ResourceSource

string

The source of the resource. Value:

  • AUTO_ALLOCATE

  • MANUAL_ALLOCATE

MANUAL_ALLOCATE

CostUnit

object

The information about the cost center.

ParentUnitId

integer

The ID of the parent cost center. A value of -1 indicates the root cost center.

23421

UnitName

string

The name of the cost center.

test

UnitId

integer

The ID of the cost center.

123412

OwnerUid

integer

The user ID of the cost center owner.

321432

CostUnitStatisInfo

object

The statistical information about the cost center.

TotalResourceCount

integer

The total number of resource instances, including resource instances of sub-cost centers, in the cost center.

3

ResourceCount

integer

The number of resource instances in the cost center.

1

TotalUserCount

integer

The total number of the associated accounts, including associated accounts of sub-cost centers, in the cost center.

2

SubUnitCount

integer

The number of sub-cost centers in the cost center.

2

ResourceGroupCount

integer

The number of resource groups in the cost center.

1

TotalResourceGroupCount

integer

The total number of resource groups, including resource groups of sub-cost centers, in the cost center.

2

UserCount

integer

The number of sub-cost centers in the cost center.

0

Examples

Success response

JSON format

{
  "Code": "Success",
  "Message": "Successful!",
  "RequestId": "04332CB7-9A57-4461-97E0-02821D044414",
  "Success": true,
  "Data": {
    "PageNum": 1,
    "PageSize": 20,
    "TotalCount": 12,
    "ResourceInstanceDtoList": [
      {
        "CommodityCode": "rds",
        "ResourceUserName": "test@test.aliyun.com",
        "CommodityName": "ApsaraDB\n",
        "ResourceUserId": 2424242134,
        "ApportionName": "test",
        "ApportionCode": "test",
        "ResourceType": "FPT_ossbag_absolute_Storage_bj",
        "ResourceNick": "testResource",
        "ResourceTag": "testResource",
        "ResourceId": "OSSBAG-cn-v0h1s4hma018",
        "ResourceGroup": "Default Resource Group\n",
        "RelatedResources": "oss",
        "ResourceStatus": "Available",
        "PipCode": "rds",
        "ResourceSource": "MANUAL_ALLOCATE"
      }
    ],
    "CostUnit": {
      "ParentUnitId": 23421,
      "UnitName": "test",
      "UnitId": 123412,
      "OwnerUid": 321432
    },
    "CostUnitStatisInfo": {
      "TotalResourceCount": 3,
      "ResourceCount": 1,
      "TotalUserCount": 2,
      "SubUnitCount": 2,
      "ResourceGroupCount": 1,
      "TotalResourceGroupCount": 2,
      "UserCount": 0
    }
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.