## ACME 账号 (`acme-accounts`)

自动签发证书用的 CA 账号(Let's Encrypt、ZeroSSL)。第一次签发时才向 CA 注册。

鉴权: 用户（部分参数仅管理员） · 文档: https://www-demo.kuxitong.com/zh/docs/api/acme-accounts

### GET `/api/v2/acme-accounts`

列出ACME 账号 · 鉴权: 用户（部分参数仅管理员）

查询参数:

| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| `page` | integer |  | 页码,从 1 开始。 默认: 1 |
| `page_size` | integer |  | 每页条数。 默认: 20 |
| `sort` | string |  | 排序字段,逗号分隔,前缀 `-` 表示降序,如 `-created_at,id`。 |
| `tenant_id` | integer |  | 仅管理员可用:按租户过滤。租户凭据调用时忽略,只返回本租户数据。 |
| `ca` | string |  | 只列这家 CA 的账号。 可选值: ["lets","zerossl"] |

```sh
curl "https://panel.example.com/api/v2/acme-accounts" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### POST `/api/v2/acme-accounts`

创建ACME 账号 · 鉴权: 用户（部分参数仅管理员）

查询参数:

| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| `tenant_id` | integer |  | 仅管理员可用:按租户过滤。租户凭据调用时忽略,只返回本租户数据。 |

请求体:

| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| `api_key` | string |  | ZeroSSL REST API Key 的掩码(`****abcd`);空 = 没配。Key 加密存库,不回明文。 |
| `ca` | string | 有 | 签发证书的 CA:lets = Let's Encrypt;zerossl = ZeroSSL。 可选值: ["lets","zerossl"] |
| `directory` | string |  | ACME 目录地址;空 = 主控配置 acme.directories 里该 CA 的地址(缺省为正式地址)。 |
| `eab_hmac` | string |  | 掩码(≥16 位露末 4 位 `****abcd`,否则 `********`),不回明文。 |
| `eab_kid` | string |  | EAB 密钥 id(ZeroSSL 用)。 |
| `email` | string |  | 邮箱 |
| `enabled` | boolean |  | 是否启用 |
| `name` | string | 有 | 名称 |
| `recheck` | boolean |  | 为 true 时重新检测已存的 API Key;通过则账号回到可用,并立即重签因账号不可用而等待的证书。 |

```sh
curl -X POST "https://panel.example.com/api/v2/acme-accounts" \
  -H "X-API-Key: $GOCDN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ca":"zerossl","eab_hmac":"${EAB_HMAC}","eab_kid":"kid-example","name":"zerossl-main"}'
```

### GET `/api/v2/acme-accounts/{id}`

获取ACME 账号 · 鉴权: 用户（部分参数仅管理员）

```sh
curl "https://panel.example.com/api/v2/acme-accounts/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### PUT `/api/v2/acme-accounts/{id}`

修改ACME 账号 · 鉴权: 用户（部分参数仅管理员）

请求体:

| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| `api_key` | string |  | ZeroSSL REST API Key 的掩码(`****abcd`);空 = 没配。Key 加密存库,不回明文。 |
| `ca` | string | 有 | 签发证书的 CA:lets = Let's Encrypt;zerossl = ZeroSSL。 可选值: ["lets","zerossl"] |
| `directory` | string |  | ACME 目录地址;空 = 主控配置 acme.directories 里该 CA 的地址(缺省为正式地址)。 |
| `eab_hmac` | string |  | 掩码(≥16 位露末 4 位 `****abcd`,否则 `********`),不回明文。 |
| `eab_kid` | string |  | EAB 密钥 id(ZeroSSL 用)。 |
| `email` | string |  | 邮箱 |
| `enabled` | boolean |  | 是否启用 |
| `name` | string | 有 | 名称 |
| `recheck` | boolean |  | 为 true 时重新检测已存的 API Key;通过则账号回到可用,并立即重签因账号不可用而等待的证书。 |

```sh
curl -X PUT "https://panel.example.com/api/v2/acme-accounts/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ca":"zerossl","eab_hmac":"${EAB_HMAC}","eab_kid":"kid-example","name":"zerossl-main"}'
```

### DELETE `/api/v2/acme-accounts/{id}`

删除ACME 账号 · 鉴权: 用户（部分参数仅管理员）

```sh
curl -X DELETE "https://panel.example.com/api/v2/acme-accounts/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

ACME 账号对象:

| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| `api_checked_at` | string |  | 最近一次检测 API Key 的时间。 (只读) |
| `api_error` | string |  | API Key 最近一次检测或签发遇到的账号级错误。 (只读) |
| `api_key` | string |  | ZeroSSL REST API Key 的掩码(`****abcd`);空 = 没配。Key 加密存库,不回明文。 (只读) |
| `api_state` | string |  | API Key 状态:none 没配;ok 可用;blocked 账号级错误(额度满、欠费、Key 被拒,6 小时后或重新检测通过再签);error Key 解不开须重填。 可选值: ["none","ok","blocked","error"] (只读) |
| `ca` | string |  | 签发证书的 CA:lets = Let's Encrypt;zerossl = ZeroSSL。 可选值: ["lets","zerossl"] |
| `created_at` | string |  | 创建时间 (只读) |
| `directory` | string |  | ACME 目录地址;空 = 主控配置 acme.directories 里该 CA 的地址(缺省为正式地址)。 |
| `eab_hmac` | string |  | 掩码(≥16 位露末 4 位 `****abcd`,否则 `********`),不回明文。 |
| `eab_kid` | string |  | EAB 密钥 id(ZeroSSL 用)。 |
| `email` | string |  | 邮箱 |
| `enabled` | boolean |  | 是否启用 |
| `id` | integer |  | 记录 ID (只读) |
| `last_error` | string |  | 最近一次错误 (只读) |
| `name` | string |  | 名称 |
| `recheck` | boolean |  | 为 true 时重新检测已存的 API Key;通过则账号回到可用,并立即重签因账号不可用而等待的证书。 |
| `status` | string |  | new = 还没注册;registered = 已在 CA 注册;error = 注册失败(原因见 last_error)。 可选值: ["new","registered","error"] (只读) |
| `tenant_id` | integer |  | 所属租户;null = 平台账号。 (只读) |
| `updated_at` | string |  | 更新时间 (只读) |
