查询计费用量记录¶
分页查询账户的计费用量、应用价格和折扣后费用。
GET https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/usage-records
调用前准备¶
请求示例¶
将示例中的 $MOI_PERSONAL_ACCESS_TOKEN 和 $ACCOUNT_ID 分别替换为个人访问令牌和所选账户的 ID。
curl -X GET \
"https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/usage-records?page_size=2" \
-H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN"
路径参数¶
参数 |
类型 |
是否必填 |
说明 |
|---|---|---|---|
|
string |
是 |
目标账户的 ID,取自“查询当前账户”响应中的 |
查询参数¶
参数 |
类型 |
是否必填 |
说明 |
|---|---|---|---|
|
string |
否 |
按记录创建时间筛选的起点,包含该时刻;支持 RFC 3339、 |
|
string |
否 |
按记录创建时间筛选的终点,不包含该时刻。日期值扩展到所选日期的次日零点。 |
|
string |
否 |
解析日期值的 IANA 时区;省略时使用 UTC。 |
|
string |
否 |
按入账账期筛选,格式为 |
|
string |
否 |
按计量项代码筛选。 |
|
string |
否 |
按计费项代码筛选;与 |
|
string |
否 |
按用量事件所属工作区筛选。 |
|
string |
否 |
按用量记录状态筛选;查询已扣费记录时使用 charged。省略时不按状态筛选。 |
|
string |
否 |
按账户归属主体类型筛选。 |
|
string |
否 |
按账户归属主体 ID 筛选。 |
|
string |
否 |
搜索计费用量记录 ID、用量事件 ID、计量项代码或事件键,不区分大小写。 |
|
string |
否 |
q 的兼容参数,仅在 q 为空时使用。 |
|
integer |
否 |
每页数量,1–100;省略、非正数或大于 100 时使用 50。 |
|
string |
否 |
下一页标记。首次请求省略;后续使用响应的 |
成功响应¶
请求成功时返回 HTTP 200 和符合筛选条件的计费用量记录。
{
"items": [
{
"rated_usage_record_id": "rated_record_example",
"usage_event_id": "usage_event_example",
"billing_account_id": "billing_account_example",
"billing_account_owner_id": "owner_example",
"billing_account_display_name": "Example account",
"meter_code": "meter_example",
"billing_item_code": "meter_example",
"billing_item_display_name": "Example usage",
"unit": "token",
"price_item_id": "price_example",
"price_dimension_key": "dimension_example",
"price_snapshot_json": "{}",
"quantity": "1000",
"unit_price_credit": "0.001000000000",
"gross_credit": "1.000000000000",
"discount_credit": "0.100000000000",
"net_credit": "0.900000000000",
"period": "2026-09",
"source_period": "2026-09",
"posting_period": "2026-09",
"status": "charged",
"source_request_ids": [
"request_example"
],
"source_request_count": 1,
"source_period_start": "2026-09-01T00:00:00Z",
"source_period_end": "2026-09-01T00:10:00Z",
"created_at": 1788739200
}
],
"total": 1,
"next_page_token": ""
}
字段 |
类型 |
说明 |
|---|---|---|
|
array of object |
本次返回的记录。 |
|
string |
计费用量记录 ID。 |
|
string |
来源用量事件 ID。 |
|
string |
Billing 账户 ID。 |
|
string |
账户归属主体 ID,可能省略。 |
|
string |
账户显示名称,可能省略。 |
|
string |
关联的 Credit 预留 ID,存在时返回。 |
|
string |
计量项代码。 |
|
string |
计费项代码。 |
|
string |
计费项显示名称。 |
|
string |
用量计量单位。 |
|
string |
应用的价格项 ID,可能省略。 |
|
string |
价格维度标识,可能省略。 |
|
string |
计费时的价格快照,以 JSON 字符串返回,可能省略。 |
|
string |
用量,使用对应计费项的计量单位。 |
|
string |
每计量单位的 Credit 单价。 |
|
string |
折扣前费用,单位为 Credit。 |
|
string |
折扣抵扣,单位为 Credit。 |
|
string |
折扣后费用,单位为 Credit。 |
|
string |
用量账期,格式为 |
|
string |
用量来源账期。 |
|
string |
入账账期。 |
|
string |
计费用量记录状态。 |
|
array of string |
来源请求 ID,可能省略。 |
|
integer |
来源请求数,可能省略。 |
|
string |
来源用量时间范围起点,可能省略。 |
|
string |
来源用量时间范围终点,可能省略。 |
|
integer |
创建时间,Unix 秒。 |
|
integer |
符合筛选条件的总记录数。 |
|
string |
下一页标记;空字符串表示没有下一页。 |
字段路径中的 [] 表示数组中的每一项。例如,items[].rated_usage_record_id 表示数组中每一项的对应字段。
继续查询时,将响应中的 next_page_token 保存为 $NEXT_PAGE_TOKEN,保持筛选条件不变。标记为空时停止翻页。
curl -X GET \
"https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/usage-records?page_size=2&page_token=$NEXT_PAGE_TOKEN" \
-H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN"
错误响应¶
缺少认证信息时返回 HTTP 401,请提供有效的个人访问令牌。
{
"code": "unauthenticated",
"message": "missing bearer token",
"error": "missing bearer token"
}
字段 |
类型 |
说明 |
|---|---|---|
|
string |
错误代码。 |
|
string |
错误说明。 |
|
string |
兼容错误说明,与 message 内容相同。 |
选择入账账期¶
选择一条计费用量记录,保存其 billing_account_id 和 posting_period,用于查询月账单用量明细。