Cloudflare API

2026-10-20

Cloudflare API

(待译)

Cloudflare Workers-compatible face of Application: the official cloudflare SDK paths for Workers, versions, deployments and static assets. Concepts, differences and limits are described under the Application tag.

基础地址

加载中…

鉴权

Authorization: Bearer <PRAXIS_API_KEY>

端点

  • 列出 Worker — GET /cloudflare/client/v4/accounts/{account_id}/workers/workers
  • 创建 Worker — POST /cloudflare/client/v4/accounts/{account_id}/workers/workers
  • 获取 Worker — GET /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}
  • 更新 Worker — PUT /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}
  • 编辑 Worker — PATCH /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}
  • 删除 Worker — DELETE /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}
  • 列出版本 — GET /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}/versions
  • 创建版本 — POST /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}/versions
  • 获取版本 — GET /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}
  • 列出部署 — GET /cloudflare/client/v4/accounts/{account_id}/workers/scripts/{script_name}/deployments
  • 创建部署 — POST /cloudflare/client/v4/accounts/{account_id}/workers/scripts/{script_name}/deployments
  • 获取部署 — GET /cloudflare/client/v4/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}
  • 获取账号子域 — GET /cloudflare/client/v4/accounts/{account_id}/workers/subdomain
  • 修改账号子域 — PUT /cloudflare/client/v4/accounts/{account_id}/workers/subdomain
  • 创建静态资源上传会话 — POST /cloudflare/client/v4/accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session
  • 上传静态资源 — POST /cloudflare/client/v4/accounts/{account_id}/workers/assets/upload
  • 旧版脚本上传(未支持) — PUT /cloudflare/client/v4/accounts/{account_id}/workers/scripts/{script_name}

GET /cloudflare/client/v4/accounts/{account_id}/workers/workers

List Workers. order and order_by are accepted and ignored.

支持状态: partial

List Workers. order and order_by are accepted and ignored.

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
pagequeryintegerfalsePage number, from 1.
per_pagequeryintegerfalseItems per page (default 20).

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultarray<object>Workers.
result[].idstringWorker ID, prefixed wkr_.
result[].namestringUnique per account; lowercase letters, digits and single hyphens.
result[].subdomainobjectPublic address of the Worker.
result[].tagsarray<string>Up to 8 tags.
result[].observabilityobjectObservability settings.
result[].logpushbooleanAlways false: unlike Cloudflare, Logpush is not offered.
result[].created_onstringWhen the Worker was created.
result[].updated_onstringWhen the Worker last changed.
result[].deployed_onstring | nullWhen the current deployment became active; null before the first deployment.
result[].praxisobjectPlatform fields: lifecycle status, labels, and soft-delete timestamps.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

创建 Worker

POST /cloudflare/client/v4/accounts/{account_id}/workers/workers

Create a Worker.

支持状态: supported

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.

请求体 (application/json)

必填: true

名称类型说明
namestringWorker 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.
tagsarray<string>Up to 8 tags.
observabilityobjectObservability settings.
observability.enabledbooleanCollect logs.
subdomainobjectSubdomain settings.
subdomain.enabledbooleanServe the Worker on its public subdomain (default true).
praxisobjectPraxis settings.
praxis.labelsobjectUp 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

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.idstringWorker ID, prefixed wkr_.
result.namestringUnique per account; lowercase letters, digits and single hyphens.
result.subdomainobjectPublic address of the Worker.
result.tagsarray<string>Up to 8 tags.
result.observabilityobjectObservability settings.
result.logpushbooleanAlways false: unlike Cloudflare, Logpush is not offered.
result.created_onstringWhen the Worker was created.
result.updated_onstringWhen the Worker last changed.
result.deployed_onstring | nullWhen the current deployment became active; null before the first deployment.
result.praxisobjectPlatform fields: lifecycle status, labels, and soft-delete timestamps.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

获取 Worker

GET /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}

Get a Worker by ID or name.

支持状态: supported

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
worker_idpathstringtrueWorker ID or name.

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.idstringWorker ID, prefixed wkr_.
result.namestringUnique per account; lowercase letters, digits and single hyphens.
result.subdomainobjectPublic address of the Worker.
result.tagsarray<string>Up to 8 tags.
result.observabilityobjectObservability settings.
result.logpushbooleanAlways false: unlike Cloudflare, Logpush is not offered.
result.created_onstringWhen the Worker was created.
result.updated_onstringWhen the Worker last changed.
result.deployed_onstring | nullWhen the current deployment became active; null before the first deployment.
result.praxisobjectPlatform fields: lifecycle status, labels, and soft-delete timestamps.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

