# 查询账户概览

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

查询账户的可用 Credit、预留额度、透支额和近期消费。

```text
GET https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/overview
```

## 调用前准备

1. 准备计费账户所属用户的有效[个人访问令牌](../../../../../guides/genesis/api-keys.md#创建和管理个人访问令牌)。
2. 调用[查询当前账户](current.md)接口，获取目标账户的 ID。

## 请求示例

将示例中的 `$MOI_PERSONAL_ACCESS_TOKEN` 和 `$ACCOUNT_ID` 分别替换为个人访问令牌和所选账户的 ID。

```bash
curl -X GET \
  "https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/overview" \
  -H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN"
```

## 路径参数

::::{div} mo-api-parameter-table

| 参数 | 类型 | 是否必填 | 说明 |
| --- | --- | --- | --- |
| `accountID` | string | 是 | 目标账户的 ID，取自“查询当前账户”响应中的 `items[].billing_account_id`。 |

::::

## 成功响应

请求成功时返回 HTTP `200` 和账户的 Credit 余额、可用额度和近期消费。

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} 响应示例

```json
{
  "billing_account_id": "billing_account_example",
  "credit_balance": "100.000000000000",
  "credit_available": "90.000000000000",
  "credit_reserved": "10.000000000000",
  "credit_cash_balance": "80.000000000000",
  "credit_grant_balance": "20.000000000000",
  "credit_overdraft_balance": "0.000000000000",
  "outstanding_credit": "0.000000000000",
  "today_spend_credit": "1.000000000000",
  "month_spend_credit": "5.000000000000",
  "last_month_spend_credit": "20.000000000000",
  "estimated_days_remaining": "90",
  "billing_timezone": "Asia/Shanghai"
}
```

:::::
:::::{tab-item} 字段说明

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `billing_account_id` | string | Billing 账户 ID。 |
| `credit_balance` | string | Credit 余额。 |
| `credit_available` | string | 可用 Credit。 |
| `credit_reserved` | string | 已预留的 Credit。 |
| `credit_cash_balance` | string | 充值 Credit 余额。 |
| `credit_grant_balance` | string | 赠送 Credit 余额。 |
| `credit_overdraft_balance` | string | 透支钱包余额。 |
| `outstanding_credit` | string | 待偿还的透支 Credit。 |
| `today_spend_credit` | string | 计费时区当日已扣费 Credit。 |
| `month_spend_credit` | string | 计费时区本月已扣费 Credit。 |
| `last_month_spend_credit` | string | 计费时区上月已扣费 Credit。 |
| `estimated_days_remaining` | string | 按最近 7 天平均消费估算的可用天数；可用额度或消费不足以计算时返回 0。 |
| `billing_timezone` | string | 计算日、月消费的 IANA 时区。 |

:::::
::::::
:::::::

## 错误响应

缺少认证信息时返回 HTTP `401`，请提供有效的个人访问令牌。

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} 响应示例

```json
{
  "code": "unauthenticated",
  "message": "missing bearer token",
  "error": "missing bearer token"
}
```

:::::
:::::{tab-item} 字段说明

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `code` | string | 错误代码。 |
| `message` | string | 错误说明。 |
| `error` | string | 兼容错误说明，与 message 内容相同。 |

:::::
::::::
:::::::
