# 账户账单

查询账户级的账单汇总，支持月粒度与日粒度，对应控制台「月度账单」页面及其日详情。

<span style="display:inline-block;background:#e6f8ea;color:#fca130;border-radius:6px;padding:2px 8px;font-weight:bold;font-family:monospace;margin-right:8px;">POST</span>
`https://dashboard.avavox.com/open/api/v1/bills/account/query`

::: warning 数据范围随授权范围变化
授权范围为「全部空间」的 Key，返回的是企业下**全部空间**的汇总；授权范围为「仅当前空间」的 Key，返回的是其**绑定空间**的汇总。两者响应结构完全一致，均不含空间维度字段。请先通过 [Key 信息](https://avavox.com/docs/developer/bill/key-info.html) 接口确认授权范围后再消费数据，避免把单空间数据误当作企业总账。
:::

## 请求头

<span style="font-family:monospace; color:#3451b2; ">Authorization </span> <code style="background:#f0f0f0; ">string</code> <span style="background:#dc3545; color:white; padding:2px 6px; border-radius:3px; font-size:12px;">必填</span>

- 填写格式：`Authorization: Bearer <App Key>`
- `<App Key>` 为控制台「App Key 管理」页面生成的 Key。
- 获取方式详见：[《App Key 创建与管理》](https://avavox.com/docs/developer/app-key.html)。

## 请求体参数

本接口仅使用[公共请求体参数](https://avavox.com/docs/developer/bill/#公共请求体参数)，无额外字段。

<span style="font-family:monospace; color:#3451b2;">granularity</span> <code style="background:#f0f0f0;">string</code> <span style="background:#28a745; color:white; padding:2px 6px; border-radius:3px; font-size:12px;">可选</span>

统计粒度，`month`（默认）或 `day`。

---

<span style="font-family:monospace; color:#3451b2;">start</span> <code style="background:#f0f0f0;">string</code> <span style="background:#dc3545; color:white; padding:2px 6px; border-radius:3px; font-size:12px;">必填</span>

起始时间。`month` 粒度传 `YYYY-MM`，`day` 粒度传 `YYYY-MM-DD`。

---

<span style="font-family:monospace; color:#3451b2;">end</span> <code style="background:#f0f0f0;">string</code> <span style="background:#dc3545; color:white; padding:2px 6px; border-radius:3px; font-size:12px;">必填</span>

结束时间，格式同 `start`。月粒度单次最大跨度 12 个月，日粒度最大 92 天。

---

<span style="font-family:monospace; color:#3451b2;">page</span> / <span style="font-family:monospace; color:#3451b2;">pageSize</span> <code style="background:#f0f0f0;">int</code> <span style="background:#28a745; color:white; padding:2px 6px; border-radius:3px; font-size:12px;">可选</span>

分页参数。`page` 从 1 开始，默认 `1`；`pageSize` 默认 `20`，最大 `100`。

## 响应数据

<span style="font-family:monospace; color:#3451b2;">code</span> <code style="background:#f0f0f0;">int</code>

状态码，200 为成功，其他状态均为失败。

---

<span style="font-family:monospace; color:#3451b2;">success</span> <code style="background:#f0f0f0;">boolean</code>

是否成功，`true` 表示成功，`false` 表示失败。

---

<span style="font-family:monospace; color:#3451b2;">message</span> <code style="background:#f0f0f0;">string</code>

描述信息。

---

<span style="font-family:monospace; color:#3451b2;">data</span> <code style="background:#f0f0f0;">object</code>

<details>
<summary>点击展开字段说明</summary>
<div style="margin: 16px 0; padding: 16px;  border-left: 1px solid #f0f0f0; border-radius: 6px;">

<span style="font-family:monospace; color:#3451b2;">total</span> <code style="background:#f0f0f0;">int</code>

符合条件的账单记录总数。

---

<span style="font-family:monospace; color:#3451b2;">page</span> <code style="background:#f0f0f0;">int</code>

当前页码。

---

<span style="font-family:monospace; color:#3451b2;">pageSize</span> <code style="background:#f0f0f0;">int</code>

每页条数。

---

<span style="font-family:monospace; color:#3451b2;">list</span> <code style="background:#f0f0f0;">array</code>

账单记录列表，每个账期一条。元素结构：

- `period`：账期，月粒度为 `YYYY-MM`，日粒度为 `YYYY-MM-DD`
- `billStatus`：出账状态，`SETTLED` / `UNSETTLED`
- `feeItems`：计费项列表，元素含 `itemCode`、`itemName`、`amount`、`points`
- `totalAmount`：合计金额（元，字符串，三位小数）
- `totalPoints`：合计积分（个）

完整字段说明见[账单记录的公共结构](https://avavox.com/docs/developer/bill/#账单记录的公共结构)。

</div>
</details>

## 请求示例

查询 2026 年 1 月至 8 月的月度账单：

```shell
curl -X POST --location 'https://dashboard.avavox.com/open/api/v1/bills/account/query' \
--header 'Authorization: Bearer $Key' \
--header 'Content-Type: application/json' \
--data '{
  "granularity": "month",
  "start": "2026-01",
  "end": "2026-08"
}'
```

查询 2026 年 8 月 1 日至 19 日的每日账单：

```shell
curl -X POST --location 'https://dashboard.avavox.com/open/api/v1/bills/account/query' \
--header 'Authorization: Bearer $Key' \
--header 'Content-Type: application/json' \
--data '{
  "granularity": "day",
  "start": "2026-08-01",
  "end": "2026-08-19"
}'
```

日粒度的响应结构与月粒度完全相同，仅 `period` 变为具体日期（如 `2026-08-17`），每日一条记录。

## 响应示例

```json
{
  "code": 200,
  "message": "操作成功",
  "success": true,
  "data": {
    "total": 8,
    "page": 1,
    "pageSize": 20,
    "list": [
      {
        "period": "2026-08",
        "billStatus": "UNSETTLED",
        "feeItems": [
          { "itemCode": "LINE",        "itemName": "线路",     "amount": "0.000", "points": 1410 },
          { "itemCode": "ROBOT",       "itemName": "机器人",   "amount": "0.000", "points": 1350 },
          { "itemCode": "SMS",         "itemName": "短信",     "amount": "0.000", "points": 0 },
          { "itemCode": "VOICE_CLONE", "itemName": "声音克隆", "amount": "0.000", "points": 0 },
          { "itemCode": "CONCURRENCY", "itemName": "并发",     "amount": "0.000", "points": 110000 },
          { "itemCode": "STORAGE",     "itemName": "存储",     "amount": "0.000", "points": 0 },
          { "itemCode": "DEBUG",       "itemName": "调试",     "amount": "0.000", "points": 150 },
          { "itemCode": "ADJUSTMENT",  "itemName": "资金调整", "amount": "0.000", "points": 0 }
        ],
        "totalAmount": "0.000",
        "totalPoints": 112910
      }
    ]
  }
}
```