PUT /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}

Update a Worker. Omitted fields stay unchanged (same as PATCH).

支持状态: partial

Update a Worker. Omitted fields stay unchanged (same as PATCH).

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
worker_idpathstringtrueWorker ID or name.

请求体 (application/json)

必填: true

名称类型说明
namestringWorker 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.
tagsarray<string>Replaces the tags.
observabilityobjectObservability settings.
observability.enabledbooleanCollect logs.
subdomainobjectSubdomain settings.
subdomain.enabledbooleanServe the Worker on its public subdomain.
praxisobjectPraxis settings.
praxis.labelsobjectReplaces the labels.
{
  "type": "object",
  "required": [],
  "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": "Replaces the 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."
        }
      }
    },
    "praxis": {
      "type": "object",
      "description": "Praxis settings.",
      "required": [],
      "properties": {
        "labels": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Replaces the labels."
        }
      }
    }
  }
}

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.idstringWorker ID, prefixed wkr_.
result.namestringUnique per account; lowercase letters, digits and single hyphens.
result.subdomainobjectPublic address of the Worker.
result.tagsarray<string>Up to 8 tags.
result.observabilityobjectObservability settings.
result.logpushbooleanAlways false: unlike Cloudflare, Logpush is not offered.
result.created_onstringWhen the Worker was created.
result.updated_onstringWhen the Worker last changed.
result.deployed_onstring | nullWhen the current deployment became active; null before the first deployment.
result.praxisobjectPlatform fields: lifecycle status, labels, and soft-delete timestamps.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

编辑 Worker

PATCH /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}

Change some fields of a Worker.

支持状态: supported

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
worker_idpathstringtrueWorker ID or name.

请求体 (application/json)

必填: true

名称类型说明
namestringWorker 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.
tagsarray<string>Replaces the tags.
observabilityobjectObservability settings.
observability.enabledbooleanCollect logs.
subdomainobjectSubdomain settings.
subdomain.enabledbooleanServe the Worker on its public subdomain.
praxisobjectPraxis settings.
praxis.labelsobjectReplaces the labels.
{
  "type": "object",
  "required": [],
  "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": "Replaces the 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."
        }
      }
    },
    "praxis": {
      "type": "object",
      "description": "Praxis settings.",
      "required": [],
      "properties": {
        "labels": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Replaces the labels."
        }
      }
    }
  }
}

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.idstringWorker ID, prefixed wkr_.
result.namestringUnique per account; lowercase letters, digits and single hyphens.
result.subdomainobjectPublic address of the Worker.
result.tagsarray<string>Up to 8 tags.
result.observabilityobjectObservability settings.
result.logpushbooleanAlways false: unlike Cloudflare, Logpush is not offered.
result.created_onstringWhen the Worker was created.
result.updated_onstringWhen the Worker last changed.
result.deployed_onstring | nullWhen the current deployment became active; null before the first deployment.
result.praxisobjectPlatform fields: lifecycle status, labels, and soft-delete timestamps.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

删除 Worker

DELETE /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}

Delete a Worker. It can be restored on the native API for 7 days. force is accepted and ignored.

支持状态: supported

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
worker_idpathstringtrueWorker ID or name.

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultnullNo result.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

列出版本

GET /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}/versions

List versions, newest first.

支持状态: supported

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
worker_idpathstringtrueWorker ID or name.
pagequeryintegerfalsePage number, from 1.
per_pagequeryintegerfalseItems per page (default 20).

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultarray<object>Versions.
result[].idstringVersion ID, prefixed ver_.
result[].numberintegerPer-Worker counter (v1, v2, …).
result[].created_onstringWhen the version was created.
result[].main_modulestring | nullEntry module name, or null for a version containing only static assets.
result[].modulesarray<object>Module names and types; content is never returned.
result[].compatibility_datestringWorkers runtime compatibility date.
result[].compatibility_flagsarray<string>Runtime compatibility flags.
result[].bindingsarray<object>Bindings; secret values are never returned.
result[].assetsobject | nullStatic asset settings.
result[].annotationsobjectFree-form annotations.
result[].author_idstring | nullWho created the version.
result[].sourcestringUpload origin, e.g. api or sdk.
result[].urlsarray<string>Preview URLs of this version.
result[].praxisobjectPlatform fields: owning Worker, build source, script size and asset manifest summary.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

POST /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}/versions

Upload a version. With deploy=true a deployment starts as well. Static assets are declared with assets.manifest; triggers, migrations, containers and placement are refused.

支持状态: partial

