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

# 计费

> 查看计费摘要、发票、交易和套餐操作。

# 计费

查看计费摘要、发票、交易和套餐操作。

<script src="/locale-bridge.js" />

示例使用 A2A 代码模式。MCP 通过 `execute` 工具公开相同的代码模式。

## 函数

### `billing.current_plan.get`

```text theme={null}
billing.current_plan.get(account_id: str) -> BillingResult
```

计费: `billing.current_plan.get`.

| 属性        | 值                                                           | 属性       | 值              |
| --------- | ----------------------------------------------------------- | -------- | -------------- |
| 所需权限      | `billing.view`                                              | 需要身份验证   | `是`            |
| 执行模式      | `sync`                                                      | 能力       | `billing.view` |
| 资源类型      | `account`                                                   | 资源 ID 字段 | `account_id`   |
| 公共 API 路由 | `GET /v1/public/accounts/{account_id}/billing/current-plan` |          |                |

<AccordionGroup>
  <Accordion title="参数">
    | 名称           | 类型    | 必需 |
    | ------------ | ----- | -- |
    | `account_id` | `str` | 是  |
  </Accordion>

  <Accordion title="返回值">
    | 字段                | 类型     | 必需 |
    | ----------------- | ------ | -- |
    | `billing_period`  | `str`  | 是  |
    | `currency`        | `str`  | 是  |
    | `plan_id`         | `str`  | 是  |
    | `plan_name`       | `str`  | 是  |
    | `price`           | `str`  | 是  |
    | `status`          | `str`  | 是  |
    | `can_cancel_plan` | `bool` | 否  |
    | `can_change_plan` | `bool` | 否  |
  </Accordion>

  <Accordion title="A2A 示例">
    请求:

    ```json theme={null}
    {
      "request_id": "example",
      "session_id": "session_123",
      "code": "billing.current_plan.get(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\")"
    }
    ```

    响应:

    ```json theme={null}
    {
      "request_id": "example",
      "status": "completed",
      "result": {
        "last_value": true
      },
      "responses": [
        {
          "index": 0,
          "function": "billing.current_plan.get",
          "status": "completed",
          "result": true
        }
      ],
      "complexity_score": 1
    }
    ```
  </Accordion>

  <Accordion title="MCP 示例">
    请求:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "method": "tools/call",
      "params": {
        "name": "hybridbox_execute",
        "arguments": {
          "code": "billing.current_plan.get(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\")"
        }
      }
    }
    ```

    响应:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "result": {
        "content": [
          {
            "type": "text",
            "text": "{\n  \"request_id\": \"example\",\n  \"status\": \"completed\",\n  \"result\": {\n    \"last_value\": true\n  },\n  \"responses\": [\n    {\n      \"index\": 0,\n      \"function\": \"billing.current_plan.get\",\n      \"status\": \"completed\",\n      \"result\": true\n    }\n  ],\n  \"complexity_score\": 1\n}"
          }
        ],
        "isError": false
      }
    }
    ```
  </Accordion>
</AccordionGroup>

### `billing.invoices.list`

```text theme={null}
billing.invoices.list(account_id: str, page?: int, page_size?: int) -> Page[BillingResult]
```

计费: `billing.invoices.list`.

| 属性        | 值                                                       | 属性       | 值              |
| --------- | ------------------------------------------------------- | -------- | -------------- |
| 所需权限      | `billing.view`                                          | 需要身份验证   | `是`            |
| 执行模式      | `sync`                                                  | 能力       | `billing.view` |
| 资源类型      | `account`                                               | 资源 ID 字段 | `account_id`   |
| 公共 API 路由 | `GET /v1/public/accounts/{account_id}/billing/invoices` |          |                |

