> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hitheo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 打开账单门户

> 为用户的个人账单或组织的团队账单生成一个短期有效的客户门户 URL。

打开托管账单门户，供用户更新已保存的银行卡、查看发票或下载收据。可以将门户范围限定为个人账单客户，也可以限定为团队（组织）账单客户。

## 身份验证

需要携带具有 `billing` 权限范围的 Bearer 令牌。参见
[身份验证](/api-reference/authentication)。

## 请求体

<ParamField body="scope" type="string">
  `"user"`（个人身份下的默认值）或 `"org"`（当调用方处于某个团队内且拥有
  `manageBilling` 权限时的默认值）。团队范围还要求该团队已预先绑定付款方式——
  在为账单充值之前尝试访问团队门户的调用方，会收到 409
  `team_billing_setup_required` 错误，而不是正常响应。
</ParamField>

## 示例

```bash curl theme={null}
curl -X POST "https://api.hitheo.ai/api/v1/billing/portal" \
  -H "Authorization: Bearer $THEO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "scope": "org" }'
```

```typescript SDK theme={null}
const { portal_url } = await theo.billingPortal({ scope: "org" });
window.open(portal_url, "_blank");
```

## 响应

```json theme={null}
{
  "portal_url": "https://portal.hitheo.ai/session/...",
  "scope": "org"
}
```

## 错误

| 状态码 | 错误码 | 含义 |
| - | - | - |
| 400 | `org_context_required` | 请求了 `scope: "org"`，但当前没有活跃团队。 |
| 403 | `permission_denied` | 调用方在当前活跃团队中不具备 `manageBilling` 权限。 |
| 409 | `team_billing_setup_required` | 团队尚未绑定付款方式——请先完成一次结账。 |
| 503 | `billing_unavailable` | 当前部署未配置账单功能。 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.