Upload a version. With deploy=true a deployment starts as well. Static assets are declared with assets.manifest; triggers, migrations, containers and placement are refused.

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
worker_idpathstringtrueWorker ID or name.
deployquerybooleanfalseAlso deploy this version.

请求体 (application/json)

必填: true

名称类型说明
deploybooleanAlso create a deployment of this version (own face only; on the compatible face use the deploy query parameter).
main_modulestringEntry module name; must equal the name of one of modules. Defaults to the first module; omit it when there are no modules.
modulesarray<object>Inline modules.
modules[].namestringModule file name.
modules[].content_typestringModule content type: application/javascript+module, text/javascript, application/javascript, application/wasm, text/plain, application/octet-stream, application/json or application/x-python. Omit it to use application/javascript+module.
modules[].content_base64stringModule content, base64.
compatibility_datestringWorkers runtime compatibility date: a real date in YYYY-MM-DD form, not later than today (UTC). Defaults to today (UTC).
compatibility_flagsarray<string>Runtime compatibility flags.
bindingsarray<object>Bindings of this version.
bindings[].typestringBinding type; see the binding description for what each needs and which are unavailable.
bindings[].namestringName of the binding in the Worker's env: 1–64 letters, digits or underscores, not starting with a digit; unique within a version.
assetsobjectStatic assets. Pass either manifest (every file already uploaded through an upload session) or jwt (the completion token from the last upload batch), not both.
assets.configobjectRouting settings for the static assets.
assets.manifestobjectMap of static file path to content hash and byte size. Paths start with /; the same hash must declare the same size. The root paths /_headers and /_redirects are response-header and redirect rule files and are not served as assets; same-named files in subdirectories are ordinary assets. _headers allows at most 100 rules and 2000 characters per line (whitespace included); _redirects allows at most 2000 static and 100 dynamic rules and 1000 characters per rule (whitespace included), and rules after the first dynamic rule count toward the dynamic quota. Exceeding a limit makes CreateVersion return INVALID_PARAMS, with violations.field pointing at the manifest entry.
assets.jwtstringCompletion token from the last assets/upload batch; it carries this version's manifest, so do not also pass manifest.
annotationsobjectFree-form annotations.
annotations.workers/messagestringVersion message.
annotations.workers/tagstringVersion tag.
praxisobjectPraxis settings.
praxis.sourceobjectBuild source: {type:inline}, {type:machine, path} or {type:file, file_id}.
{
  "type": "object",
  "required": [],
  "properties": {
    "deploy": {
      "type": "boolean",
      "description": "Also create a deployment of this version (own face only; on the compatible face use the deploy query parameter)."
    },
    "main_module": {
      "type": "string",
      "description": "Entry module name; must equal the name of one of modules. Defaults to the first module; omit it when there are no modules.",
      "example": "index.js"
    },
    "modules": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/cloudflare-Module"
      },
      "description": "Inline modules."
    },
    "compatibility_date": {
      "type": "string",
      "description": "Workers runtime compatibility date: a real date in YYYY-MM-DD form, not later than today (UTC). Defaults to today (UTC).",
      "format": "date",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "example": "2026-01-01"
    },
    "compatibility_flags": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Runtime compatibility flags."
    },
    "bindings": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/cloudflare-Binding"
      },
      "description": "Bindings of this version."
    },
    "assets": {
      "type": "object",
      "description": "Static assets. Pass either manifest (every file already uploaded through an upload session) or jwt (the completion token from the last upload batch), not both.",
      "required": [],
      "properties": {
        "config": {
          "$ref": "#/components/schemas/cloudflare-AssetsConfig",
          "description": "Routing settings for the static assets."
        },
        "manifest": {
          "$ref": "#/components/schemas/cloudflare-AssetManifest"
        },
        "jwt": {
          "type": "string",
          "description": "Completion token from the last assets/upload batch; it carries this version's manifest, so do not also pass manifest."
        }
      }
    },
    "annotations": {
      "type": "object",
      "description": "Free-form annotations.",
      "required": [],
      "properties": {
        "workers/message": {
          "type": "string",
          "description": "Version message."
        },
        "workers/tag": {
          "type": "string",
          "description": "Version tag."
        }
      }
    },
    "praxis": {
      "type": "object",
      "description": "Praxis settings.",
      "required": [],
      "properties": {
        "source": {
          "type": "object",
          "additionalProperties": true,
          "description": "Build source: {type:inline}, {type:machine, path} or {type:file, file_id}."
        }
      }
    }
  }
}

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.idstringVersion ID, prefixed ver_.
result.numberintegerPer-Worker counter (v1, v2, …).
result.created_onstringWhen the version was created.
result.main_modulestring | nullEntry module name, or null for a version containing only static assets.
result.modulesarray<object>Module names and types; content is never returned.
result.compatibility_datestringWorkers runtime compatibility date.
result.compatibility_flagsarray<string>Runtime compatibility flags.
result.bindingsarray<object>Bindings; secret values are never returned.
result.assetsobject | nullStatic asset settings.
result.annotationsobjectFree-form annotations.
result.author_idstring | nullWho created the version.
result.sourcestringUpload origin, e.g. api or sdk.
result.urlsarray<string>Preview URLs of this version.
result.praxisobjectPlatform fields: owning Worker, build source, script size and asset manifest summary.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

