Patch Settings
Patch metadata or config, such as bindings or usage model.
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
annotations: Optional[SettingsAnnotations]Annotations for the Worker version. Annotations are not inherited across settings updates; omitting this field means the new version will have no annotations.
Annotations for the Worker version. Annotations are not inherited across settings updates; omitting this field means the new version will have no annotations.
bindings: Optional[Iterable[SettingsBinding]]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 SettingsBindingWorkersBindingKindAISearch: …
class SettingsBindingWorkersBindingKindAISearchNamespace: …
class SettingsBindingWorkersBindingKindDispatchNamespace: …
class SettingsBindingWorkersBindingKindInherit: …
class SettingsBindingWorkersBindingKindRatelimit: …
class SettingsBindingWorkersBindingKindR2Bucket: …
jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]The jurisdiction of the R2 bucket.
The jurisdiction of the R2 bucket.
class SettingsBindingWorkersBindingKindSecretKey: …
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 SettingsBindingWorkersBindingKindWorkflow: …
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.
migrations: Optional[SettingsMigrations]Migrations to apply for Durable Objects associated with this Worker.
Migrations to apply for Durable Objects associated with this Worker.
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 SettingsMigrationsWorkersMultipleStepMigrations: …
Tag used to verify against the latest migration tag for this Worker. If they don’t match, the upload is rejected.
observability: Optional[SettingsObservability]Observability settings for the Worker.
Observability settings for the Worker.
The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
logs: Optional[SettingsObservabilityLogs]Log settings for the Worker.
Log settings for the Worker.
Whether invocation logs are enabled for the Worker.
placement: Optional[SettingsPlacement]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 SettingsPlacementMode: …
Enables Smart Placement.
ReturnsExpand Collapse
class ScriptAndVersionSettingEditResponse: …
annotations: Optional[Annotations]Annotations for the Worker version. Annotations are not inherited across settings updates; omitting this field means the new version will have no annotations.
Annotations for the Worker version. Annotations are not inherited across settings updates; omitting this field means the new version will have no annotations.
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.
migrations: Optional[Migrations]Migrations to apply for Durable Objects associated with this Worker.
Migrations to apply for Durable Objects associated with this Worker.
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.
observability: Optional[Observability]Observability settings for the Worker.
Observability settings for the Worker.
The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
logs: Optional[ObservabilityLogs]Log settings for the Worker.
Log settings for the Worker.
Whether invocation logs are enabled for the Worker.
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.
Patch Settings
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
response = client.workers.scripts.script_and_version_settings.edit(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(response.annotations){
"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": {
"annotations": {
"workers/message": "Fixed bug.",
"workers/tag": "v1.0.1",
"workers/triggered_by": "upload"
},
"bindings": [
{
"name": "MY_ENV_VAR",
"text": "my_data",
"type": "plain_text"
}
],
"compatibility_date": "2021-01-01",
"compatibility_flags": [
"nodejs_compat"
],
"limits": {
"cpu_ms": 50
},
"logpush": false,
"observability": {
"enabled": true,
"head_sampling_rate": 0.1,
"logs": {
"enabled": true,
"invocation_logs": true,
"destinations": [
"cloudflare"
],
"head_sampling_rate": 0.1,
"persist": true
},
"traces": {
"destinations": [
"cloudflare"
],
"enabled": true,
"head_sampling_rate": 0.1,
"persist": true
}
},
"placement": {
"mode": "smart"
},
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"service": "my-log-consumer",
"environment": "production",
"namespace": "my-namespace"
}
],
"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": {
"annotations": {
"workers/message": "Fixed bug.",
"workers/tag": "v1.0.1",
"workers/triggered_by": "upload"
},
"bindings": [
{
"name": "MY_ENV_VAR",
"text": "my_data",
"type": "plain_text"
}
],
"compatibility_date": "2021-01-01",
"compatibility_flags": [
"nodejs_compat"
],
"limits": {
"cpu_ms": 50
},
"logpush": false,
"observability": {
"enabled": true,
"head_sampling_rate": 0.1,
"logs": {
"enabled": true,
"invocation_logs": true,
"destinations": [
"cloudflare"
],
"head_sampling_rate": 0.1,
"persist": true
},
"traces": {
"destinations": [
"cloudflare"
],
"enabled": true,
"head_sampling_rate": 0.1,
"persist": true
}
},
"placement": {
"mode": "smart"
},
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"service": "my-log-consumer",
"environment": "production",
"namespace": "my-namespace"
}
],
"usage_model": "standard"
},
"success": true
}