# 查询计费设置

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

读取账户的余额提醒、消费上限和自动充值设置。

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

## 调用前准备

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/settings" \
  -H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN"
```

## 路径参数

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

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

::::

## 成功响应

请求成功时返回 HTTP `200` 和账户当前的计费设置。

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

```json
{
  "billing_account_id": "billing_account_example",
  "balance_alert_enabled": false,
  "warning_threshold_credit": "10",
  "critical_threshold_credit": "5",
  "monthly_spend_limit_credit": "100",
  "pause_when_balance_zero": false,
  "new_account_rate_limit_enabled": false,
  "auto_recharge_enabled": false,
  "auto_recharge_mode": "notify_only",
  "auto_recharge_threshold_credit": "10",
  "auto_recharge_amount": "100.00",
  "auto_recharge_channel": "alipay",
  "auto_recharge_cooldown_hours": 24,
  "auto_recharge_monthly_limit_amount": "500.00",
  "notification_channels": [
    "email"
  ],
  "settings_version": 1,
  "updated_at": 1788739200
}
```

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

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `billing_account_id` | string | Billing 账户 ID。 |
| `balance_alert_enabled` | boolean | 是否启用余额提醒。 |
| `warning_threshold_credit` | string | 余额预警阈值，单位为 Credit。 |
| `critical_threshold_credit` | string | 余额严重告警阈值，单位为 Credit。 |
| `monthly_spend_limit_credit` | string | 月度消费上限，单位为 Credit。未设置时返回空字符串。 |
| `pause_when_balance_zero` | boolean | 余额归零时暂停使用的设置。 |
| `new_account_rate_limit_enabled` | boolean | 是否启用新账户速率限制。 |
| `auto_recharge_enabled` | boolean | 是否启用自动充值。 |
| `auto_recharge_mode` | string | 自动充值模式。 |
| `auto_recharge_threshold_credit` | string | 触发自动充值的余额阈值，单位为 Credit。 |
| `auto_recharge_amount` | string | 每次自动充值的支付金额，使用账户默认支付币种。 |
| `auto_recharge_channel` | string | 自动充值渠道。 |
| `auto_recharge_authorization_id` | string | 自动充值所使用的支付授权 ID，存在时返回。 |
| `auto_recharge_cooldown_hours` | integer | 两次自动充值之间的冷却时长，单位为小时。 |
| `auto_recharge_monthly_limit_amount` | string | 自动充值月度支付上限，使用账户默认支付币种。 |
| `notification_channels` | array of string | 通知渠道。 |
| `settings_version` | integer | 设置版本号。 |
| `updated_at` | integer | 更新时间，Unix 秒。 |
| `updated_by` | string | 最后修改设置的用户 ID，存在时返回。 |

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

## 错误响应

缺少认证信息时返回 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 内容相同。 |

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