获取版本

GET /cloudflare/client/v4/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}

Get one version.

支持状态: supported

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
worker_idpathstringtrueWorker ID or name.
version_idpathstringtrueVersion ID.

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.idstringVersion ID, prefixed ver_.
result.numberintegerPer-Worker counter (v1, v2, …).
result.created_onstringWhen the version was created.
result.main_modulestring | nullEntry module name, or null for a version containing only static assets.
result.modulesarray<object>Module names and types; content is never returned.
result.compatibility_datestringWorkers runtime compatibility date.
result.compatibility_flagsarray<string>Runtime compatibility flags.
result.bindingsarray<object>Bindings; secret values are never returned.
result.assetsobject | nullStatic asset settings.
result.annotationsobjectFree-form annotations.
result.author_idstring | nullWho created the version.
result.sourcestringUpload origin, e.g. api or sdk.
result.urlsarray<string>Preview URLs of this version.
result.praxisobjectPlatform fields: owning Worker, build source, script size and asset manifest summary.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

列出部署

GET /cloudflare/client/v4/accounts/{account_id}/workers/scripts/{script_name}/deployments

List deployments of a Worker, newest first.

支持状态: supported

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
script_namepathstringtrueWorker name.
pagequeryintegerfalsePage number, from 1.
per_pagequeryintegerfalseItems per page (default 20).

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.deploymentsarray<object>Deployments.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

POST /cloudflare/client/v4/accounts/{account_id}/workers/scripts/{script_name}/deployments

Deploy one version at 100 percent (no gradual rollout). Deployment is asynchronous; read praxis.status.

支持状态: partial

Deploy one version at 100 percent (no gradual rollout). Deployment is asynchronous; read praxis.status.

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
script_namepathstringtrueWorker name.
forcequerybooleanfalseDeploy even if the last deployment changed in between.

请求体 (application/json)

必填: true

名称类型说明
strategystringRollout strategy.
versionsarray<object>Exactly one version at 100 percent.
versions[].version_idstringVersion to deploy.
versions[].percentagenumberMust be 100.
forcebooleanOwn face only; on the compatible face use the force query parameter.
annotationsobjectFree-form annotations.
annotations.workers/messagestringDeployment message.
{
  "type": "object",
  "required": [
    "strategy",
    "versions"
  ],
  "properties": {
    "strategy": {
      "type": "string",
      "description": "Rollout strategy.",
      "enum": [
        "percentage"
      ],
      "x-enum-descriptions": {
        "percentage": "Split traffic by percentage; only a single version at 100 is accepted."
      },
      "example": "percentage"
    },
    "versions": {
      "type": "array",
      "description": "Exactly one version at 100 percent.",
      "items": {
        "type": "object",
        "required": [
          "version_id",
          "percentage"
        ],
        "properties": {
          "version_id": {
            "type": "string",
            "description": "Version to deploy."
          },
          "percentage": {
            "type": "number",
            "description": "Must be 100."
          }
        }
      }
    },
    "force": {
      "type": "boolean",
      "description": "Own face only; on the compatible face use the force query parameter."
    },
    "annotations": {
      "type": "object",
      "description": "Free-form annotations.",
      "required": [],
      "properties": {
        "workers/message": {
          "type": "string",
          "description": "Deployment message."
        }
      }
    }
  }
}

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.idstringDeployment ID, prefixed dep_.
result.created_onstringWhen the deployment was created.
result.sourcestringOrigin: api, sdk, console or rollback.
result.strategystringRollout strategy.
result.versionsarray<object>Exactly one version at 100 percent.
result.annotationsobjectFree-form annotations.
result.author_emailstring | nullWho created the deployment.
result.praxisobjectPlatform fields: deployments run asynchronously, so track status, progress and error here.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

获取部署

GET /cloudflare/client/v4/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}

