Path: API › ACME 证书

`POST /acme`

创建 Let's Encrypt（或其他 ACME CA）证书申请订单。支持三种验证方式。

## Request body

_Required._

- `action1.request_time` (string, required) — Unix 时间戳。
- `action1.request_token` (string, required) — 按 API 概览生成的签名。
- `action1.action` (string, required) — 具体操作名称。
  - one of `"apply_cert_api"`
- `action1.id` (integer, required) — 关联网站 ID
- `action1.domains` (string, required) — JSON 数组，要申请的域名列表 `["example.com","www.example.com"]`
- `action1.auth_type` (string, required) — 验证方式：`http`(文件)、`tls`(TLS)、`dns`(DNS)
- `action1.auth_to` (string, required) — 验证路径。HTTP/TLS 传网站目录；**DNS 验证传 `dns`**
- `action1.auto_wildcard` (string, optional) — `"1"` 自动申请泛域名 `*.example.com`
- `action1.ca` (string, optional) — CA 标识，默认 Let's Encrypt

## Example request

```text
{
  "request_time": "string",
  "request_token": "string",
  "action": "apply_cert_api",
  "id": 0,
  "domains": "string",
  "auth_type": "string",
  "auth_to": "string",
  "auto_wildcard": "string",
  "ca": "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_cert_api" \
  --data-urlencode "id=<id>" \
  --data-urlencode "domains=<domains>" \
  --data-urlencode "auth_type=<auth_type>" \
  --data-urlencode "auth_to=<auth_to>"
```

## Responses

### default

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

#### Example

```json
{
  "status": "pending",
  "index": "a7a0472c4a5061ec83450119b874a5d3",
  "domains": [
    "dnstest.cc"
  ],
  "auth_type": "dns",
  "expires": 1780111135,
  "create_time": 1779506335,
  "authorizations": [
    "https://acme-v02.api.letsencrypt.org/acme/authz/..."
  ]
}
```

- `action1.response.default.status` (string, optional) — `pending` 订单待验证
- `action1.response.default.index` (string, optional) — 订单索引 ID，后续操作需要
- `action1.response.default.domains` (array<unknown>, optional) — 申请的域名列表
- `action1.response.default.authorizations` (array<unknown>, optional) — Let's Encrypt 授权 URL 列表
- `action1.response.default.expires` (integer, optional) — 订单过期时间戳
- `action1.response.default.create_time` (integer, optional) — 创建时间戳


## apply_cert_api

创建 Let's Encrypt（或其他 ACME CA）证书申请订单。支持三种验证方式。

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

## 输入参数

| 参数名称 | 必选 | 类型 | 描述 |
|----------|------|------|------|
| action | 是 | String | 固定值 `apply_cert_api` |
| id | 是 | Integer | 关联网站 ID |
| domains | 是 | String | JSON 数组，要申请的域名列表 `["example.com","www.example.com"]` |
| auth_type | 是 | String | 验证方式：`http`(文件)、`tls`(TLS)、`dns`(DNS) |
| auth_to | 是 | String | 验证路径。HTTP/TLS 传网站目录；**DNS 验证传 `dns`** |
| auto_wildcard | 否 | String | `"1"` 自动申请泛域名 `*.example.com` |
| ca | 否 | String | CA 标识，默认 Let's Encrypt |

> **提示**：`auth_type=dns`, `auth_to=dns` 时仅创建订单。需再用 [apply_dns_auth](/api/acme/apply_dns_auth) 完成 DNS TXT 记录创建和验证。


## 输出参数

| 参数名称 | 类型 | 描述 |
|----------|------|------|
| status | String | `pending` 订单待验证 |
| index | String | 订单索引 ID，后续操作需要 |
| domains | Array | 申请的域名列表 |
| authorizations | Array | Let's Encrypt 授权 URL 列表 |
| expires | Integer | 订单过期时间戳 |
| create_time | Integer | 创建时间戳 |

## 示例

### 请求（DNS 验证）

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

action=apply_cert_api&id=1&domains=["dnstest.cc"]&auth_type=dns&auth_to=dns
```

### 响应

```json
{
  "status": "pending",
  "index": "a7a0472c4a5061ec83450119b874a5d3",
  "domains": ["dnstest.cc"],
  "auth_type": "dns",
  "expires": 1780111135,
  "create_time": 1779506335,
  "authorizations": ["https://acme-v02.api.letsencrypt.org/acme/authz/..."]
}
```

## 相关接口

- [apply_dns_auth](/api/acme/apply_dns_auth) — 完成 DNS 验证并签发
- [SetCertToSite](/api/acme/setcerttosite) — 部署证书到网站

