Create Version
Create a new version.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYYAPI Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
X-Auth-Email: user@example.comThe previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194Accepted Permissions (at least one required)
Workers Scripts WritePath ParametersExpand Collapse
Query ParametersExpand Collapse
Body ParametersJSONExpand Collapse
annotations: optional object { "workers/message", "workers/tag", "workers/triggered_by" } Metadata about the version.
Metadata about the version.
assets: optional object { config, jwt } Configuration for assets within a Worker.
_headers and
_redirects files should be
included as modules named _headers and _redirects with content type text/plain.
Configuration for assets within a Worker.
_headers and
_redirects files should be
included as modules named _headers and _redirects with content type text/plain.
config: optional object { html_handling, not_found_handling, run_worker_first } Configuration for assets within a Worker.
Configuration for assets within a Worker.
html_handling: optional "auto-trailing-slash" or "force-trailing-slash" or "drop-trailing-slash" or "none"Determines the redirects and rewrites of requests for HTML content.
Determines the redirects and rewrites of requests for HTML content.
not_found_handling: optional "none" or "404-page" or "single-page-application"Determines the response when a request does not match a static asset, and there is no Worker script.
Determines the response when a request does not match a static asset, and there is no Worker script.
run_worker_first: optional array of string or booleanContains a list path rules to control routing to either the Worker or assets. Glob (*) and negative (!) rules are supported. Rules must start with either ’/’ or ’!/’. At least one non-negative rule must be provided, and negative rules have higher precedence than non-negative rules.
Contains a list path rules to control routing to either the Worker or assets. Glob (*) and negative (!) rules are supported. Rules must start with either ’/’ or ’!/’. At least one non-negative rule must be provided, and negative rules have higher precedence than non-negative rules.
bindings: optional array of object { name, type } or object { instance_name, name, type, namespace } or object { name, namespace, type } or 32 moreList of bindings attached to a Worker. You can find more about bindings on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings.
List of bindings attached to a Worker. You can find more about bindings on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings.
AISearch object { instance_name, name, type, namespace }
AISearchNamespace object { name, namespace, type }
DispatchNamespace object { name, namespace, type, outbound }
Inherit object { name, type, old_name, version_id }
Ratelimit object { name, namespace_id, simple, type }
R2Bucket object { bucket_name, name, type, jurisdiction }
jurisdiction: optional "eu" or "fedramp" or "fedramp-high"The jurisdiction of the R2 bucket.
The jurisdiction of the R2 bucket.
SecretKey object { algorithm, format, name, 4 more }
Algorithm-specific key parameters. Learn more.
format: "raw" or "pkcs8" or "spki" or "jwk"Data format of the key. Learn more.
Data format of the key. Learn more.
usages: array of "encrypt" or "decrypt" or "sign" or 5 moreAllowed operations with the key. Learn more.
Allowed operations with the key. Learn more.
Base64-encoded key data. Required if format is “raw”, “pkcs8”, or “spki”.
Key data in JSON Web Key format. Required if format is “jwk”.
Workflow object { name, type, workflow_name, 2 more }
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a compatibility_date.
containers: optional array of object { class_name } List of containers attached to a Worker. Containers can only be attached to Durable Object classes of this Worker script.
List of containers attached to a Worker. Containers can only be attached to Durable Object classes of this Worker script.
The name of the main module in the modules array (e.g. the name of the module that exports a fetch handler).
migrations: optional SingleStepMigration { deleted_classes, new_classes, new_sqlite_classes, 4 more } or object { new_tag, old_tag, steps } Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed.
Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed.
SingleStepMigration object { deleted_classes, new_classes, new_sqlite_classes, 4 more } A single set of migrations to apply.
A single set of migrations to apply.
A list of classes to delete Durable Object namespaces from.
A list of classes to create Durable Object namespaces with SQLite from.
Tag used to verify against the latest migration tag for this Worker. If they don’t match, the upload is rejected.
WorkersMultipleStepMigrations object { new_tag, old_tag, steps }
Tag used to verify against the latest migration tag for this Worker. If they don’t match, the upload is rejected.
Migrations to apply in order.
Migrations to apply in order.
A list of classes to delete Durable Object namespaces from.
A list of classes to create Durable Object namespaces with SQLite from.
modules: optional array of object { content_base64, content_type, name } Code, sourcemaps, and other content used at runtime.
This includes _headers and
_redirects files used to configure
Static Assets. _headers and _redirects files should be
included as modules named _headers and _redirects with content type text/plain.
Code, sourcemaps, and other content used at runtime.
This includes _headers and
_redirects files used to configure
Static Assets. _headers and _redirects files should be
included as modules named _headers and _redirects with content type text/plain.
placement: optional object { mode } or object { region } or object { hostname } or 5 moreConfiguration for Smart Placement. Specify mode=‘smart’ for Smart Placement, or one of region/hostname/host.
Configuration for Smart Placement. Specify mode=‘smart’ for Smart Placement, or one of region/hostname/host.
Mode object { mode }
Enables Smart Placement.
ReturnsExpand Collapse
All routable URLs that always point to this version. Does not include alias URLs, since aliases can be updated to point to a different version.
annotations: optional object { "workers/message", "workers/tag", "workers/triggered_by" } Metadata about the version.
Metadata about the version.
assets: optional object { config, jwt } Configuration for assets within a Worker.
_headers and
_redirects files should be
included as modules named _headers and _redirects with content type text/plain.
Configuration for assets within a Worker.
_headers and
_redirects files should be
included as modules named _headers and _redirects with content type text/plain.
config: optional object { html_handling, not_found_handling, run_worker_first } Configuration for assets within a Worker.
Configuration for assets within a Worker.
html_handling: optional "auto-trailing-slash" or "force-trailing-slash" or "drop-trailing-slash" or "none"Determines the redirects and rewrites of requests for HTML content.
Determines the redirects and rewrites of requests for HTML content.
not_found_handling: optional "none" or "404-page" or "single-page-application"Determines the response when a request does not match a static asset, and there is no Worker script.
Determines the response when a request does not match a static asset, and there is no Worker script.
run_worker_first: optional array of string or booleanContains a list path rules to control routing to either the Worker or assets. Glob (*) and negative (!) rules are supported. Rules must start with either ’/’ or ’!/’. At least one non-negative rule must be provided, and negative rules have higher precedence than non-negative rules.
Contains a list path rules to control routing to either the Worker or assets. Glob (*) and negative (!) rules are supported. Rules must start with either ’/’ or ’!/’. At least one non-negative rule must be provided, and negative rules have higher precedence than non-negative rules.
bindings: optional array of object { name, type } or object { instance_name, name, type, namespace } or object { name, namespace, type } or 32 moreList of bindings attached to a Worker. You can find more about bindings on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings.
List of bindings attached to a Worker. You can find more about bindings on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings.
AISearch object { instance_name, name, type, namespace }
AISearchNamespace object { name, namespace, type }
DispatchNamespace object { name, namespace, type, outbound }
Inherit object { name, type, old_name, version_id }
Ratelimit object { name, namespace_id, simple, type }
R2Bucket object { bucket_name, name, type, jurisdiction }
jurisdiction: optional "eu" or "fedramp" or "fedramp-high"The jurisdiction of the R2 bucket.
The jurisdiction of the R2 bucket.
SecretKey object { algorithm, format, name, 4 more }
Algorithm-specific key parameters. Learn more.
format: "raw" or "pkcs8" or "spki" or "jwk"Data format of the key. Learn more.
Data format of the key. Learn more.
usages: array of "encrypt" or "decrypt" or "sign" or 5 moreAllowed operations with the key. Learn more.
Allowed operations with the key. Learn more.
Base64-encoded key data. Required if format is “raw”, “pkcs8”, or “spki”.
Key data in JSON Web Key format. Required if format is “jwk”.
Workflow object { name, type, workflow_name, 2 more }
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a compatibility_date.
containers: optional array of object { class_name } List of containers attached to a Worker. Containers can only be attached to Durable Object classes of this Worker script.
List of containers attached to a Worker. Containers can only be attached to Durable Object classes of this Worker script.
The name of the main module in the modules array (e.g. the name of the module that exports a fetch handler).
Durable Object migration tag. Set when the version is deployed. Omitted if the version has not been deployed or the Worker does not use Durable Objects.
migrations: optional SingleStepMigration { deleted_classes, new_classes, new_sqlite_classes, 4 more } or object { new_tag, old_tag, steps } Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed.
Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed.
SingleStepMigration object { deleted_classes, new_classes, new_sqlite_classes, 4 more } A single set of migrations to apply.
A single set of migrations to apply.
A list of classes to delete Durable Object namespaces from.
A list of classes to create Durable Object namespaces with SQLite from.
Tag used to verify against the latest migration tag for this Worker. If they don’t match, the upload is rejected.
WorkersMultipleStepMigrations object { new_tag, old_tag, steps }
Tag used to verify against the latest migration tag for this Worker. If they don’t match, the upload is rejected.
Migrations to apply in order.
Migrations to apply in order.
A list of classes to delete Durable Object namespaces from.
A list of classes to create Durable Object namespaces with SQLite from.
modules: optional array of object { content_base64, content_type, name } Code, sourcemaps, and other content used at runtime.
This includes _headers and
_redirects files used to configure
Static Assets. _headers and _redirects files should be
included as modules named _headers and _redirects with content type text/plain.
Code, sourcemaps, and other content used at runtime.
This includes _headers and
_redirects files used to configure
Static Assets. _headers and _redirects files should be
included as modules named _headers and _redirects with content type text/plain.
placement: optional object { mode } or object { region } or object { hostname } or 5 moreConfiguration for Smart Placement. Specify mode=‘smart’ for Smart Placement, or one of region/hostname/host.
Configuration for Smart Placement. Specify mode=‘smart’ for Smart Placement, or one of region/hostname/host.
Mode object { mode }
Enables Smart Placement.
Time in milliseconds spent on Worker startup.
Create Version
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/workers/$WORKER_ID/versions \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-d '{
"bindings": [
{
"name": "MY_ENV_VAR",
"text": "my_data",
"type": "plain_text"
}
],
"compatibility_date": "2021-01-01",
"compatibility_flags": [
"nodejs_compat"
],
"containers": [
{
"class_name": "MyDurableObject"
}
],
"main_module": "index.js",
"usage_model": "standard"
}'{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"created_on": "2019-12-27T18:11:19.117Z",
"number": 0,
"urls": [
"https://9387e76d-my-worker.my-subdomain.workers.dev"
],
"annotations": {
"workers/message": "Fixed bug.",
"workers/tag": "v1.0.1",
"workers/triggered_by": "upload"
},
"assets": {
"config": {
"html_handling": "auto-trailing-slash",
"not_found_handling": "404-page",
"run_worker_first": true
},
"jwt": "jwt"
},
"bindings": [
{
"name": "MY_ENV_VAR",
"text": "my_data",
"type": "plain_text"
}
],
"compatibility_date": "2021-01-01",
"compatibility_flags": [
"nodejs_compat"
],
"containers": [
{
"class_name": "MyDurableObject"
}
],
"limits": {
"cpu_ms": 50,
"subrequests": 1000
},
"main_module": "index.js",
"migration_tag": "v1",
"migrations": {},
"modules": [
{
"content_base64": "ZXhwb3J0IGRlZmF1bHQgewogIGFzeW5jIGZldGNoKHJlcXVlc3QsIGVudiwgY3R4KSB7CiAgICByZXR1cm4gbmV3IFJlc3BvbnNlKCdIZWxsbyBXb3JsZCEnKQogIH0KfQ==",
"content_type": "application/javascript+module",
"name": "index.js"
}
],
"placement": {
"mode": "smart"
},
"source": "wrangler",
"startup_time_ms": 10,
"usage_model": "standard"
},
"success": true
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"created_on": "2019-12-27T18:11:19.117Z",
"number": 0,
"urls": [
"https://9387e76d-my-worker.my-subdomain.workers.dev"
],
"annotations": {
"workers/message": "Fixed bug.",
"workers/tag": "v1.0.1",
"workers/triggered_by": "upload"
},
"assets": {
"config": {
"html_handling": "auto-trailing-slash",
"not_found_handling": "404-page",
"run_worker_first": true
},
"jwt": "jwt"
},
"bindings": [
{
"name": "MY_ENV_VAR",
"text": "my_data",
"type": "plain_text"
}
],
"compatibility_date": "2021-01-01",
"compatibility_flags": [
"nodejs_compat"
],
"containers": [
{
"class_name": "MyDurableObject"
}
],
"limits": {
"cpu_ms": 50,
"subrequests": 1000
},
"main_module": "index.js",
"migration_tag": "v1",
"migrations": {},
"modules": [
{
"content_base64": "ZXhwb3J0IGRlZmF1bHQgewogIGFzeW5jIGZldGNoKHJlcXVlc3QsIGVudiwgY3R4KSB7CiAgICByZXR1cm4gbmV3IFJlc3BvbnNlKCdIZWxsbyBXb3JsZCEnKQogIH0KfQ==",
"content_type": "application/javascript+module",
"name": "index.js"
}
],
"placement": {
"mode": "smart"
},
"source": "wrangler",
"startup_time_ms": 10,
"usage_model": "standard"
},
"success": true
}