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 WriteParametersExpand Collapse
Metadata about the version.
Metadata about the version.
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[AssetsConfig]Configuration for assets within a Worker.
Configuration for assets within a Worker.
html_handling: Optional[Literal["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "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[Literal["none", "404-page", "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[Union[Sequence[str], bool]]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.
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[Iterable[Binding]]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.
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.
class BindingWorkersBindingKindAISearch: …
class BindingWorkersBindingKindAISearchNamespace: …
class BindingWorkersBindingKindDispatchNamespace: …
class BindingWorkersBindingKindInherit: …
class BindingWorkersBindingKindRatelimit: …
class BindingWorkersBindingKindR2Bucket: …
jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]The jurisdiction of the R2 bucket.
The jurisdiction of the R2 bucket.
class BindingWorkersBindingKindSecretKey: …
Algorithm-specific key parameters. Learn more.
format: Literal["raw", "pkcs8", "spki", "jwk"]Data format of the key. Learn more.
Data format of the key. Learn more.
usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]Allowed operations with the key. Learn more.
Allowed operations with the key. Learn more.
Key data in JSON Web Key format. Required if format is “jwk”.
class BindingWorkersBindingKindWorkflow: …
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[Iterable[Container]]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 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.
class SingleStepMigration: …A single set of migrations to apply.
A single set of migrations to apply.
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.
class MigrationsWorkersMultipleStepMigrations: …
Tag used to verify against the latest migration tag for this Worker. If they don’t match, the upload is rejected.
modules: Optional[Iterable[Module]]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.
Configuration 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.
class PlacementMode: …
Enables Smart Placement.
ReturnsExpand Collapse
class Version: …
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[Annotations]Metadata about the version.
Metadata about the version.
assets: Optional[Assets]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[AssetsConfig]Configuration for assets within a Worker.
Configuration for assets within a Worker.
html_handling: Optional[Literal["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "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[Literal["none", "404-page", "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[Union[List[str], bool, null]]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.
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[List[Binding]]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.
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.
class BindingWorkersBindingKindAISearch: …
class BindingWorkersBindingKindAISearchNamespace: …
class BindingWorkersBindingKindDispatchNamespace: …
class BindingWorkersBindingKindInherit: …
class BindingWorkersBindingKindRatelimit: …
class BindingWorkersBindingKindR2Bucket: …
jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]The jurisdiction of the R2 bucket.
The jurisdiction of the R2 bucket.
class BindingWorkersBindingKindSecretKey: …
Algorithm-specific key parameters. Learn more.
format: Literal["raw", "pkcs8", "spki", "jwk"]Data format of the key. Learn more.
Data format of the key. Learn more.
usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]Allowed operations with the key. Learn more.
Allowed operations with the key. Learn more.
Key data in JSON Web Key format. Required if format is “jwk”.
class BindingWorkersBindingKindWorkflow: …
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[List[Container]]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[Migrations]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.
class SingleStepMigration: …A single set of migrations to apply.
A single set of migrations to apply.
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.
class MigrationsWorkersMultipleStepMigrations: …
Tag used to verify against the latest migration tag for this Worker. If they don’t match, the upload is rejected.
modules: Optional[List[Module]]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[Placement]Configuration 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.
class PlacementMode: …
Enables Smart Placement.
Time in milliseconds spent on Worker startup.
Create Version
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
version = client.workers.beta.workers.versions.create(
worker_id="worker_id",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(version.id){
"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
}