Cloudflare
创建 Worker
创建 Worker
POST /cloudflare/client/v4/accounts/{account_id}/workers/workers
Create a Worker.
支持状态: supported
参数
| 名称 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| account_id | path | string | true | Any value; your account comes from the API key. |
请求体 (application/json)
必填: true
| 名称 | 类型 | 说明 |
|---|---|---|
| name | string | Worker name, unique in your account: 3–40 lowercase letters, digits or hyphens, starting and ending with a letter or digit, with no two hyphens in a row. The names www, api, admin, app, canary, canary-probe, status, docs and console are reserved. |
| tags | array<string> | Up to 8 tags. |
| observability | object | Observability settings. |
| observability.enabled | boolean | Collect logs. |
| subdomain | object | Subdomain settings. |
| subdomain.enabled | boolean | Serve the Worker on its public subdomain (default true). |
| praxis | object | Praxis settings. |
| praxis.labels | object | Up to 16 labels. |
{
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"description": "Worker name, unique in your account: 3–40 lowercase letters, digits or hyphens, starting and ending with a letter or digit, with no two hyphens in a row. The names www, api, admin, app, canary, canary-probe, status, docs and console are reserved.",
"pattern": "^(?!(?:www|api|admin|app|canary|canary-probe|status|docs|console)$)(?!.*--)[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$",
"example": "my-app"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"maxItems": 8,
"description": "Up to 8 tags."
},
"observability": {
"type": "object",
"description": "Observability settings.",
"required": [
"enabled"
],
"properties": {
"enabled": {
"type": "boolean",
"description": "Collect logs."
}
}
},
"subdomain": {
"type": "object",
"description": "Subdomain settings.",
"required": [
"enabled"
],
"properties": {
"enabled": {
"type": "boolean",
"description": "Serve the Worker on its public subdomain (default true)."
}
}
},
"praxis": {
"type": "object",
"description": "Praxis settings.",
"required": [],
"properties": {
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "Up to 16 labels."
}
}
}
}
}响应
HTTP 200
Success
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| success | boolean | Always true on success. |
| errors | array<any> | Always empty on success. |
| messages | array<any> | Always empty on success. |
| result | object | |
| result.id | string | Worker ID, prefixed wkr_. |
| result.name | string | Unique per account; lowercase letters, digits and single hyphens. |
| result.subdomain | object | Public address of the Worker. |
| result.tags | array<string> | Up to 8 tags. |
| result.observability | object | Observability settings. |
| result.logpush | boolean | Always false: unlike Cloudflare, Logpush is not offered. |
| result.created_on | string | When the Worker was created. |
| result.updated_on | string | When the Worker last changed. |
| result.deployed_on | string | null | When the current deployment became active; null before the first deployment. |
| result.praxis | object | Platform fields: lifecycle status, labels, and soft-delete timestamps. |
| result_info | object | Present on list responses. |
| result_info.page | integer | Page number. |
| result_info.per_page | integer | Page size. |
| result_info.count | integer | Items on this page. |