Application

创建版本

创建版本

POST /application/v1/workers/{worker_id}/versions

Upload code and bindings as a new version; a version serves nothing until deployed. Set deploy true to create the pending deployment in the same call. Rejected binding types return UNSUPPORTED.

支持状态: supported

参数

名称位置类型必填说明
worker_idpathstringtrueWorker ID (wkr_…).

请求体 (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/application-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/application-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/application-AssetsConfig",
          "description": "Routing settings for the static assets."
        },
        "manifest": {
          "$ref": "#/components/schemas/application-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

名称类型说明
versionobjectThe version that was created.
version.idstringVersion ID, prefixed ver_.
version.numberintegerPer-Worker counter (v1, v2, …).
version.created_onstringWhen the version was created.
version.main_modulestring | nullEntry module name, or null for a version containing only static assets.
version.modulesarray<object>Module names and types; content is never returned.
version.compatibility_datestringWorkers runtime compatibility date.
version.compatibility_flagsarray<string>Runtime compatibility flags.
version.bindingsarray<object>Bindings; secret values are never returned.
version.assetsobject | nullStatic asset settings.
version.annotationsobjectFree-form annotations.
version.author_idstring | nullWho created the version.
version.sourcestringUpload origin, e.g. api or sdk.
version.urlsarray<string>Preview URLs of this version.
version.praxisobjectPlatform fields: owning Worker, build source, script size and asset manifest summary.
deploymentobject | nullThe pending deployment; null unless deploy was requested.
deployment.idstringDeployment ID, prefixed dep_.
deployment.created_onstringWhen the deployment was created.
deployment.sourcestringOrigin: api, sdk, console or rollback.
deployment.strategystringRollout strategy.
deployment.versionsarray<object>Exactly one version at 100 percent.
deployment.annotationsobjectFree-form annotations.
deployment.author_emailstring | nullWho created the deployment.
deployment.praxisobjectPlatform fields: deployments run asynchronously, so track status, progress and error here.
导出

本页内容