# 创建版本 (/docs/api/compatible/cloudflare/createVersion)



`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\_id | path  | string  | true  | Any value; your account comes from the API key. |
| worker\_id  | path  | string  | true  | Worker ID or name.                              |
| deploy      | query | boolean | false | Also deploy this version.                       |

## 请求体 (application/json) [#请求体-applicationjson]

必填: true

| 名称                          | 类型             | 说明                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| --------------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| deploy                      | boolean        | Also create a deployment of this version (own face only; on the compatible face use the deploy query parameter).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| main\_module                | string         | Entry module name; must equal the name of one of modules. Defaults to the first module; omit it when there are no modules.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| modules                     | array\<object> | Inline modules.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| modules\[].name             | string         | Module file name.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| modules\[].content\_type    | string         | Module 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\_base64  | string         | Module content, base64.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| compatibility\_date         | string         | Workers runtime compatibility date: a real date in YYYY-MM-DD form, not later than today (UTC). Defaults to today (UTC).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| compatibility\_flags        | array\<string> | Runtime compatibility flags.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| bindings                    | array\<object> | Bindings of this version.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| bindings\[].type            | string         | Binding type; see the binding description for what each needs and which are unavailable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| bindings\[].name            | string         | Name of the binding in the Worker's env: 1–64 letters, digits or underscores, not starting with a digit; unique within a version.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| assets                      | object         | 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| assets.config               | object         | Routing settings for the static assets.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| assets.manifest             | object         | Map 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.jwt                  | string         | Completion token from the last assets/upload batch; it carries this version's manifest, so do not also pass manifest.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| annotations                 | object         | Free-form annotations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| annotations.workers/message | string         | Version message.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| annotations.workers/tag     | string         | Version tag.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| praxis                      | object         | Praxis settings.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| praxis.source               | object         | Build source: \{type:inline}, \{type:machine, path} or \{type:file, file\_id}.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

```json
{
  "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 [#http-200]

Success

**application/json**

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| success | boolean | Always true on success. |
| errors | array&lt;any&gt; | Always empty on success. |
| messages | array&lt;any&gt; | Always empty on success. |
| result | object |  |
| result.id | string | Version ID, prefixed ver_. |
| result.number | integer | Per-Worker counter (v1, v2, …). |
| result.created_on | string | When the version was created. |
| result.main_module | string &#124; null | Entry module name, or null for a version containing only static assets. |
| result.modules | array&lt;object&gt; | Module names and types; content is never returned. |
| result.compatibility_date | string | Workers runtime compatibility date. |
| result.compatibility_flags | array&lt;string&gt; | Runtime compatibility flags. |
| result.bindings | array&lt;object&gt; | Bindings; secret values are never returned. |
| result.assets | object &#124; null | Static asset settings. |
| result.annotations | object | Free-form annotations. |
| result.author_id | string &#124; null | Who created the version. |
| result.source | string | Upload origin, e.g. api or sdk. |
| result.urls | array&lt;string&gt; | Preview URLs of this version. |
| result.praxis | object | Platform fields: owning Worker, build source, script size and asset manifest summary. |
| 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. |