<AccordionGroup>
  <Accordion title="参数">
    | 名称           | 类型    | 必需 |
    | ------------ | ----- | -- |
    | `account_id` | `str` | 是  |
    | `page`       | `int` | 否  |
    | `page_size`  | `int` | 否  |
  </Accordion>

  <Accordion title="返回值">
    | 字段          | 类型                                                                                                       | 必需 |
    | ----------- | -------------------------------------------------------------------------------------------------------- | -- |
    | `items`     | `[{"amount": str, "currency": str, "date": str, "download_url": str \| null, "id": str, "status": str}]` | 是  |
    | `page`      | `int`                                                                                                    | 是  |
    | `page_size` | `int`                                                                                                    | 是  |
    | `total`     | `int`                                                                                                    | 是  |
  </Accordion>

  <Accordion title="A2A 示例">
    请求:

    ```json theme={null}
    {
      "request_id": "example",
      "session_id": "session_123",
      "code": "billing.invoices.list(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\", page=123, page_size=123)"
    }
    ```

    响应:

    ```json theme={null}
    {
      "request_id": "example",
      "status": "completed",
      "result": {
        "last_value": "<string>"
      },
      "responses": [
        {
          "index": 0,
          "function": "billing.invoices.list",
          "status": "completed",
          "result": "<string>"
        }
      ],
      "complexity_score": 1
    }
    ```
  </Accordion>

  <Accordion title="MCP 示例">
    请求:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "method": "tools/call",
      "params": {
        "name": "hybridbox_execute",
        "arguments": {
          "code": "billing.invoices.list(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\", page=123, page_size=123)"
        }
      }
    }
    ```

    响应:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "result": {
        "content": [
          {
            "type": "text",
            "text": "{\n  \"request_id\": \"example\",\n  \"status\": \"completed\",\n  \"result\": {\n    \"last_value\": \"<string>\"\n  },\n  \"responses\": [\n    {\n      \"index\": 0,\n      \"function\": \"billing.invoices.list\",\n      \"status\": \"completed\",\n      \"result\": \"<string>\"\n    }\n  ],\n  \"complexity_score\": 1\n}"
          }
        ],
        "isError": false
      }
    }
    ```
  </Accordion>
</AccordionGroup>

### `billing.plan.cancel`

```text theme={null}
billing.plan.cancel(account_id: str, cancel_at_period_end?: bool, cancel_immediately?: bool) -> BillingResult
```

计费: `billing.plan.cancel`.

| 属性        | 值                                                           | 属性       | 值                |
| --------- | ----------------------------------------------------------- | -------- | ---------------- |
| 所需权限      | `billing.manage`                                            | 需要身份验证   | `是`              |
| 执行模式      | `sync`                                                      | 能力       | `billing.manage` |
| 资源类型      | `account`                                                   | 资源 ID 字段 | `account_id`     |
| 公共 API 路由 | `POST /v1/public/accounts/{account_id}/billing/cancel-plan` |          |                  |

<AccordionGroup>
  <Accordion title="参数">
    | 名称                     | 类型     | 必需 |
    | ---------------------- | ------ | -- |
    | `account_id`           | `str`  | 是  |
    | `cancel_at_period_end` | `bool` | 否  |
    | `cancel_immediately`   | `bool` | 否  |
  </Accordion>

  <Accordion title="返回值">
    | 字段                 | 类型             | 必需 |
    | ------------------ | -------------- | -- |
    | `status`           | `str`          | 是  |
    | `account_status`   | `str \| null`  | 否  |
    | `effective_at`     | `str \| null`  | 否  |
    | `eligible`         | `bool \| null` | 否  |
    | `previous_plan_id` | `str \| null`  | 否  |
    | `target_plan_id`   | `str \| null`  | 否  |
  </Accordion>

  <Accordion title="A2A 示例">
    请求:

    ```json theme={null}
    {
      "request_id": "example",
      "session_id": "session_123",
      "code": "billing.plan.cancel(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\", cancel_at_period_end=true, cancel_immediately=true)"
    }
    ```

    响应:

    ```json theme={null}
    {
      "request_id": "example",
      "status": "completed",
      "result": {
        "last_value": "<string>"
      },
      "responses": [
        {
          "index": 0,
          "function": "billing.plan.cancel",
          "status": "completed",
          "result": "<string>"
        }
      ],
      "complexity_score": 1
    }
    ```
  </Accordion>

  <Accordion title="MCP 示例">
    请求:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "method": "tools/call",
      "params": {
        "name": "hybridbox_execute",
        "arguments": {
          "code": "billing.plan.cancel(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\", cancel_at_period_end=true, cancel_immediately=true)"
        }
      }
    }
    ```

    响应:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "result": {
        "content": [
          {
            "type": "text",
            "text": "{\n  \"request_id\": \"example\",\n  \"status\": \"completed\",\n  \"result\": {\n    \"last_value\": \"<string>\"\n  },\n  \"responses\": [\n    {\n      \"index\": 0,\n      \"function\": \"billing.plan.cancel\",\n      \"status\": \"completed\",\n      \"result\": \"<string>\"\n    }\n  ],\n  \"complexity_score\": 1\n}"
          }
        ],
        "isError": false
      }
    }
    ```
  </Accordion>
</AccordionGroup>

### `billing.plan.change`

```text theme={null}
billing.plan.change(account_id: str, plan_id: "smtp_per_mailbox" | "smtp_per_proxy", effective_date?: str | null) -> BillingResult
```

