hosting
POST /v1/sites/{siteId}/protection/directories
Password-protect a folder on a site.
身份验证
请将 API 密钥作为 bearer 令牌发送。该密钥必须具有 sites.view 权限;缺少该权限的密钥将被拒绝并返回 403 状态码,而非 404。
此端点不需要组织 ID。您的密钥已用于识别其所属的组织,且响应范围也仅限于该组织。
免费试用
将尖括号中的内容替换为您自己的值,并将键占位符替换为您仪表板中的一个键。
curl -X POST https://api.zinndigital.com/v1/sites/{siteId}/protection/directories \
-H "Authorization: Bearer zdk_live_…" \
-H "Content-Type: application/json" \
-d '{ "directory": <string>, "username": <string> }'已登录?您仪表板中的 API 控制台会自动填入您真实的组织 ID 和您自己的密钥,并针对实时 API 运行请求,以便您查看实际的响应。 在 API 控制台中打开此端点
详细信息
Puts an HTTP password on one folder under the document root. `POST` and not a `PUT` of the whole set even though the vendor endpoint replaces it: the set is rebuilt by the engine from the entries the platform itself returned, precisely because we do not hold the other folders' passwords and must not ask a customer to re-enter them to protect a new one. ⛔ **The response carries a password, and it is the only one on this surface that does.** Omit `password` and the engine generates a strong one; either way the value is returned **exactly once**, written to no record of ours, and readable back by no endpoint. The whole response is therefore a credential: a client displays it once and does not cache it, store it in a query cache, put it in a URL, or include it in an error report. `username` may not contain a colon or a space — `:` separates the name from the hash in an `.htpasswd` file, so a name containing one produces a file that parses into something other than what was written. `404` for a site with no vendor hosting package. Requires `sites.view` and `sites.panel_access`.
参数
| 名称 | 类型 | 必填 | 内容简介 |
|---|---|---|---|
siteId (path) | Uuid | 是 | Site ID (UUIDv7). |
请求正文
| 名称 | 类型 | 必填 | 内容简介 |
|---|---|---|---|
directory | string | 是 | The folder to protect, relative to the document root. It is normalised before it is compared with what the vendor holds, so what is protected is the folder the customer meant. |
username | string | 是 | The name a visitor types. No colon and no space, because this is written into an `.htpasswd` file where `:` is the field separator. |
password | string | 否 | Optional. Omitting it means *generate one for me*, which is the path that guarantees a strong value. Write-only: whatever is sent here appears in no response, no log line and no… |
响应
| 名称 | 类型 | 必填 | 内容简介 |
|---|---|---|---|
directory | SiteProtectedDirectory | 是 | The folder, exactly as `getSiteProtection` will report it. |
password | string | 是 | The password, shown once. Deliberately carries no example — a documented example of a credential field is the shape people copy. ⛔ It never contains a colon: this value is writt… |
此端点可能返回的错误
401 · 403 · 404 · 409 · 422 · 429 · 503