按文档 ID 对自定义组件的文档变体执行插入或更新。
针对自定义组件的某个变体(一行 documents),按文档 id 作为键执行插入或更新。提供 id 时会更新现有变体;省略则插入新的变体。也可通过 /schemas/{schema_name} 使用。本内容会根据组件的架构进行验证。
认证: API 密钥——始终必需,且该密钥必须具有 content_write 权限。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
schema_name | string | yes | 自定义组件名称。 |
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
websiteId | uuid | no | 目标网站;回退到 Host 标头/配置。 |
api_key | string | no | 作为 x-api-key 标头的替代方案。 |
{
"id": "<uuid>",
"title": "我的变体",
"content": { "title": "你好", "body": "..." }
}
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | uuid | no | 存在时更新匹配的变体;缺失或未找到时插入。 |
title | string | no | 显示标题。插入时默认为 "Untitled";更新时若省略则保持不变。 |
content | object | yes | 字段值,会根据组件的架构进行验证。必须是 JSON 对象。 |
{
"id": "...",
"schema_name": "post",
"title": "我的变体",
"status": "草稿",
"version": 2,
"created": true
}
created 在插入时为 true(HTTP 201),在更新时为 false(HTTP 200)。
curl -X PATCH '{CMS_API_URL}/dataset/post?websiteId=<uuid>' \
-H 'x-api-key: <key>' \
-H 'Content-Type: application/json' \
-d '{"content":{"title":"你好"}}'
400 — 无效的 websiteId、content 不是对象、组件未知或已归档,或验证失败401 — 缺失或无效的 API 密钥403 — 密钥缺少 content_write 权限404 — 提供了 id 但没有匹配的变体