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

# 设置自定义域名

> 将你的网站与自定义域名集成。速率限制为每 5 分钟 10 次更改，每 24 小时 50 次更改。

**使用此路由至少需要 [Standard 套餐](https://squarecloud.app/zh/pricing)。**

同一账户可以将一个域名绑定到多个应用（负载均衡）：Standard 最多 2 个应用，Pro 最多 5 个，Enterprise 最多 10 个。参见 [列出负载均衡器](/zh/api-reference/endpoint/apps/network/load-balancers)。

<ParamField header="Authorization" type="string" placeholder="API Key" required>
  你账户的 API 密钥。你可以在[账户设置](https://squarecloud.app/zh/account/security)中找到它。
</ParamField>

### 参数

<ParamField path="app_id" type="string" placeholder="Application ID" required>
  应用的 ID。你可以在应用仪表盘的 URL 中找到它。
</ParamField>

<ParamField body="custom" type="string" placeholder="example.com" required>
  要绑定的完全限定域名，或使用 `@` 移除应用当前的自定义域名。它不能是 Square Cloud 域名（`squareweb.app`、`squarecloud.app`……）。
</ParamField>

### 响应

<ResponseField name="status" type="string">
  指示调用是否成功。成功时为 `success`，否则为 `error`。
</ResponseField>

失败时，响应会包含一个错误 `code`：

| Status | Code                          | 含义                                          |
| ------ | ----------------------------- | ------------------------------------------- |
| `400`  | `REGEX_VALIDATION`            | 该域名不是有效的完全限定域名。                             |
| `400`  | `RESERVED_DOMAIN`             | Square Cloud 域名不能用作自定义域名。                   |
| `403`  | `UPGRADE_REQUIRED`            | 当前套餐不包含自定义域名（需要 Standard、Pro 或 Enterprise）。 |
| `403`  | `LOAD_BALANCER_LIMIT_REACHED` | 已达到该套餐在此域名上的应用数量上限。                         |
| `409`  | `DOMAIN_ALREADY_EXISTS`       | 该域名已绑定到另一账户拥有的应用。                           |
| `502`  | `DNS_FAILED`                  | 域名绑定在边缘提供商处失败。                              |

<ResponseExample>
  ```json theme={null}
  {
      "status": "success"
  }
  ```
</ResponseExample>