计费: `billing.plan.change`.

| 属性        | 值                                                           | 属性       | 值                |
| --------- | ----------------------------------------------------------- | -------- | ---------------- |
| 所需权限      | `billing.manage`                                            | 需要身份验证   | `是`              |
| 执行模式      | `sync`                                                      | 能力       | `billing.manage` |
| 资源类型      | `account`                                                   | 资源 ID 字段 | `account_id`     |
| 公共 API 路由 | `POST /v1/public/accounts/{account_id}/billing/change-plan` |          |                  |

<AccordionGroup>
  <Accordion title="参数">
    | 名称               | 类型                                       | 必需 |
    | ---------------- | ---------------------------------------- | -- |
    | `account_id`     | `str`                                    | 是  |
    | `plan_id`        | `"smtp_per_mailbox" \| "smtp_per_proxy"` | 是  |
    | `effective_date` | `str \| null`                            | 否  |
  </Accordion>

  <Accordion title="返回值">
    | 字段                 | 类型             | 必需 |
    | ------------------ | -------------- | -- |
    | `status`           | `str`          | 是  |
    | `account_status`   | `str \| null`  | 否  |
    | `effective_at`     | `str \| null`  | 否  |
    | `eligible`         | `bool \| null` | 否  |
    | `previous_plan_id` | `str \| null`  | 否  |
    | `target_plan_id`   | `str \| null`  | 否  |
  </Accordion>

  <Accordion title="A2A 示例">
    请求:

    ```json theme={null}
    {
      "request_id": "example",
      "session_id": "session_123",
      "code": "billing.plan.change(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\", plan_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\", effective_date=\"<string>\")"
    }
    ```

    响应:

    ```json theme={null}
    {
      "request_id": "example",
      "status": "completed",
      "result": {
        "last_value": "<string>"
      },
      "responses": [
        {
          "index": 0,
          "function": "billing.plan.change",
          "status": "completed",
          "result": "<string>"
        }
      ],
      "complexity_score": 1
    }
    ```
  </Accordion>

  <Accordion title="MCP 示例">
    请求:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "method": "tools/call",
      "params": {
        "name": "hybridbox_execute",
        "arguments": {
          "code": "billing.plan.change(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\", plan_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\", effective_date=\"<string>\")"
        }
      }
    }
    ```

    响应:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "result": {
        "content": [
          {
            "type": "text",
            "text": "{\n  \"request_id\": \"example\",\n  \"status\": \"completed\",\n  \"result\": {\n    \"last_value\": \"<string>\"\n  },\n  \"responses\": [\n    {\n      \"index\": 0,\n      \"function\": \"billing.plan.change\",\n      \"status\": \"completed\",\n      \"result\": \"<string>\"\n    }\n  ],\n  \"complexity_score\": 1\n}"
          }
        ],
        "isError": false
      }
    }
    ```
  </Accordion>
</AccordionGroup>

### `billing.transactions.list`

```text theme={null}
billing.transactions.list(account_id: str, page?: int, page_size?: int) -> Page[BillingResult]
```

计费: `billing.transactions.list`.

| 属性        | 值                                                           | 属性       | 值              |
| --------- | ----------------------------------------------------------- | -------- | -------------- |
| 所需权限      | `billing.view`                                              | 需要身份验证   | `是`            |
| 执行模式      | `sync`                                                      | 能力       | `billing.view` |
| 资源类型      | `account`                                                   | 资源 ID 字段 | `account_id`   |
| 公共 API 路由 | `GET /v1/public/accounts/{account_id}/billing/transactions` |          |                |