Get one deployment.

支持状态: supported

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
script_namepathstringtrueWorker name.
deployment_idpathstringtrueDeployment ID.

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.idstringDeployment ID, prefixed dep_.
result.created_onstringWhen the deployment was created.
result.sourcestringOrigin: api, sdk, console or rollback.
result.strategystringRollout strategy.
result.versionsarray<object>Exactly one version at 100 percent.
result.annotationsobjectFree-form annotations.
result.author_emailstring | nullWho created the deployment.
result.praxisobjectPlatform fields: deployments run asynchronously, so track status, progress and error here.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

获取账号子域

GET /cloudflare/client/v4/accounts/{account_id}/workers/subdomain

Get the account subdomain.

支持状态: supported

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.subdomainstringAccount subdomain, 8–32 lowercase letters and digits; part of every Worker URL.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

修改账号子域

PUT /cloudflare/client/v4/accounts/{account_id}/workers/subdomain

Change the account subdomain.

支持状态: supported

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.

请求体 (application/json)

必填: true

名称类型说明
subdomainstringAccount subdomain, 8–32 lowercase letters and digits; part of every Worker URL.
{
  "type": "object",
  "required": [
    "subdomain"
  ],
  "properties": {
    "subdomain": {
      "type": "string",
      "description": "Account subdomain, 8–32 lowercase letters and digits; part of every Worker URL.",
      "pattern": "^[a-z0-9]{8,32}$",
      "example": "acme1234"
    }
  }
}

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.subdomainstringAccount subdomain, 8–32 lowercase letters and digits; part of every Worker URL.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

创建静态资源上传会话

POST /cloudflare/client/v4/accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session

Declare the static file manifest; the answer lists missing hashes in batches and an upload token.

支持状态: supported

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
script_namepathstringtrueWorker name.

请求体 (application/json)

必填: true

名称类型说明
manifestobjectMap of static file path to content hash and byte size. Paths start with /; the same hash must declare the same size. The root paths /_headers and /_redirects are response-header and redirect rule files and are not served as assets; same-named files in subdirectories are ordinary assets. _headers allows at most 100 rules and 2000 characters per line (whitespace included); _redirects allows at most 2000 static and 100 dynamic rules and 1000 characters per rule (whitespace included), and rules after the first dynamic rule count toward the dynamic quota. Exceeding a limit makes CreateVersion return INVALID_PARAMS, with violations.field pointing at the manifest entry.
{
  "type": "object",
  "required": [
    "manifest"
  ],
  "properties": {
    "manifest": {
      "$ref": "#/components/schemas/cloudflare-AssetManifest"
    }
  }
}

响应

HTTP 200

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.jwtstringUpload token, valid for one hour.
result.bucketsarray<array<string>>Hashes still missing, grouped into upload batches.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

POST /cloudflare/client/v4/accounts/{account_id}/workers/assets/upload

Upload one batch as multipart form fields (hash → content; base64 when base64=true). Send the upload token as Authorization: Bearer and your API key in X-API-Key. Earlier batches answer 202; the last answers 201 with the completion token.

支持状态: partial

Upload one batch as multipart form fields (hash → content; base64 when base64=true). Send the upload token as Authorization: Bearer and your API key in X-API-Key. Earlier batches answer 202; the last answers 201 with the completion token.

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
base64querybooleanfalseField values are base64.

请求体 (multipart/form-data)

必填: true

名称类型说明
{
  "type": "object",
  "additionalProperties": {
    "type": "string"
  },
  "description": "One form field per file: the field name is the hash, the value the content."
}

响应

HTTP 201

Success

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result.jwtstring | nullCompletion token after the last batch; null for earlier batches.
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

HTTP 202

Batch stored; more batches remain (no completion token yet).

application/json

名称类型说明
successbooleanAlways true on success.
errorsarray<any>Always empty on success.
messagesarray<any>Always empty on success.
resultobject
result_infoobjectPresent on list responses.
result_info.pageintegerPage number.
result_info.per_pageintegerPage size.
result_info.countintegerItems on this page.

PUT /cloudflare/client/v4/accounts/{account_id}/workers/scripts/{script_name}

Not supported: answers 501. Use POST workers/workers and POST workers/workers/{worker_id}/versions?deploy=true.

支持状态: unsupported

Not supported: answers 501. Use POST workers/workers and POST workers/workers/{worker_id}/versions?deploy=true.

参数

名称位置类型必填说明
account_idpathstringtrueAny value; your account comes from the API key.
script_namepathstringtrueWorker name.

响应

此端点没有声明成功响应。