Path: API › ACME 证书

`POST /acme`

自动调用已配置的 DNS 提供商 API（如腾讯云 DNSPod）创建 ACME 所需的 `_acme-challenge` TXT 记录，完成域名验证，签发并下载证书。验证完成后自动删除临时 TXT 记录。

## Request body

_Required._

- `action2.request_time` (string, required) — Unix 时间戳。
- `action2.request_token` (string, required) — 按 API 概览生成的签名。
- `action2.action` (string, required) — 具体操作名称。
  - one of `"apply_dns_auth"`
- `action2.index` (string, required) — 订单索引 ID（由 `apply_cert_api` 返回）

## Example request

```text
{
  "request_time": "string",
  "request_token": "string",
  "action": "apply_dns_auth",
  "index": "string"
}
```

## Code samples

### cURL（填写面板地址与签名）

```curl
curl --request POST \
  --url "https://your-panel.example.com:8888/acme" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "request_time=<Unix时间戳>" \
  --data-urlencode "request_token=<按 API 概览生成的签名>" \
  --data-urlencode "action=apply_dns_auth" \
  --data-urlencode "index=<index>"
```

## Responses

### default

接口响应，业务状态见下方详细说明。

#### Example

```json
{
  "status": true,
  "msg": "申请成功!",
  "cert": "-----BEGIN CERTIFICATE-----\nMIIE7TCCA9W...",
  "private_key": "-----BEGIN PRIVATE KEY-----\n...",
  "domains": [
    "dnstest.cc"
  ],
  "cert_timeout": 1780111135
}
```

- `action2.response.default.status` (boolean, optional) — `true` 申请成功
- `action2.response.default.msg` (string, optional) — `申请成功!`
- `action2.response.default.cert` (string, optional) — 完整证书链（PEM 格式）
- `action2.response.default.private_key` (string, optional) — 私钥（PEM 格式）
- `action2.response.default.domains` (array<unknown>, optional) — 证书覆盖的域名列表
- `action2.response.default.cert_timeout` (integer, optional) — 证书到期时间戳


## apply_dns_auth

自动调用已配置的 DNS 提供商 API（如腾讯云 DNSPod）创建 ACME 所需的 `_acme-challenge` TXT 记录，完成域名验证，签发并下载证书。验证完成后自动删除临时 TXT 记录。

**前置条件**：已通过 `/ssl/dnsapi/add_dns_data` 配置 DNS API 密钥，并通过 `/ssl/data/add_domain` 添加域名。

- **路由**：`POST /acme`
- **action**：`apply_dns_auth`

## 输入参数

| 参数名称 | 必选 | 类型 | 描述 |
|----------|------|------|------|
| action | 是 | String | 固定值 `apply_dns_auth` |
| index | 是 | String | 订单索引 ID（由 `apply_cert_api` 返回） |

## 输出参数

| 参数名称 | 类型 | 描述 |
|----------|------|------|
| status | Boolean | `true` 申请成功 |
| msg | String | `申请成功!` |
| cert | String | 完整证书链（PEM 格式） |
| private_key | String | 私钥（PEM 格式） |
| domains | Array | 证书覆盖的域名列表 |
| cert_timeout | Integer | 证书到期时间戳 |

## 示例

### 请求

```
POST /acme HTTP/1.1
Host: 192.168.168.213:8888
Content-Type: application/x-www-form-urlencoded

action=apply_dns_auth&index=a7a0472c4a5061ec83450119b874a5d3
```

### 响应

```json
{
  "status": true,
  "msg": "申请成功!",
  "cert": "-----BEGIN CERTIFICATE-----\nMIIE7TCCA9W...",
  "private_key": "-----BEGIN PRIVATE KEY-----\n...",
  "domains": ["dnstest.cc"],
  "cert_timeout": 1780111135
}
```

## 相关接口

- [apply_cert_api](/api/acme/apply_cert_api) — 创建证书订单
- [SetCertToSite](/api/acme/setcerttosite) — 部署证书到网站