<AccordionGroup>
  <Accordion title="参数">
    | 名称           | 类型    | 必需 |
    | ------------ | ----- | -- |
    | `account_id` | `str` | 是  |
    | `page`       | `int` | 否  |
    | `page_size`  | `int` | 否  |
  </Accordion>

  <Accordion title="返回值">
    | 字段          | 类型                                                                                                                                                                                         | 必需 |
    | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -- |
    | `page`      | `int`                                                                                                                                                                                      | 是  |
    | `page_size` | `int`                                                                                                                                                                                      | 是  |
    | `total`     | `int`                                                                                                                                                                                      | 是  |
    | `items`     | `[{"amount": str, "currency": str, "direction": str, "effective_at": str, "status": str, "transaction_id": str, "type": str, "balance_after"?: str \| null, "description"?: str \| null}]` | 否  |
  </Accordion>

  <Accordion title="A2A 示例">
    请求:

    ```json theme={null}
    {
      "request_id": "example",
      "session_id": "session_123",
      "code": "billing.transactions.list(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\", page=123, page_size=123)"
    }
    ```

    响应:

    ```json theme={null}
    {
      "request_id": "example",
      "status": "completed",
      "result": {
        "last_value": 123
      },
      "responses": [
        {
          "index": 0,
          "function": "billing.transactions.list",
          "status": "completed",
          "result": 123
        }
      ],
      "complexity_score": 1
    }
    ```
  </Accordion>

  <Accordion title="MCP 示例">
    请求:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "method": "tools/call",
      "params": {
        "name": "hybridbox_execute",
        "arguments": {
          "code": "billing.transactions.list(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\", page=123, page_size=123)"
        }
      }
    }
    ```

    响应:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "result": {
        "content": [
          {
            "type": "text",
            "text": "{\n  \"request_id\": \"example\",\n  \"status\": \"completed\",\n  \"result\": {\n    \"last_value\": 123\n  },\n  \"responses\": [\n    {\n      \"index\": 0,\n      \"function\": \"billing.transactions.list\",\n      \"status\": \"completed\",\n      \"result\": 123\n    }\n  ],\n  \"complexity_score\": 1\n}"
          }
        ],
        "isError": false
      }
    }
    ```
  </Accordion>
</AccordionGroup>

### `billing.wallet_balance.get`

```text theme={null}
billing.wallet_balance.get(account_id: str) -> BillingResult
```

计费: `billing.wallet_balance.get`.

| 属性        | 值                                                             | 属性       | 值              |
| --------- | ------------------------------------------------------------- | -------- | -------------- |
| 所需权限      | `billing.view`                                                | 需要身份验证   | `是`            |
| 执行模式      | `sync`                                                        | 能力       | `billing.view` |
| 资源类型      | `account`                                                     | 资源 ID 字段 | `account_id`   |
| 公共 API 路由 | `GET /v1/public/accounts/{account_id}/billing/wallet-balance` |          |                |

<AccordionGroup>
  <Accordion title="参数">
    | 名称           | 类型    | 必需 |
    | ------------ | ----- | -- |
    | `account_id` | `str` | 是  |
  </Accordion>

  <Accordion title="返回值">
    | 字段                | 类型    | 必需 |
    | ----------------- | ----- | -- |
    | `accrued_charges` | `str` | 是  |
    | `balance`         | `str` | 是  |
    | `currency`        | `str` | 是  |
    | `net_balance`     | `str` | 是  |
  </Accordion>

  <Accordion title="A2A 示例">
    请求:

    ```json theme={null}
    {
      "request_id": "example",
      "session_id": "session_123",
      "code": "billing.wallet_balance.get(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\")"
    }
    ```

    响应:

    ```json theme={null}
    {
      "request_id": "example",
      "status": "completed",
      "result": {
        "last_value": {
          "accrued_charges": "<string>",
          "balance": "<string>",
          "currency": "<string>",
          "net_balance": "<string>"
        }
      },
      "responses": [
        {
          "index": 0,
          "function": "billing.wallet_balance.get",
          "status": "completed",
          "result": {
            "accrued_charges": "<string>",
            "balance": "<string>",
            "currency": "<string>",
            "net_balance": "<string>"
          }
        }
      ],
      "complexity_score": 1
    }
    ```
  </Accordion>

  <Accordion title="MCP 示例">
    请求:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "method": "tools/call",
      "params": {
        "name": "hybridbox_execute",
        "arguments": {
          "code": "billing.wallet_balance.get(account_id=\"3c90c3cc-0d44-4b50-8888-8dd25736052a\")"
        }
      }
    }
    ```

    响应:

    ```json theme={null}
    {
      "jsonrpc": "2.0",
      "id": "example",
      "result": {
        "content": [
          {
            "type": "text",
            "text": "{\n  \"request_id\": \"example\",\n  \"status\": \"completed\",\n  \"result\": {\n    \"last_value\": {\n      \"accrued_charges\": \"<string>\",\n      \"balance\": \"<string>\",\n      \"currency\": \"<string>\",\n      \"net_balance\": \"<string>\"\n    }\n  },\n  \"responses\": [\n    {\n      \"index\": 0,\n      \"function\": \"billing.wallet_balance.get\",\n      \"status\": \"completed\",\n      \"result\": {\n        \"accrued_charges\": \"<string>\",\n        \"balance\": \"<string>\",\n        \"currency\": \"<string>\",\n        \"net_balance\": \"<string>\"\n      }\n    }\n  ],\n  \"complexity_score\": 1\n}"
          }
        ],
        "isError": false
      }
    }
    ```
  </Accordion>
</AccordionGroup>
