# Workers
## Domain Types
### Migration Step
- `class MigrationStep: …`
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
### Single Step Migration
- `class SingleStepMigration: …`
A single set of migrations to apply.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
### Worker Metadata
- `class WorkerMetadata: …`
JSON-encoded metadata about the uploaded parts and Worker configuration.
- `body_part: Optional[str]`
Name of the part in the multipart request that contains the script (e.g. the file adding a listener to the `fetch` event). Indicates a `service worker syntax` Worker.
- `main_module: Optional[str]`
Name of the part in the multipart request that contains the main module (e.g. the file exporting a `fetch` handler). Indicates a `module syntax` Worker.
# Beta
# Workers
## List Workers
`workers.beta.workers.list(WorkerListParams**kwargs) -> SyncV4PagePaginationArray[Worker]`
**get** `/accounts/{account_id}/workers/workers`
List all Workers for an account.
### Parameters
- `account_id: str`
Identifier.
- `order: Optional[Literal["asc", "desc"]]`
Sort direction.
- `"asc"`
- `"desc"`
- `order_by: Optional[Literal["deployed_on", "updated_on", "created_on", "name"]]`
Property to sort results by.
- `"deployed_on"`
- `"updated_on"`
- `"created_on"`
- `"name"`
- `page: Optional[int]`
Current page.
- `per_page: Optional[int]`
Items per-page.
### Returns
- `class Worker: …`
- `id: str`
Immutable ID of the Worker.
- `created_on: datetime`
When the Worker was created.
- `logpush: bool`
Whether logpush is enabled for the Worker.
- `name: str`
Name of the Worker.
- `observability: Observability`
Observability settings for the Worker.
- `enabled: Optional[bool]`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `logs: Optional[ObservabilityLogs]`
Log settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `enabled: Optional[bool]`
Whether logs are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `invocation_logs: Optional[bool]`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `references: References`
Other resources that reference the Worker and depend on it existing.
- `dispatch_namespace_outbounds: List[ReferencesDispatchNamespaceOutbound]`
Other Workers that reference the Worker as an outbound for a dispatch namespace.
- `namespace_id: str`
ID of the dispatch namespace.
- `namespace_name: str`
Name of the dispatch namespace.
- `worker_id: str`
ID of the Worker using the dispatch namespace.
- `worker_name: str`
Name of the Worker using the dispatch namespace.
- `domains: List[ReferencesDomain]`
Custom domains connected to the Worker.
- `id: str`
ID of the custom domain.
- `certificate_id: str`
ID of the TLS certificate issued for the custom domain.
- `hostname: str`
Full hostname of the custom domain, including the zone name.
- `zone_id: str`
ID of the zone.
- `zone_name: str`
Name of the zone.
- `durable_objects: List[ReferencesDurableObject]`
Other Workers that reference Durable Object classes implemented by the Worker.
- `namespace_id: str`
ID of the Durable Object namespace being used.
- `namespace_name: str`
Name of the Durable Object namespace being used.
- `worker_id: str`
ID of the Worker using the Durable Object implementation.
- `worker_name: str`
Name of the Worker using the Durable Object implementation.
- `queues: List[ReferencesQueue]`
Queues that send messages to the Worker.
- `queue_consumer_id: str`
ID of the queue consumer configuration.
- `queue_id: str`
ID of the queue.
- `queue_name: str`
Name of the queue.
- `workers: List[ReferencesWorker]`
Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/).
- `id: str`
ID of the referencing Worker.
- `name: str`
Name of the referencing Worker.
- `subdomain: Subdomain`
Subdomain settings for the Worker.
- `enabled: Optional[bool]`
Whether the *.workers.dev subdomain is enabled for the Worker.
- `previews_enabled: Optional[bool]`
Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.
- `tags: List[str]`
Tags associated with the Worker.
- `tail_consumers: List[TailConsumer]`
Other Workers that should consume logs from the Worker.
- `name: str`
Name of the consumer Worker.
- `updated_on: datetime`
When the Worker was most recently updated.
- `deployed_on: Optional[datetime]`
When the Worker's most recent deployment was created. `null` if the Worker has never been deployed.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
page = client.workers.beta.workers.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
page = page.result[0]
print(page.id)
```
#### Response
```json
{
"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": "e8f70fdbc8b1fb0b8ddb1af166186758",
"created_on": "2019-12-27T18:11:19.117Z",
"logpush": true,
"name": "my-worker",
"observability": {
"enabled": true,
"head_sampling_rate": 1,
"logs": {
"destinations": [
"string"
],
"enabled": true,
"head_sampling_rate": 1,
"invocation_logs": true,
"persist": true
},
"traces": {
"destinations": [
"string"
],
"enabled": true,
"head_sampling_rate": 1,
"persist": true
}
},
"references": {
"dispatch_namespace_outbounds": [
{
"namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"namespace_name": "my-dispatch-namespace",
"worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"worker_name": "my-worker"
}
],
"domains": [
{
"id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"certificate_id": "certificate_id",
"hostname": "my-worker.example.com",
"zone_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"zone_name": "example.com"
}
],
"durable_objects": [
{
"namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"namespace_name": "my-durable-object-namespace",
"worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"worker_name": "my-worker"
}
],
"queues": [
{
"queue_consumer_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"queue_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"queue_name": "my-queue"
}
],
"workers": [
{
"id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"name": "my-worker"
}
]
},
"subdomain": {
"enabled": true,
"previews_enabled": true
},
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"name": "my-tail-consumer"
}
],
"updated_on": "2019-12-27T18:11:19.117Z",
"deployed_on": "2019-12-27T18:11:19.117Z"
}
],
"success": true,
"result_info": {
"count": 1,
"page": 1,
"per_page": 20,
"total_count": 2000,
"total_pages": 100
}
}
```
## Get Worker
`workers.beta.workers.get(strworker_id, WorkerGetParams**kwargs) -> Worker`
**get** `/accounts/{account_id}/workers/workers/{worker_id}`
Get details about a specific Worker.
### Parameters
- `account_id: str`
Identifier.
- `worker_id: str`
Identifier for the Worker, which can be ID or name.
### Returns
- `class Worker: …`
- `id: str`
Immutable ID of the Worker.
- `created_on: datetime`
When the Worker was created.
- `logpush: bool`
Whether logpush is enabled for the Worker.
- `name: str`
Name of the Worker.
- `observability: Observability`
Observability settings for the Worker.
- `enabled: Optional[bool]`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `logs: Optional[ObservabilityLogs]`
Log settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `enabled: Optional[bool]`
Whether logs are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `invocation_logs: Optional[bool]`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `references: References`
Other resources that reference the Worker and depend on it existing.
- `dispatch_namespace_outbounds: List[ReferencesDispatchNamespaceOutbound]`
Other Workers that reference the Worker as an outbound for a dispatch namespace.
- `namespace_id: str`
ID of the dispatch namespace.
- `namespace_name: str`
Name of the dispatch namespace.
- `worker_id: str`
ID of the Worker using the dispatch namespace.
- `worker_name: str`
Name of the Worker using the dispatch namespace.
- `domains: List[ReferencesDomain]`
Custom domains connected to the Worker.
- `id: str`
ID of the custom domain.
- `certificate_id: str`
ID of the TLS certificate issued for the custom domain.
- `hostname: str`
Full hostname of the custom domain, including the zone name.
- `zone_id: str`
ID of the zone.
- `zone_name: str`
Name of the zone.
- `durable_objects: List[ReferencesDurableObject]`
Other Workers that reference Durable Object classes implemented by the Worker.
- `namespace_id: str`
ID of the Durable Object namespace being used.
- `namespace_name: str`
Name of the Durable Object namespace being used.
- `worker_id: str`
ID of the Worker using the Durable Object implementation.
- `worker_name: str`
Name of the Worker using the Durable Object implementation.
- `queues: List[ReferencesQueue]`
Queues that send messages to the Worker.
- `queue_consumer_id: str`
ID of the queue consumer configuration.
- `queue_id: str`
ID of the queue.
- `queue_name: str`
Name of the queue.
- `workers: List[ReferencesWorker]`
Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/).
- `id: str`
ID of the referencing Worker.
- `name: str`
Name of the referencing Worker.
- `subdomain: Subdomain`
Subdomain settings for the Worker.
- `enabled: Optional[bool]`
Whether the *.workers.dev subdomain is enabled for the Worker.
- `previews_enabled: Optional[bool]`
Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.
- `tags: List[str]`
Tags associated with the Worker.
- `tail_consumers: List[TailConsumer]`
Other Workers that should consume logs from the Worker.
- `name: str`
Name of the consumer Worker.
- `updated_on: datetime`
When the Worker was most recently updated.
- `deployed_on: Optional[datetime]`
When the Worker's most recent deployment was created. `null` if the Worker has never been deployed.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
worker = client.workers.beta.workers.get(
worker_id="worker_id",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(worker.id)
```
#### Response
```json
{
"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": "e8f70fdbc8b1fb0b8ddb1af166186758",
"created_on": "2019-12-27T18:11:19.117Z",
"logpush": true,
"name": "my-worker",
"observability": {
"enabled": true,
"head_sampling_rate": 1,
"logs": {
"destinations": [
"string"
],
"enabled": true,
"head_sampling_rate": 1,
"invocation_logs": true,
"persist": true
},
"traces": {
"destinations": [
"string"
],
"enabled": true,
"head_sampling_rate": 1,
"persist": true
}
},
"references": {
"dispatch_namespace_outbounds": [
{
"namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"namespace_name": "my-dispatch-namespace",
"worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"worker_name": "my-worker"
}
],
"domains": [
{
"id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"certificate_id": "certificate_id",
"hostname": "my-worker.example.com",
"zone_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"zone_name": "example.com"
}
],
"durable_objects": [
{
"namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"namespace_name": "my-durable-object-namespace",
"worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"worker_name": "my-worker"
}
],
"queues": [
{
"queue_consumer_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"queue_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"queue_name": "my-queue"
}
],
"workers": [
{
"id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"name": "my-worker"
}
]
},
"subdomain": {
"enabled": true,
"previews_enabled": true
},
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"name": "my-tail-consumer"
}
],
"updated_on": "2019-12-27T18:11:19.117Z",
"deployed_on": "2019-12-27T18:11:19.117Z"
},
"success": true
}
```
## Create Worker
`workers.beta.workers.create(WorkerCreateParams**kwargs) -> Worker`
**post** `/accounts/{account_id}/workers/workers`
Create a new Worker.
### Parameters
- `account_id: str`
Identifier.
- `name: str`
Name of the Worker.
- `logpush: Optional[bool]`
Whether logpush is enabled for the Worker.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: Optional[bool]`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `logs: Optional[ObservabilityLogs]`
Log settings for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where logs will be exported to.
- `enabled: Optional[bool]`
Whether logs are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `invocation_logs: Optional[bool]`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `subdomain: Optional[Subdomain]`
Subdomain settings for the Worker.
- `enabled: Optional[bool]`
Whether the *.workers.dev subdomain is enabled for the Worker.
- `previews_enabled: Optional[bool]`
Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.
- `tags: Optional[Sequence[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[Iterable[TailConsumer]]`
Other Workers that should consume logs from the Worker.
- `name: str`
Name of the consumer Worker.
### Returns
- `class Worker: …`
- `id: str`
Immutable ID of the Worker.
- `created_on: datetime`
When the Worker was created.
- `logpush: bool`
Whether logpush is enabled for the Worker.
- `name: str`
Name of the Worker.
- `observability: Observability`
Observability settings for the Worker.
- `enabled: Optional[bool]`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `logs: Optional[ObservabilityLogs]`
Log settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `enabled: Optional[bool]`
Whether logs are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `invocation_logs: Optional[bool]`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `references: References`
Other resources that reference the Worker and depend on it existing.
- `dispatch_namespace_outbounds: List[ReferencesDispatchNamespaceOutbound]`
Other Workers that reference the Worker as an outbound for a dispatch namespace.
- `namespace_id: str`
ID of the dispatch namespace.
- `namespace_name: str`
Name of the dispatch namespace.
- `worker_id: str`
ID of the Worker using the dispatch namespace.
- `worker_name: str`
Name of the Worker using the dispatch namespace.
- `domains: List[ReferencesDomain]`
Custom domains connected to the Worker.
- `id: str`
ID of the custom domain.
- `certificate_id: str`
ID of the TLS certificate issued for the custom domain.
- `hostname: str`
Full hostname of the custom domain, including the zone name.
- `zone_id: str`
ID of the zone.
- `zone_name: str`
Name of the zone.
- `durable_objects: List[ReferencesDurableObject]`
Other Workers that reference Durable Object classes implemented by the Worker.
- `namespace_id: str`
ID of the Durable Object namespace being used.
- `namespace_name: str`
Name of the Durable Object namespace being used.
- `worker_id: str`
ID of the Worker using the Durable Object implementation.
- `worker_name: str`
Name of the Worker using the Durable Object implementation.
- `queues: List[ReferencesQueue]`
Queues that send messages to the Worker.
- `queue_consumer_id: str`
ID of the queue consumer configuration.
- `queue_id: str`
ID of the queue.
- `queue_name: str`
Name of the queue.
- `workers: List[ReferencesWorker]`
Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/).
- `id: str`
ID of the referencing Worker.
- `name: str`
Name of the referencing Worker.
- `subdomain: Subdomain`
Subdomain settings for the Worker.
- `enabled: Optional[bool]`
Whether the *.workers.dev subdomain is enabled for the Worker.
- `previews_enabled: Optional[bool]`
Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.
- `tags: List[str]`
Tags associated with the Worker.
- `tail_consumers: List[TailConsumer]`
Other Workers that should consume logs from the Worker.
- `name: str`
Name of the consumer Worker.
- `updated_on: datetime`
When the Worker was most recently updated.
- `deployed_on: Optional[datetime]`
When the Worker's most recent deployment was created. `null` if the Worker has never been deployed.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
worker = client.workers.beta.workers.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
name="my-worker",
)
print(worker.id)
```
#### Response
```json
{
"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": "e8f70fdbc8b1fb0b8ddb1af166186758",
"created_on": "2019-12-27T18:11:19.117Z",
"logpush": true,
"name": "my-worker",
"observability": {
"enabled": true,
"head_sampling_rate": 1,
"logs": {
"destinations": [
"string"
],
"enabled": true,
"head_sampling_rate": 1,
"invocation_logs": true,
"persist": true
},
"traces": {
"destinations": [
"string"
],
"enabled": true,
"head_sampling_rate": 1,
"persist": true
}
},
"references": {
"dispatch_namespace_outbounds": [
{
"namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"namespace_name": "my-dispatch-namespace",
"worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"worker_name": "my-worker"
}
],
"domains": [
{
"id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"certificate_id": "certificate_id",
"hostname": "my-worker.example.com",
"zone_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"zone_name": "example.com"
}
],
"durable_objects": [
{
"namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"namespace_name": "my-durable-object-namespace",
"worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"worker_name": "my-worker"
}
],
"queues": [
{
"queue_consumer_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"queue_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"queue_name": "my-queue"
}
],
"workers": [
{
"id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"name": "my-worker"
}
]
},
"subdomain": {
"enabled": true,
"previews_enabled": true
},
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"name": "my-tail-consumer"
}
],
"updated_on": "2019-12-27T18:11:19.117Z",
"deployed_on": "2019-12-27T18:11:19.117Z"
},
"success": true
}
```
## Update Worker
`workers.beta.workers.update(strworker_id, WorkerUpdateParams**kwargs) -> Worker`
**put** `/accounts/{account_id}/workers/workers/{worker_id}`
Perform a complete replacement of a Worker, where omitted properties are set to their default values. This is the exact same as the Create Worker endpoint, but operates on an existing Worker. To perform a partial update instead, use the Edit Worker endpoint.
### Parameters
- `account_id: str`
Identifier.
- `worker_id: str`
Identifier for the Worker, which can be ID or name.
- `name: str`
Name of the Worker.
- `logpush: Optional[bool]`
Whether logpush is enabled for the Worker.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: Optional[bool]`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `logs: Optional[ObservabilityLogs]`
Log settings for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where logs will be exported to.
- `enabled: Optional[bool]`
Whether logs are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `invocation_logs: Optional[bool]`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `subdomain: Optional[Subdomain]`
Subdomain settings for the Worker.
- `enabled: Optional[bool]`
Whether the *.workers.dev subdomain is enabled for the Worker.
- `previews_enabled: Optional[bool]`
Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.
- `tags: Optional[Sequence[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[Iterable[TailConsumer]]`
Other Workers that should consume logs from the Worker.
- `name: str`
Name of the consumer Worker.
### Returns
- `class Worker: …`
- `id: str`
Immutable ID of the Worker.
- `created_on: datetime`
When the Worker was created.
- `logpush: bool`
Whether logpush is enabled for the Worker.
- `name: str`
Name of the Worker.
- `observability: Observability`
Observability settings for the Worker.
- `enabled: Optional[bool]`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `logs: Optional[ObservabilityLogs]`
Log settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `enabled: Optional[bool]`
Whether logs are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `invocation_logs: Optional[bool]`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `references: References`
Other resources that reference the Worker and depend on it existing.
- `dispatch_namespace_outbounds: List[ReferencesDispatchNamespaceOutbound]`
Other Workers that reference the Worker as an outbound for a dispatch namespace.
- `namespace_id: str`
ID of the dispatch namespace.
- `namespace_name: str`
Name of the dispatch namespace.
- `worker_id: str`
ID of the Worker using the dispatch namespace.
- `worker_name: str`
Name of the Worker using the dispatch namespace.
- `domains: List[ReferencesDomain]`
Custom domains connected to the Worker.
- `id: str`
ID of the custom domain.
- `certificate_id: str`
ID of the TLS certificate issued for the custom domain.
- `hostname: str`
Full hostname of the custom domain, including the zone name.
- `zone_id: str`
ID of the zone.
- `zone_name: str`
Name of the zone.
- `durable_objects: List[ReferencesDurableObject]`
Other Workers that reference Durable Object classes implemented by the Worker.
- `namespace_id: str`
ID of the Durable Object namespace being used.
- `namespace_name: str`
Name of the Durable Object namespace being used.
- `worker_id: str`
ID of the Worker using the Durable Object implementation.
- `worker_name: str`
Name of the Worker using the Durable Object implementation.
- `queues: List[ReferencesQueue]`
Queues that send messages to the Worker.
- `queue_consumer_id: str`
ID of the queue consumer configuration.
- `queue_id: str`
ID of the queue.
- `queue_name: str`
Name of the queue.
- `workers: List[ReferencesWorker]`
Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/).
- `id: str`
ID of the referencing Worker.
- `name: str`
Name of the referencing Worker.
- `subdomain: Subdomain`
Subdomain settings for the Worker.
- `enabled: Optional[bool]`
Whether the *.workers.dev subdomain is enabled for the Worker.
- `previews_enabled: Optional[bool]`
Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.
- `tags: List[str]`
Tags associated with the Worker.
- `tail_consumers: List[TailConsumer]`
Other Workers that should consume logs from the Worker.
- `name: str`
Name of the consumer Worker.
- `updated_on: datetime`
When the Worker was most recently updated.
- `deployed_on: Optional[datetime]`
When the Worker's most recent deployment was created. `null` if the Worker has never been deployed.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
worker = client.workers.beta.workers.update(
worker_id="worker_id",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
name="my-worker",
)
print(worker.id)
```
#### Response
```json
{
"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": "e8f70fdbc8b1fb0b8ddb1af166186758",
"created_on": "2019-12-27T18:11:19.117Z",
"logpush": true,
"name": "my-worker",
"observability": {
"enabled": true,
"head_sampling_rate": 1,
"logs": {
"destinations": [
"string"
],
"enabled": true,
"head_sampling_rate": 1,
"invocation_logs": true,
"persist": true
},
"traces": {
"destinations": [
"string"
],
"enabled": true,
"head_sampling_rate": 1,
"persist": true
}
},
"references": {
"dispatch_namespace_outbounds": [
{
"namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"namespace_name": "my-dispatch-namespace",
"worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"worker_name": "my-worker"
}
],
"domains": [
{
"id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"certificate_id": "certificate_id",
"hostname": "my-worker.example.com",
"zone_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"zone_name": "example.com"
}
],
"durable_objects": [
{
"namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"namespace_name": "my-durable-object-namespace",
"worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"worker_name": "my-worker"
}
],
"queues": [
{
"queue_consumer_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"queue_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"queue_name": "my-queue"
}
],
"workers": [
{
"id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"name": "my-worker"
}
]
},
"subdomain": {
"enabled": true,
"previews_enabled": true
},
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"name": "my-tail-consumer"
}
],
"updated_on": "2019-12-27T18:11:19.117Z",
"deployed_on": "2019-12-27T18:11:19.117Z"
},
"success": true
}
```
## Edit Worker
`workers.beta.workers.edit(strworker_id, WorkerEditParams**kwargs) -> Worker`
**patch** `/accounts/{account_id}/workers/workers/{worker_id}`
Perform a partial update on a Worker, where omitted properties are left unchanged from their current values.
### Parameters
- `account_id: str`
Identifier.
- `worker_id: str`
Identifier for the Worker, which can be ID or name.
- `logpush: bool`
Whether logpush is enabled for the Worker.
- `name: str`
Name of the Worker.
- `observability: Observability`
Observability settings for the Worker.
- `enabled: Optional[bool]`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `logs: Optional[ObservabilityLogs]`
Log settings for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where logs will be exported to.
- `enabled: Optional[bool]`
Whether logs are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `invocation_logs: Optional[bool]`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `subdomain: Subdomain`
Subdomain settings for the Worker.
- `enabled: Optional[bool]`
Whether the *.workers.dev subdomain is enabled for the Worker.
- `previews_enabled: Optional[bool]`
Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.
- `tags: Sequence[str]`
Tags associated with the Worker.
- `tail_consumers: Iterable[TailConsumer]`
Other Workers that should consume logs from the Worker.
- `name: str`
Name of the consumer Worker.
### Returns
- `class Worker: …`
- `id: str`
Immutable ID of the Worker.
- `created_on: datetime`
When the Worker was created.
- `logpush: bool`
Whether logpush is enabled for the Worker.
- `name: str`
Name of the Worker.
- `observability: Observability`
Observability settings for the Worker.
- `enabled: Optional[bool]`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `logs: Optional[ObservabilityLogs]`
Log settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `enabled: Optional[bool]`
Whether logs are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `invocation_logs: Optional[bool]`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `references: References`
Other resources that reference the Worker and depend on it existing.
- `dispatch_namespace_outbounds: List[ReferencesDispatchNamespaceOutbound]`
Other Workers that reference the Worker as an outbound for a dispatch namespace.
- `namespace_id: str`
ID of the dispatch namespace.
- `namespace_name: str`
Name of the dispatch namespace.
- `worker_id: str`
ID of the Worker using the dispatch namespace.
- `worker_name: str`
Name of the Worker using the dispatch namespace.
- `domains: List[ReferencesDomain]`
Custom domains connected to the Worker.
- `id: str`
ID of the custom domain.
- `certificate_id: str`
ID of the TLS certificate issued for the custom domain.
- `hostname: str`
Full hostname of the custom domain, including the zone name.
- `zone_id: str`
ID of the zone.
- `zone_name: str`
Name of the zone.
- `durable_objects: List[ReferencesDurableObject]`
Other Workers that reference Durable Object classes implemented by the Worker.
- `namespace_id: str`
ID of the Durable Object namespace being used.
- `namespace_name: str`
Name of the Durable Object namespace being used.
- `worker_id: str`
ID of the Worker using the Durable Object implementation.
- `worker_name: str`
Name of the Worker using the Durable Object implementation.
- `queues: List[ReferencesQueue]`
Queues that send messages to the Worker.
- `queue_consumer_id: str`
ID of the queue consumer configuration.
- `queue_id: str`
ID of the queue.
- `queue_name: str`
Name of the queue.
- `workers: List[ReferencesWorker]`
Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/).
- `id: str`
ID of the referencing Worker.
- `name: str`
Name of the referencing Worker.
- `subdomain: Subdomain`
Subdomain settings for the Worker.
- `enabled: Optional[bool]`
Whether the *.workers.dev subdomain is enabled for the Worker.
- `previews_enabled: Optional[bool]`
Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.
- `tags: List[str]`
Tags associated with the Worker.
- `tail_consumers: List[TailConsumer]`
Other Workers that should consume logs from the Worker.
- `name: str`
Name of the consumer Worker.
- `updated_on: datetime`
When the Worker was most recently updated.
- `deployed_on: Optional[datetime]`
When the Worker's most recent deployment was created. `null` if the Worker has never been deployed.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
worker = client.workers.beta.workers.edit(
worker_id="worker_id",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
logpush=True,
name="my-worker",
observability={},
subdomain={},
tags=["my-team", "my-public-api"],
tail_consumers=[{
"name": "my-tail-consumer"
}],
)
print(worker.id)
```
#### Response
```json
{
"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": "e8f70fdbc8b1fb0b8ddb1af166186758",
"created_on": "2019-12-27T18:11:19.117Z",
"logpush": true,
"name": "my-worker",
"observability": {
"enabled": true,
"head_sampling_rate": 1,
"logs": {
"destinations": [
"string"
],
"enabled": true,
"head_sampling_rate": 1,
"invocation_logs": true,
"persist": true
},
"traces": {
"destinations": [
"string"
],
"enabled": true,
"head_sampling_rate": 1,
"persist": true
}
},
"references": {
"dispatch_namespace_outbounds": [
{
"namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"namespace_name": "my-dispatch-namespace",
"worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"worker_name": "my-worker"
}
],
"domains": [
{
"id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"certificate_id": "certificate_id",
"hostname": "my-worker.example.com",
"zone_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"zone_name": "example.com"
}
],
"durable_objects": [
{
"namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"namespace_name": "my-durable-object-namespace",
"worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"worker_name": "my-worker"
}
],
"queues": [
{
"queue_consumer_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"queue_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"queue_name": "my-queue"
}
],
"workers": [
{
"id": "e8f70fdbc8b1fb0b8ddb1af166186758",
"name": "my-worker"
}
]
},
"subdomain": {
"enabled": true,
"previews_enabled": true
},
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"name": "my-tail-consumer"
}
],
"updated_on": "2019-12-27T18:11:19.117Z",
"deployed_on": "2019-12-27T18:11:19.117Z"
},
"success": true
}
```
## Delete Worker
`workers.beta.workers.delete(strworker_id, WorkerDeleteParams**kwargs) -> WorkerDeleteResponse`
**delete** `/accounts/{account_id}/workers/workers/{worker_id}`
Delete a Worker and all its associated resources (versions, deployments, etc.).
### Parameters
- `account_id: str`
Identifier.
- `worker_id: str`
Identifier for the Worker, which can be ID or name.
### Returns
- `class WorkerDeleteResponse: …`
- `errors: List[Error]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[ErrorSource]`
- `pointer: Optional[str]`
- `messages: List[Message]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[MessageSource]`
- `pointer: Optional[str]`
- `success: Literal[true]`
Whether the API call was successful.
- `true`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
worker = client.workers.beta.workers.delete(
worker_id="worker_id",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(worker.errors)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true
}
```
## Domain Types
### Worker
- `class Worker: …`
- `id: str`
Immutable ID of the Worker.
- `created_on: datetime`
When the Worker was created.
- `logpush: bool`
Whether logpush is enabled for the Worker.
- `name: str`
Name of the Worker.
- `observability: Observability`
Observability settings for the Worker.
- `enabled: Optional[bool]`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `logs: Optional[ObservabilityLogs]`
Log settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `enabled: Optional[bool]`
Whether logs are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `invocation_logs: Optional[bool]`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `references: References`
Other resources that reference the Worker and depend on it existing.
- `dispatch_namespace_outbounds: List[ReferencesDispatchNamespaceOutbound]`
Other Workers that reference the Worker as an outbound for a dispatch namespace.
- `namespace_id: str`
ID of the dispatch namespace.
- `namespace_name: str`
Name of the dispatch namespace.
- `worker_id: str`
ID of the Worker using the dispatch namespace.
- `worker_name: str`
Name of the Worker using the dispatch namespace.
- `domains: List[ReferencesDomain]`
Custom domains connected to the Worker.
- `id: str`
ID of the custom domain.
- `certificate_id: str`
ID of the TLS certificate issued for the custom domain.
- `hostname: str`
Full hostname of the custom domain, including the zone name.
- `zone_id: str`
ID of the zone.
- `zone_name: str`
Name of the zone.
- `durable_objects: List[ReferencesDurableObject]`
Other Workers that reference Durable Object classes implemented by the Worker.
- `namespace_id: str`
ID of the Durable Object namespace being used.
- `namespace_name: str`
Name of the Durable Object namespace being used.
- `worker_id: str`
ID of the Worker using the Durable Object implementation.
- `worker_name: str`
Name of the Worker using the Durable Object implementation.
- `queues: List[ReferencesQueue]`
Queues that send messages to the Worker.
- `queue_consumer_id: str`
ID of the queue consumer configuration.
- `queue_id: str`
ID of the queue.
- `queue_name: str`
Name of the queue.
- `workers: List[ReferencesWorker]`
Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/).
- `id: str`
ID of the referencing Worker.
- `name: str`
Name of the referencing Worker.
- `subdomain: Subdomain`
Subdomain settings for the Worker.
- `enabled: Optional[bool]`
Whether the *.workers.dev subdomain is enabled for the Worker.
- `previews_enabled: Optional[bool]`
Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.
- `tags: List[str]`
Tags associated with the Worker.
- `tail_consumers: List[TailConsumer]`
Other Workers that should consume logs from the Worker.
- `name: str`
Name of the consumer Worker.
- `updated_on: datetime`
When the Worker was most recently updated.
- `deployed_on: Optional[datetime]`
When the Worker's most recent deployment was created. `null` if the Worker has never been deployed.
### Worker Delete Response
- `class WorkerDeleteResponse: …`
- `errors: List[Error]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[ErrorSource]`
- `pointer: Optional[str]`
- `messages: List[Message]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[MessageSource]`
- `pointer: Optional[str]`
- `success: Literal[true]`
Whether the API call was successful.
- `true`
# Versions
## List Versions
`workers.beta.workers.versions.list(strworker_id, VersionListParams**kwargs) -> SyncV4PagePaginationArray[Version]`
**get** `/accounts/{account_id}/workers/workers/{worker_id}/versions`
List all versions for a Worker.
### Parameters
- `account_id: str`
Identifier.
- `worker_id: str`
Identifier for the Worker, which can be ID or name.
- `page: Optional[int]`
Current page.
- `per_page: Optional[int]`
Items per-page.
### Returns
- `class Version: …`
- `id: str`
Version identifier.
- `created_on: datetime`
When the version was created.
- `number: int`
The integer version number, starting from one.
- `urls: List[str]`
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.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the version.
- `assets: Optional[Assets]`
Configuration for assets within a Worker.
[`_headers`](https://developers.cloudflare.com/workers/static-assets/headers/#custom-headers) and
[`_redirects`](https://developers.cloudflare.com/workers/static-assets/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.
- `html_handling: Optional[Literal["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]]`
Determines the redirects and rewrites of requests for HTML content.
- `"auto-trailing-slash"`
- `"force-trailing-slash"`
- `"drop-trailing-slash"`
- `"none"`
- `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.
- `"none"`
- `"404-page"`
- `"single-page-application"`
- `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.
- `List[str]`
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.
- `bool`
Enables routing to always invoke the Worker script ahead of all requests. When true, this is equivalent to `["/*"]` in the string array version of this field.
- `jwt: Optional[str]`
Token provided upon successful upload of all files from a registered manifest.
- `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.
- `class BindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class BindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class BindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class BindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class BindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class BindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class BindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class BindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class BindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[BindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[BindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[BindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class BindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class BindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class BindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class BindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class BindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class BindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class BindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class BindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class BindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class BindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class BindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class BindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: BindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class BindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class BindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class BindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class BindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class BindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class BindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class BindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class BindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class BindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class BindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class BindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class BindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class BindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class BindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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.
- `class_name: str`
Select which Durable Object class should get this container attached.
- `limits: Optional[Limits]`
Resource limits enforced at runtime.
- `cpu_ms: Optional[int]`
CPU time limit in milliseconds.
- `subrequests: Optional[int]`
Subrequest limit per request.
- `main_module: Optional[str]`
The name of the main module in the `modules` array (e.g. the name of the module that exports a `fetch` handler).
- `migration_tag: Optional[str]`
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.
- `class SingleStepMigration: …`
A single set of migrations to apply.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `class MigrationsWorkersMultipleStepMigrations: …`
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `steps: Optional[List[MigrationStep]]`
Migrations to apply in order.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `modules: Optional[List[Module]]`
Code, sourcemaps, and other content used at runtime.
This includes [`_headers`](https://developers.cloudflare.com/workers/static-assets/headers/#custom-headers) and
[`_redirects`](https://developers.cloudflare.com/workers/static-assets/redirects/) files used to configure
[Static Assets](https://developers.cloudflare.com/workers/static-assets/). `_headers` and `_redirects` files should be
included as modules named `_headers` and `_redirects` with content type `text/plain`.
- `content_base64: str`
The base64-encoded module content.
- `content_type: str`
The content type of the module.
- `name: str`
The name of the module.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementMode: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `class PlacementRegion: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementHost: …`
- `host: str`
TCP host and port for targeted placement.
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `source: Optional[str]`
The client used to create the version.
- `startup_time_ms: Optional[int]`
Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time).
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the version.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
page = client.workers.beta.workers.versions.list(
worker_id="worker_id",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
page = page.result[0]
print(page.id)
```
#### Response
```json
{
"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,
"result_info": {
"count": 1,
"page": 1,
"per_page": 20,
"total_count": 2000,
"total_pages": 100
}
}
```
## Get Version
`workers.beta.workers.versions.get(strversion_id, VersionGetParams**kwargs) -> Version`
**get** `/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}`
Get details about a specific version.
### Parameters
- `account_id: str`
Identifier.
- `worker_id: str`
Identifier for the Worker, which can be ID or name.
- `version_id: str`
Identifier for the version, which can be a UUID, a UUID prefix (minimum length 8), or the literal "latest" to operate on the most recently created version.
- `include: Optional[Literal["modules"]]`
Whether to include the `modules` property of the version in the response, which contains code and sourcemap content and may add several megabytes to the response size.
- `"modules"`
### Returns
- `class Version: …`
- `id: str`
Version identifier.
- `created_on: datetime`
When the version was created.
- `number: int`
The integer version number, starting from one.
- `urls: List[str]`
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.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the version.
- `assets: Optional[Assets]`
Configuration for assets within a Worker.
[`_headers`](https://developers.cloudflare.com/workers/static-assets/headers/#custom-headers) and
[`_redirects`](https://developers.cloudflare.com/workers/static-assets/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.
- `html_handling: Optional[Literal["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]]`
Determines the redirects and rewrites of requests for HTML content.
- `"auto-trailing-slash"`
- `"force-trailing-slash"`
- `"drop-trailing-slash"`
- `"none"`
- `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.
- `"none"`
- `"404-page"`
- `"single-page-application"`
- `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.
- `List[str]`
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.
- `bool`
Enables routing to always invoke the Worker script ahead of all requests. When true, this is equivalent to `["/*"]` in the string array version of this field.
- `jwt: Optional[str]`
Token provided upon successful upload of all files from a registered manifest.
- `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.
- `class BindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class BindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class BindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class BindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class BindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class BindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class BindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class BindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class BindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[BindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[BindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[BindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class BindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class BindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class BindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class BindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class BindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class BindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class BindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class BindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class BindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class BindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class BindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class BindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: BindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class BindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class BindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class BindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class BindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class BindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class BindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class BindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class BindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class BindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class BindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class BindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class BindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class BindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class BindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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.
- `class_name: str`
Select which Durable Object class should get this container attached.
- `limits: Optional[Limits]`
Resource limits enforced at runtime.
- `cpu_ms: Optional[int]`
CPU time limit in milliseconds.
- `subrequests: Optional[int]`
Subrequest limit per request.
- `main_module: Optional[str]`
The name of the main module in the `modules` array (e.g. the name of the module that exports a `fetch` handler).
- `migration_tag: Optional[str]`
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.
- `class SingleStepMigration: …`
A single set of migrations to apply.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `class MigrationsWorkersMultipleStepMigrations: …`
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `steps: Optional[List[MigrationStep]]`
Migrations to apply in order.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `modules: Optional[List[Module]]`
Code, sourcemaps, and other content used at runtime.
This includes [`_headers`](https://developers.cloudflare.com/workers/static-assets/headers/#custom-headers) and
[`_redirects`](https://developers.cloudflare.com/workers/static-assets/redirects/) files used to configure
[Static Assets](https://developers.cloudflare.com/workers/static-assets/). `_headers` and `_redirects` files should be
included as modules named `_headers` and `_redirects` with content type `text/plain`.
- `content_base64: str`
The base64-encoded module content.
- `content_type: str`
The content type of the module.
- `name: str`
The name of the module.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementMode: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `class PlacementRegion: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementHost: …`
- `host: str`
TCP host and port for targeted placement.
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `source: Optional[str]`
The client used to create the version.
- `startup_time_ms: Optional[int]`
Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time).
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the version.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Example
```python
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.get(
version_id="version_id",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
worker_id="worker_id",
)
print(version.id)
```
#### Response
```json
{
"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
}
```
## Create Version
`workers.beta.workers.versions.create(strworker_id, VersionCreateParams**kwargs) -> Version`
**post** `/accounts/{account_id}/workers/workers/{worker_id}/versions`
Create a new version.
### Parameters
- `account_id: str`
Identifier.
- `worker_id: str`
Identifier for the Worker, which can be ID or name.
- `deploy: Optional[bool]`
If true, a deployment will be created that sends 100% of traffic to the new version.
- `annotations: Optional[Annotations]`
Metadata about the version.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the version.
- `assets: Optional[Assets]`
Configuration for assets within a Worker.
[`_headers`](https://developers.cloudflare.com/workers/static-assets/headers/#custom-headers) and
[`_redirects`](https://developers.cloudflare.com/workers/static-assets/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.
- `html_handling: Optional[Literal["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]]`
Determines the redirects and rewrites of requests for HTML content.
- `"auto-trailing-slash"`
- `"force-trailing-slash"`
- `"drop-trailing-slash"`
- `"none"`
- `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.
- `"none"`
- `"404-page"`
- `"single-page-application"`
- `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.
- `Sequence[str]`
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.
- `bool`
Enables routing to always invoke the Worker script ahead of all requests. When true, this is equivalent to `["/*"]` in the string array version of this field.
- `jwt: Optional[str]`
Token provided upon successful upload of all files from a registered manifest.
- `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.
- `class BindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class BindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class BindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class BindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class BindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class BindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class BindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class BindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class BindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[BindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[Iterable[BindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[BindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class BindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class BindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class BindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class BindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class BindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class BindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class BindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class BindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class BindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class BindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class BindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class BindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: BindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class BindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class BindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class BindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[Sequence[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[Sequence[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class BindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class BindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class BindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class BindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class BindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class BindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class BindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class BindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class BindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class BindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class BindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[Sequence[str]]`
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.
- `class_name: str`
Select which Durable Object class should get this container attached.
- `limits: Optional[Limits]`
Resource limits enforced at runtime.
- `cpu_ms: Optional[int]`
CPU time limit in milliseconds.
- `subrequests: Optional[int]`
Subrequest limit per request.
- `main_module: Optional[str]`
The name of the main module in the `modules` array (e.g. the name of the module that exports a `fetch` handler).
- `migrations: Optional[Migrations]`
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.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `class MigrationsWorkersMultipleStepMigrations: …`
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `steps: Optional[Iterable[MigrationStepParam]]`
Migrations to apply in order.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `modules: Optional[Iterable[Module]]`
Code, sourcemaps, and other content used at runtime.
This includes [`_headers`](https://developers.cloudflare.com/workers/static-assets/headers/#custom-headers) and
[`_redirects`](https://developers.cloudflare.com/workers/static-assets/redirects/) files used to configure
[Static Assets](https://developers.cloudflare.com/workers/static-assets/). `_headers` and `_redirects` files should be
included as modules named `_headers` and `_redirects` with content type `text/plain`.
- `content_base64: Union[str, Base64FileInput]`
The base64-encoded module content.
- `content_type: str`
The content type of the module.
- `name: str`
The name of the module.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementMode: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `class PlacementRegion: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementHost: …`
- `host: str`
TCP host and port for targeted placement.
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: Iterable[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the version.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Returns
- `class Version: …`
- `id: str`
Version identifier.
- `created_on: datetime`
When the version was created.
- `number: int`
The integer version number, starting from one.
- `urls: List[str]`
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.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the version.
- `assets: Optional[Assets]`
Configuration for assets within a Worker.
[`_headers`](https://developers.cloudflare.com/workers/static-assets/headers/#custom-headers) and
[`_redirects`](https://developers.cloudflare.com/workers/static-assets/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.
- `html_handling: Optional[Literal["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]]`
Determines the redirects and rewrites of requests for HTML content.
- `"auto-trailing-slash"`
- `"force-trailing-slash"`
- `"drop-trailing-slash"`
- `"none"`
- `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.
- `"none"`
- `"404-page"`
- `"single-page-application"`
- `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.
- `List[str]`
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.
- `bool`
Enables routing to always invoke the Worker script ahead of all requests. When true, this is equivalent to `["/*"]` in the string array version of this field.
- `jwt: Optional[str]`
Token provided upon successful upload of all files from a registered manifest.
- `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.
- `class BindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class BindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class BindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class BindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class BindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class BindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class BindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class BindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class BindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[BindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[BindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[BindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class BindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class BindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class BindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class BindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class BindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class BindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class BindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class BindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class BindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class BindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class BindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class BindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: BindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class BindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class BindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class BindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class BindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class BindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class BindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class BindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class BindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class BindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class BindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class BindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class BindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class BindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class BindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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.
- `class_name: str`
Select which Durable Object class should get this container attached.
- `limits: Optional[Limits]`
Resource limits enforced at runtime.
- `cpu_ms: Optional[int]`
CPU time limit in milliseconds.
- `subrequests: Optional[int]`
Subrequest limit per request.
- `main_module: Optional[str]`
The name of the main module in the `modules` array (e.g. the name of the module that exports a `fetch` handler).
- `migration_tag: Optional[str]`
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.
- `class SingleStepMigration: …`
A single set of migrations to apply.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `class MigrationsWorkersMultipleStepMigrations: …`
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `steps: Optional[List[MigrationStep]]`
Migrations to apply in order.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `modules: Optional[List[Module]]`
Code, sourcemaps, and other content used at runtime.
This includes [`_headers`](https://developers.cloudflare.com/workers/static-assets/headers/#custom-headers) and
[`_redirects`](https://developers.cloudflare.com/workers/static-assets/redirects/) files used to configure
[Static Assets](https://developers.cloudflare.com/workers/static-assets/). `_headers` and `_redirects` files should be
included as modules named `_headers` and `_redirects` with content type `text/plain`.
- `content_base64: str`
The base64-encoded module content.
- `content_type: str`
The content type of the module.
- `name: str`
The name of the module.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementMode: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `class PlacementRegion: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementHost: …`
- `host: str`
TCP host and port for targeted placement.
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `source: Optional[str]`
The client used to create the version.
- `startup_time_ms: Optional[int]`
Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time).
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the version.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Example
```python
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)
```
#### Response
```json
{
"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
}
```
## Delete Version
`workers.beta.workers.versions.delete(strversion_id, VersionDeleteParams**kwargs) -> VersionDeleteResponse`
**delete** `/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}`
Delete a version.
### Parameters
- `account_id: str`
Identifier.
- `worker_id: str`
Identifier for the Worker, which can be ID or name.
- `version_id: str`
Identifier for the version, which can be a UUID, a UUID prefix (minimum length 8), or the literal "latest" to operate on the most recently created version.
### Returns
- `class VersionDeleteResponse: …`
- `errors: List[Error]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[ErrorSource]`
- `pointer: Optional[str]`
- `messages: List[Message]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[MessageSource]`
- `pointer: Optional[str]`
- `success: Literal[true]`
Whether the API call was successful.
- `true`
### Example
```python
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.delete(
version_id="version_id",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
worker_id="worker_id",
)
print(version.errors)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true
}
```
## Domain Types
### Version
- `class Version: …`
- `id: str`
Version identifier.
- `created_on: datetime`
When the version was created.
- `number: int`
The integer version number, starting from one.
- `urls: List[str]`
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.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the version.
- `assets: Optional[Assets]`
Configuration for assets within a Worker.
[`_headers`](https://developers.cloudflare.com/workers/static-assets/headers/#custom-headers) and
[`_redirects`](https://developers.cloudflare.com/workers/static-assets/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.
- `html_handling: Optional[Literal["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]]`
Determines the redirects and rewrites of requests for HTML content.
- `"auto-trailing-slash"`
- `"force-trailing-slash"`
- `"drop-trailing-slash"`
- `"none"`
- `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.
- `"none"`
- `"404-page"`
- `"single-page-application"`
- `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.
- `List[str]`
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.
- `bool`
Enables routing to always invoke the Worker script ahead of all requests. When true, this is equivalent to `["/*"]` in the string array version of this field.
- `jwt: Optional[str]`
Token provided upon successful upload of all files from a registered manifest.
- `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.
- `class BindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class BindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class BindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class BindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class BindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class BindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class BindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class BindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class BindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[BindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[BindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[BindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class BindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class BindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class BindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class BindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class BindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class BindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class BindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class BindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class BindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class BindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class BindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class BindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: BindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class BindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class BindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class BindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class BindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class BindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class BindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class BindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class BindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class BindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class BindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class BindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class BindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class BindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class BindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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.
- `class_name: str`
Select which Durable Object class should get this container attached.
- `limits: Optional[Limits]`
Resource limits enforced at runtime.
- `cpu_ms: Optional[int]`
CPU time limit in milliseconds.
- `subrequests: Optional[int]`
Subrequest limit per request.
- `main_module: Optional[str]`
The name of the main module in the `modules` array (e.g. the name of the module that exports a `fetch` handler).
- `migration_tag: Optional[str]`
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.
- `class SingleStepMigration: …`
A single set of migrations to apply.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `class MigrationsWorkersMultipleStepMigrations: …`
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `steps: Optional[List[MigrationStep]]`
Migrations to apply in order.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `modules: Optional[List[Module]]`
Code, sourcemaps, and other content used at runtime.
This includes [`_headers`](https://developers.cloudflare.com/workers/static-assets/headers/#custom-headers) and
[`_redirects`](https://developers.cloudflare.com/workers/static-assets/redirects/) files used to configure
[Static Assets](https://developers.cloudflare.com/workers/static-assets/). `_headers` and `_redirects` files should be
included as modules named `_headers` and `_redirects` with content type `text/plain`.
- `content_base64: str`
The base64-encoded module content.
- `content_type: str`
The content type of the module.
- `name: str`
The name of the module.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementMode: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `class PlacementRegion: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementHost: …`
- `host: str`
TCP host and port for targeted placement.
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `source: Optional[str]`
The client used to create the version.
- `startup_time_ms: Optional[int]`
Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time).
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the version.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Version Delete Response
- `class VersionDeleteResponse: …`
- `errors: List[Error]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[ErrorSource]`
- `pointer: Optional[str]`
- `messages: List[Message]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[MessageSource]`
- `pointer: Optional[str]`
- `success: Literal[true]`
Whether the API call was successful.
- `true`
# Routes
## List Routes
`workers.routes.list(RouteListParams**kwargs) -> SyncSinglePage[RouteListResponse]`
**get** `/zones/{zone_id}/workers/routes`
Returns routes for a zone.
### Parameters
- `zone_id: str`
Identifier.
### Returns
- `class RouteListResponse: …`
- `id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
page = client.workers.routes.list(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
page = page.result[0]
print(page.id)
```
#### Response
```json
{
"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": "023e105f4ecef8ad9ca31a8372d0c353",
"pattern": "example.com/*",
"script": "my-workers-script"
}
],
"success": true
}
```
## Get Route
`workers.routes.get(strroute_id, RouteGetParams**kwargs) -> RouteGetResponse`
**get** `/zones/{zone_id}/workers/routes/{route_id}`
Returns information about a route, including URL pattern and Worker.
### Parameters
- `zone_id: str`
Identifier.
- `route_id: str`
Identifier.
### Returns
- `class RouteGetResponse: …`
- `id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
route = client.workers.routes.get(
route_id="023e105f4ecef8ad9ca31a8372d0c353",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(route.id)
```
#### Response
```json
{
"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": "023e105f4ecef8ad9ca31a8372d0c353",
"pattern": "example.com/*",
"script": "my-workers-script"
},
"success": true
}
```
## Create Route
`workers.routes.create(RouteCreateParams**kwargs) -> RouteCreateResponse`
**post** `/zones/{zone_id}/workers/routes`
Creates a route that maps a URL pattern to a Worker.
### Parameters
- `zone_id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
### Returns
- `class RouteCreateResponse: …`
- `id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
route = client.workers.routes.create(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
pattern="example.com/*",
)
print(route.id)
```
#### Response
```json
{
"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": "023e105f4ecef8ad9ca31a8372d0c353",
"pattern": "example.com/*",
"script": "my-workers-script"
},
"success": true
}
```
## Update Route
`workers.routes.update(strroute_id, RouteUpdateParams**kwargs) -> RouteUpdateResponse`
**put** `/zones/{zone_id}/workers/routes/{route_id}`
Updates the URL pattern or Worker associated with a route.
### Parameters
- `zone_id: str`
Identifier.
- `route_id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
### Returns
- `class RouteUpdateResponse: …`
- `id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
route = client.workers.routes.update(
route_id="023e105f4ecef8ad9ca31a8372d0c353",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
pattern="example.com/*",
)
print(route.id)
```
#### Response
```json
{
"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": "023e105f4ecef8ad9ca31a8372d0c353",
"pattern": "example.com/*",
"script": "my-workers-script"
},
"success": true
}
```
## Delete Route
`workers.routes.delete(strroute_id, RouteDeleteParams**kwargs) -> RouteDeleteResponse`
**delete** `/zones/{zone_id}/workers/routes/{route_id}`
Deletes a route.
### Parameters
- `zone_id: str`
Identifier.
- `route_id: str`
Identifier.
### Returns
- `class RouteDeleteResponse: …`
- `id: Optional[str]`
Identifier.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
route = client.workers.routes.delete(
route_id="023e105f4ecef8ad9ca31a8372d0c353",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(route.id)
```
#### Response
```json
{
"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": "023e105f4ecef8ad9ca31a8372d0c353"
},
"success": true
}
```
## Domain Types
### Route List Response
- `class RouteListResponse: …`
- `id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
### Route Get Response
- `class RouteGetResponse: …`
- `id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
### Route Create Response
- `class RouteCreateResponse: …`
- `id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
### Route Update Response
- `class RouteUpdateResponse: …`
- `id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
### Route Delete Response
- `class RouteDeleteResponse: …`
- `id: Optional[str]`
Identifier.
# Assets
# Upload
## Upload Assets
`workers.assets.upload.create(UploadCreateParams**kwargs) -> UploadCreateResponse`
**post** `/accounts/{account_id}/workers/assets/upload`
Upload assets ahead of creating a Worker version. To learn more about the direct uploads of assets, see https://developers.cloudflare.com/workers/static-assets/direct-upload/.
### Parameters
- `account_id: str`
Identifier.
- `base64: Literal[true]`
Whether the file contents are base64-encoded. Must be `true`.
- `true`
- `body: Dict[str, str]`
### Returns
- `class UploadCreateResponse: …`
- `jwt: Optional[str]`
A "completion" JWT which can be redeemed when creating a Worker version.
### Example
```python
from cloudflare import Cloudflare
client = Cloudflare()
upload = client.workers.assets.upload.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
base64=True,
body={
"foo": "string"
},
)
print(upload.jwt)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {
"jwt": "jwt"
}
}
```
## Domain Types
### Upload Create Response
- `class UploadCreateResponse: …`
- `jwt: Optional[str]`
A "completion" JWT which can be redeemed when creating a Worker version.
# Scripts
## List Workers
`workers.scripts.list(ScriptListParams**kwargs) -> SyncSinglePage[ScriptListResponse]`
**get** `/accounts/{account_id}/workers/scripts`
Fetch a list of uploaded workers.
### Parameters
- `account_id: str`
Identifier.
- `tags: Optional[str]`
Filter scripts by tags. Format: comma-separated list of tag:allowed pairs where allowed is 'yes' or 'no'.
### Returns
- `class ScriptListResponse: …`
- `id: Optional[str]`
The name used to identify the script.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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`.
- `created_on: Optional[datetime]`
When the script was created.
- `etag: Optional[str]`
Hashed script content, can be used in a If-None-Match header when updating.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the default export.
- `has_assets: Optional[bool]`
Whether a Worker contains assets.
- `has_modules: Optional[bool]`
Whether a Worker contains modules.
- `last_deployed_from: Optional[str]`
The client most recently used to deploy this Worker.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `migration_tag: Optional[str]`
The tag of the Durable Object migration that was most recently applied for this Worker.
- `modified_on: Optional[datetime]`
When the script was last modified.
- `named_handlers: Optional[List[NamedHandler]]`
Named exports, such as Durable Object class implementations and named entrypoints.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the named export.
- `name: Optional[str]`
The name of the export.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementUnionMember0: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember1: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember2: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember3: …`
- `host: str`
TCP host and port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `placement_mode: Optional[Literal["smart", "targeted"]]`
- `"smart"`
- `"targeted"`
- `placement_status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `routes: Optional[List[Route]]`
Routes associated with the Worker.
- `id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
- `tag: Optional[str]`
The immutable ID of the script.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
page = client.workers.scripts.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
page = page.result[0]
print(page.id)
```
#### Response
```json
{
"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": "my-workers-script",
"compatibility_date": "2021-01-01",
"compatibility_flags": [
"nodejs_compat"
],
"created_on": "2017-01-01T00:00:00Z",
"etag": "ea95132c15732412d22c1476fa83f27a",
"handlers": [
"fetch",
"scheduled"
],
"has_assets": false,
"has_modules": false,
"last_deployed_from": "wrangler",
"logpush": false,
"migration_tag": "v1",
"modified_on": "2017-01-01T00:00:00Z",
"named_handlers": [
{
"handlers": [
"class"
],
"name": "MyDurableObject"
}
],
"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",
"last_analyzed_at": "2025-01-01T00:00:00Z",
"status": "SUCCESS"
},
"placement_mode": "smart",
"placement_status": "SUCCESS",
"routes": [
{
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"pattern": "example.com/*",
"script": "my-workers-script"
}
],
"tag": "e8f70fdbc8b1fb0b8ddb1af166186758",
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"service": "my-log-consumer",
"environment": "production",
"namespace": "my-namespace"
}
],
"usage_model": "standard"
}
],
"success": true
}
```
## Search Workers
`workers.scripts.search(ScriptSearchParams**kwargs) -> ScriptSearchResponse`
**get** `/accounts/{account_id}/workers/scripts-search`
Search for Workers in an account.
### Parameters
- `account_id: str`
Identifier.
- `id: Optional[str]`
Worker ID (also called tag) to search for. Only exact matches are returned.
- `name: Optional[str]`
Worker name to search for. Both exact and partial matches are returned.
- `order_by: Optional[Literal["created_on", "modified_on", "name"]]`
Property to sort results by. Results are sorted in ascending order.
- `"created_on"`
- `"modified_on"`
- `"name"`
- `page: Optional[int]`
Current page.
- `per_page: Optional[int]`
Items per page.
### Returns
- `List[ScriptSearchResponseItem]`
- `id: str`
Identifier.
- `created_on: datetime`
When the script was created.
- `modified_on: datetime`
When the script was last modified.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `environment_is_default: Optional[bool]`
Whether the environment is the default environment.
- `environment_name: Optional[str]`
Name of the environment.
- `service_name: Optional[str]`
Name of the service.
### Example
```python
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.search(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(response)
```
#### Response
```json
{
"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": "023e105f4ecef8ad9ca31a8372d0c353",
"created_on": "2017-01-01T00:00:00Z",
"modified_on": "2017-01-01T00:00:00Z",
"script_name": "this-is_my_script-01",
"environment_is_default": true,
"environment_name": "production",
"service_name": "my-service"
}
],
"success": true,
"result_info": {
"count": 1,
"page": 1,
"per_page": 20,
"total_count": 2000,
"total_pages": 100
}
}
```
## Download Worker
`workers.scripts.get(strscript_name, ScriptGetParams**kwargs) -> ScriptGetResponse`
**get** `/accounts/{account_id}/workers/scripts/{script_name}`
Fetch raw script content for your worker. Note this is the original script content, not JSON encoded.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
### Returns
- `str`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
script = client.workers.scripts.get(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(script)
```
## Upload Worker Module
`workers.scripts.update(strscript_name, ScriptUpdateParams**kwargs) -> ScriptUpdateResponse`
**put** `/accounts/{account_id}/workers/scripts/{script_name}`
Upload a worker module. You can find more about the multipart metadata on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `metadata: Metadata`
JSON-encoded metadata about the uploaded parts and Worker configuration.
- `annotations: Optional[MetadataAnnotations]`
Annotations for the version created by this upload.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `assets: Optional[MetadataAssets]`
Configuration for assets within a Worker.
- `config: Optional[MetadataAssetsConfig]`
Configuration for assets within a Worker.
- `_headers: Optional[str]`
The contents of a _headers file (used to attach custom headers on asset responses).
- `_redirects: Optional[str]`
The contents of a _redirects file (used to apply redirects or proxy paths ahead of asset serving).
- `html_handling: Optional[Literal["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]]`
Determines the redirects and rewrites of requests for HTML content.
- `"auto-trailing-slash"`
- `"force-trailing-slash"`
- `"drop-trailing-slash"`
- `"none"`
- `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.
- `"none"`
- `"404-page"`
- `"single-page-application"`
- `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.
- `Sequence[str]`
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.
- `bool`
Enables routing to always invoke the Worker script ahead of all requests. When true, this is equivalent to `["/*"]` in the string array version of this field.
- `serve_directly: Optional[bool]`
When true and the incoming request matches an asset, that will be served instead of invoking the Worker script. When false, requests will always invoke the Worker script.
- `jwt: Optional[str]`
Token provided upon successful upload of all files from a registered manifest.
- `bindings: Optional[Iterable[MetadataBinding]]`
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 MetadataBindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class MetadataBindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class MetadataBindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class MetadataBindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class MetadataBindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class MetadataBindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class MetadataBindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class MetadataBindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class MetadataBindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[MetadataBindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[Iterable[MetadataBindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[MetadataBindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class MetadataBindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class MetadataBindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class MetadataBindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class MetadataBindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class MetadataBindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class MetadataBindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class MetadataBindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class MetadataBindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class MetadataBindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class MetadataBindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class MetadataBindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class MetadataBindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: MetadataBindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class MetadataBindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class MetadataBindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class MetadataBindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[Sequence[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[Sequence[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class MetadataBindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class MetadataBindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class MetadataBindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class MetadataBindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class MetadataBindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class MetadataBindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class MetadataBindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class MetadataBindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class MetadataBindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class MetadataBindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class MetadataBindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `body_part: Optional[str]`
Name of the uploaded file that contains the script (e.g. the file adding a listener to the `fetch` event). Indicates a `service worker syntax` Worker.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[Sequence[str]]`
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`.
- `keep_assets: Optional[bool]`
Retain assets which exist for a previously uploaded Worker version; used in lieu of providing a completion token.
- `keep_bindings: Optional[Sequence[str]]`
List of binding types to keep from previous_upload.
- `limits: Optional[MetadataLimits]`
Limits to apply for this Worker.
- `cpu_ms: Optional[int]`
The amount of CPU time this Worker can use in milliseconds.
- `subrequests: Optional[int]`
The number of subrequests this Worker can make per request.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `main_module: Optional[str]`
Name of the uploaded file that contains the main module (e.g. the file exporting a `fetch` handler). Indicates a `module syntax` Worker.
- `migrations: Optional[MetadataMigrations]`
Migrations to apply for Durable Objects associated with this Worker.
- `class SingleStepMigration: …`
A single set of migrations to apply.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `class MetadataMigrationsWorkersMultipleStepMigrations: …`
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `steps: Optional[Iterable[MigrationStepParam]]`
Migrations to apply in order.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `observability: Optional[MetadataObservability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `logs: Optional[MetadataObservabilityLogs]`
Log settings for the Worker.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[MetadataObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[MetadataPlacement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class MetadataPlacementUnionMember0: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `last_analyzed_at: Optional[Union[str, datetime]]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class MetadataPlacementUnionMember1: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[Union[str, datetime]]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class MetadataPlacementUnionMember2: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `last_analyzed_at: Optional[Union[str, datetime]]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class MetadataPlacementUnionMember3: …`
- `host: str`
TCP host and port for targeted placement.
- `last_analyzed_at: Optional[Union[str, datetime]]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class MetadataPlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[Union[str, datetime]]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class MetadataPlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[Union[str, datetime]]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class MetadataPlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[Union[str, datetime]]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class MetadataPlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: Iterable[MetadataPlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class MetadataPlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class MetadataPlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class MetadataPlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `last_analyzed_at: Optional[Union[str, datetime]]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `tags: Optional[Sequence[str]]`
List of strings to use as tags for this Worker.
- `tail_consumers: Optional[Iterable[ConsumerScriptParam]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
- `bindings_inherit: Optional[Literal["strict"]]`
When set to "strict", the upload will fail if any `inherit` type bindings cannot be resolved against the previous version of the Worker. Without this, unresolvable inherit bindings are silently dropped.
- `"strict"`
- `files: Optional[Sequence[FileTypes]]`
An array of modules (often JavaScript files) comprising a Worker script. At least one module must be present and referenced in the metadata as `main_module` or `body_part` by filename.
Possible Content-Type(s) are: `application/javascript+module`, `text/javascript+module`, `application/javascript`, `text/javascript`, `text/x-python`, `text/x-python-requirement`, `application/wasm`, `text/plain`, `application/octet-stream`, `application/source-map`.
### Returns
- `class ScriptUpdateResponse: …`
- `startup_time_ms: int`
- `id: Optional[str]`
The name used to identify the script.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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`.
- `created_on: Optional[datetime]`
When the script was created.
- `entry_point: Optional[str]`
The entry point for the script.
- `etag: Optional[str]`
Hashed script content, can be used in a If-None-Match header when updating.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the default export.
- `has_assets: Optional[bool]`
Whether a Worker contains assets.
- `has_modules: Optional[bool]`
Whether a Worker contains modules.
- `last_deployed_from: Optional[str]`
The client most recently used to deploy this Worker.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `migration_tag: Optional[str]`
The tag of the Durable Object migration that was most recently applied for this Worker.
- `modified_on: Optional[datetime]`
When the script was last modified.
- `named_handlers: Optional[List[NamedHandler]]`
Named exports, such as Durable Object class implementations and named entrypoints.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the named export.
- `name: Optional[str]`
The name of the export.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementUnionMember0: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember1: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember2: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember3: …`
- `host: str`
TCP host and port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `placement_mode: Optional[Literal["smart", "targeted"]]`
- `"smart"`
- `"targeted"`
- `placement_status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `tag: Optional[str]`
The immutable ID of the script.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
script = client.workers.scripts.update(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
metadata={},
)
print(script.id)
```
#### Response
```json
{
"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": {
"startup_time_ms": 10,
"id": "this-is_my_script-01",
"compatibility_date": "2021-01-01",
"compatibility_flags": [
"nodejs_compat"
],
"created_on": "2022-05-05T05:15:11.602148Z",
"entry_point": "index.js",
"etag": "777f24a43bef5f69174aa69ceaf1dea67968d510a31d1vw3e49d34a0187c06d1",
"handlers": [
"fetch"
],
"has_assets": false,
"has_modules": false,
"last_deployed_from": "wrangler",
"logpush": false,
"migration_tag": "v1",
"modified_on": "2022-05-20T19:02:56.446492Z",
"named_handlers": [
{
"handlers": [
"class"
],
"name": "MyDurableObject"
}
],
"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",
"last_analyzed_at": "2025-01-01T00:00:00Z",
"status": "SUCCESS"
},
"placement_mode": "smart",
"placement_status": "SUCCESS",
"tag": "e8f70fdbc8b1fb0b8ddb1af166186758",
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"service": "my-log-consumer",
"environment": "production",
"namespace": "my-namespace"
}
],
"usage_model": "standard"
},
"success": true
}
```
## Delete Worker
`workers.scripts.delete(strscript_name, ScriptDeleteParams**kwargs) -> object`
**delete** `/accounts/{account_id}/workers/scripts/{script_name}`
Delete your worker. This call has no response body on a successful delete.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `force: Optional[bool]`
If set to true, delete will not be stopped by associated service binding, durable object, or other binding. Any of these associated bindings/durable objects will be deleted along with the script.
### Returns
- `object`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
script = client.workers.scripts.delete(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(script)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {}
}
```
## Domain Types
### Script
- `class Script: …`
- `id: Optional[str]`
The name used to identify the script.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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`.
- `created_on: Optional[datetime]`
When the script was created.
- `etag: Optional[str]`
Hashed script content, can be used in a If-None-Match header when updating.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the default export.
- `has_assets: Optional[bool]`
Whether a Worker contains assets.
- `has_modules: Optional[bool]`
Whether a Worker contains modules.
- `last_deployed_from: Optional[str]`
The client most recently used to deploy this Worker.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `migration_tag: Optional[str]`
The tag of the Durable Object migration that was most recently applied for this Worker.
- `modified_on: Optional[datetime]`
When the script was last modified.
- `named_handlers: Optional[List[NamedHandler]]`
Named exports, such as Durable Object class implementations and named entrypoints.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the named export.
- `name: Optional[str]`
The name of the export.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementUnionMember0: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember1: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember2: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember3: …`
- `host: str`
TCP host and port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `placement_mode: Optional[Literal["smart", "targeted"]]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `"smart"`
- `"targeted"`
- `placement_status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `tag: Optional[str]`
The immutable ID of the script.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Script Setting
- `class ScriptSetting: …`
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
### Script List Response
- `class ScriptListResponse: …`
- `id: Optional[str]`
The name used to identify the script.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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`.
- `created_on: Optional[datetime]`
When the script was created.
- `etag: Optional[str]`
Hashed script content, can be used in a If-None-Match header when updating.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the default export.
- `has_assets: Optional[bool]`
Whether a Worker contains assets.
- `has_modules: Optional[bool]`
Whether a Worker contains modules.
- `last_deployed_from: Optional[str]`
The client most recently used to deploy this Worker.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `migration_tag: Optional[str]`
The tag of the Durable Object migration that was most recently applied for this Worker.
- `modified_on: Optional[datetime]`
When the script was last modified.
- `named_handlers: Optional[List[NamedHandler]]`
Named exports, such as Durable Object class implementations and named entrypoints.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the named export.
- `name: Optional[str]`
The name of the export.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementUnionMember0: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember1: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember2: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember3: …`
- `host: str`
TCP host and port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `placement_mode: Optional[Literal["smart", "targeted"]]`
- `"smart"`
- `"targeted"`
- `placement_status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `routes: Optional[List[Route]]`
Routes associated with the Worker.
- `id: str`
Identifier.
- `pattern: str`
Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).
- `script: Optional[str]`
Name of the script to run if the route matches.
- `tag: Optional[str]`
The immutable ID of the script.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Script Search Response
- `List[ScriptSearchResponseItem]`
- `id: str`
Identifier.
- `created_on: datetime`
When the script was created.
- `modified_on: datetime`
When the script was last modified.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `environment_is_default: Optional[bool]`
Whether the environment is the default environment.
- `environment_name: Optional[str]`
Name of the environment.
- `service_name: Optional[str]`
Name of the service.
### Script Get Response
- `str`
### Script Update Response
- `class ScriptUpdateResponse: …`
- `startup_time_ms: int`
- `id: Optional[str]`
The name used to identify the script.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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`.
- `created_on: Optional[datetime]`
When the script was created.
- `entry_point: Optional[str]`
The entry point for the script.
- `etag: Optional[str]`
Hashed script content, can be used in a If-None-Match header when updating.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the default export.
- `has_assets: Optional[bool]`
Whether a Worker contains assets.
- `has_modules: Optional[bool]`
Whether a Worker contains modules.
- `last_deployed_from: Optional[str]`
The client most recently used to deploy this Worker.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `migration_tag: Optional[str]`
The tag of the Durable Object migration that was most recently applied for this Worker.
- `modified_on: Optional[datetime]`
When the script was last modified.
- `named_handlers: Optional[List[NamedHandler]]`
Named exports, such as Durable Object class implementations and named entrypoints.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the named export.
- `name: Optional[str]`
The name of the export.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementUnionMember0: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember1: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember2: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember3: …`
- `host: str`
TCP host and port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `placement_mode: Optional[Literal["smart", "targeted"]]`
- `"smart"`
- `"targeted"`
- `placement_status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `tag: Optional[str]`
The immutable ID of the script.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
# Assets
# Upload
## Create Assets Upload Session
`workers.scripts.assets.upload.create(strscript_name, UploadCreateParams**kwargs) -> UploadCreateResponse`
**post** `/accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session`
Start uploading a collection of assets for use in a Worker version. To learn more about the direct uploads of assets, see https://developers.cloudflare.com/workers/static-assets/direct-upload/.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `manifest: Dict[str, Manifest]`
A manifest ([path]: {hash, size}) map of files to upload. As an example, `/blog/hello-world.html` would be a valid path key.
- `hash: str`
The hash of the file.
- `size: int`
The size of the file in bytes.
### Returns
- `class UploadCreateResponse: …`
- `buckets: Optional[List[List[str]]]`
The requests to make to upload assets.
- `jwt: Optional[str]`
A JWT to use as authentication for uploading assets.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
upload = client.workers.scripts.assets.upload.create(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
manifest={
"foo": {
"hash": "hash",
"size": 0,
}
},
)
print(upload.buckets)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {
"buckets": [
[
"string"
]
],
"jwt": "jwt"
}
}
```
## Domain Types
### Upload Create Response
- `class UploadCreateResponse: …`
- `buckets: Optional[List[List[str]]]`
The requests to make to upload assets.
- `jwt: Optional[str]`
A JWT to use as authentication for uploading assets.
# Subdomain
## Get Worker subdomain
`workers.scripts.subdomain.get(strscript_name, SubdomainGetParams**kwargs) -> SubdomainGetResponse`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/subdomain`
Get if the Worker is available on the workers.dev subdomain.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
### Returns
- `class SubdomainGetResponse: …`
- `enabled: bool`
Whether the Worker is available on the workers.dev subdomain.
- `previews_enabled: bool`
Whether the Worker's Preview URLs are available on the workers.dev subdomain.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
subdomain = client.workers.scripts.subdomain.get(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(subdomain.enabled)
```
#### Response
```json
{
"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": {
"enabled": false,
"previews_enabled": false
},
"success": true
}
```
## Post Worker subdomain
`workers.scripts.subdomain.create(strscript_name, SubdomainCreateParams**kwargs) -> SubdomainCreateResponse`
**post** `/accounts/{account_id}/workers/scripts/{script_name}/subdomain`
Enable or disable the Worker on the workers.dev subdomain.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `enabled: bool`
Whether the Worker should be available on the workers.dev subdomain.
- `previews_enabled: Optional[bool]`
Whether the Worker's Preview URLs should be available on the workers.dev subdomain.
### Returns
- `class SubdomainCreateResponse: …`
- `enabled: bool`
Whether the Worker is available on the workers.dev subdomain.
- `previews_enabled: bool`
Whether the Worker's Preview URLs are available on the workers.dev subdomain.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
subdomain = client.workers.scripts.subdomain.create(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
enabled=True,
)
print(subdomain.enabled)
```
#### Response
```json
{
"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": {
"enabled": false,
"previews_enabled": false
},
"success": true
}
```
## Delete Worker subdomain
`workers.scripts.subdomain.delete(strscript_name, SubdomainDeleteParams**kwargs) -> SubdomainDeleteResponse`
**delete** `/accounts/{account_id}/workers/scripts/{script_name}/subdomain`
Disable all workers.dev subdomains for a Worker.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
### Returns
- `class SubdomainDeleteResponse: …`
- `enabled: bool`
Whether the Worker is available on the workers.dev subdomain.
- `previews_enabled: bool`
Whether the Worker's Preview URLs are available on the workers.dev subdomain.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
subdomain = client.workers.scripts.subdomain.delete(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(subdomain.enabled)
```
#### Response
```json
{
"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": {
"enabled": false,
"previews_enabled": false
},
"success": true
}
```
## Domain Types
### Subdomain Get Response
- `class SubdomainGetResponse: …`
- `enabled: bool`
Whether the Worker is available on the workers.dev subdomain.
- `previews_enabled: bool`
Whether the Worker's Preview URLs are available on the workers.dev subdomain.
### Subdomain Create Response
- `class SubdomainCreateResponse: …`
- `enabled: bool`
Whether the Worker is available on the workers.dev subdomain.
- `previews_enabled: bool`
Whether the Worker's Preview URLs are available on the workers.dev subdomain.
### Subdomain Delete Response
- `class SubdomainDeleteResponse: …`
- `enabled: bool`
Whether the Worker is available on the workers.dev subdomain.
- `previews_enabled: bool`
Whether the Worker's Preview URLs are available on the workers.dev subdomain.
# Schedules
## Get Cron Triggers
`workers.scripts.schedules.get(strscript_name, ScheduleGetParams**kwargs) -> ScheduleGetResponse`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/schedules`
Fetches Cron Triggers for a Worker.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
### Returns
- `class ScheduleGetResponse: …`
- `schedules: List[Schedule]`
- `cron: str`
- `created_on: Optional[str]`
- `modified_on: Optional[str]`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
schedule = client.workers.scripts.schedules.get(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(schedule.schedules)
```
#### Response
```json
{
"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": {
"schedules": [
{
"cron": "*/30 * * * *",
"created_on": "created_on",
"modified_on": "modified_on"
}
]
},
"success": true
}
```
## Update Cron Triggers
`workers.scripts.schedules.update(strscript_name, ScheduleUpdateParams**kwargs) -> ScheduleUpdateResponse`
**put** `/accounts/{account_id}/workers/scripts/{script_name}/schedules`
Updates Cron Triggers for a Worker.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `body: Iterable[Body]`
- `cron: str`
- `created_on: Optional[str]`
- `modified_on: Optional[str]`
### Returns
- `class ScheduleUpdateResponse: …`
- `schedules: List[Schedule]`
- `cron: str`
- `created_on: Optional[str]`
- `modified_on: Optional[str]`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
schedule = client.workers.scripts.schedules.update(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body=[{
"cron": "*/30 * * * *"
}],
)
print(schedule.schedules)
```
#### Response
```json
{
"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": {
"schedules": [
{
"cron": "*/30 * * * *",
"created_on": "created_on",
"modified_on": "modified_on"
}
]
},
"success": true
}
```
## Domain Types
### Schedule Get Response
- `class ScheduleGetResponse: …`
- `schedules: List[Schedule]`
- `cron: str`
- `created_on: Optional[str]`
- `modified_on: Optional[str]`
### Schedule Update Response
- `class ScheduleUpdateResponse: …`
- `schedules: List[Schedule]`
- `cron: str`
- `created_on: Optional[str]`
- `modified_on: Optional[str]`
# Tail
## List Tails
`workers.scripts.tail.get(strscript_name, TailGetParams**kwargs) -> TailGetResponse`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/tails`
Get list of tails currently deployed on a Worker.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
### Returns
- `class TailGetResponse: …`
- `id: str`
Identifier.
- `expires_at: str`
- `url: str`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
tail = client.workers.scripts.tail.get(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(tail.id)
```
#### Response
```json
{
"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": "023e105f4ecef8ad9ca31a8372d0c353",
"expires_at": "expires_at",
"url": "url"
},
"success": true
}
```
## Start Tail
`workers.scripts.tail.create(strscript_name, TailCreateParams**kwargs) -> TailCreateResponse`
**post** `/accounts/{account_id}/workers/scripts/{script_name}/tails`
Starts a tail that receives logs and exception from a Worker.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `body: object`
### Returns
- `class TailCreateResponse: …`
- `id: str`
Identifier.
- `expires_at: str`
- `url: str`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
tail = client.workers.scripts.tail.create(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
)
print(tail.id)
```
#### Response
```json
{
"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": "023e105f4ecef8ad9ca31a8372d0c353",
"expires_at": "expires_at",
"url": "url"
},
"success": true
}
```
## Delete Tail
`workers.scripts.tail.delete(strid, TailDeleteParams**kwargs) -> TailDeleteResponse`
**delete** `/accounts/{account_id}/workers/scripts/{script_name}/tails/{id}`
Deletes a tail from a Worker.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `id: str`
Identifier.
### Returns
- `class TailDeleteResponse: …`
- `errors: List[Error]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[ErrorSource]`
- `pointer: Optional[str]`
- `messages: List[Message]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[MessageSource]`
- `pointer: Optional[str]`
- `success: Literal[true]`
Whether the API call was successful.
- `true`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
tail = client.workers.scripts.tail.delete(
id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
script_name="this-is_my_script-01",
)
print(tail.errors)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true
}
```
## Domain Types
### Consumer Script
- `class ConsumerScript: …`
A reference to a script that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
### Tail Get Response
- `class TailGetResponse: …`
- `id: str`
Identifier.
- `expires_at: str`
- `url: str`
### Tail Create Response
- `class TailCreateResponse: …`
- `id: str`
Identifier.
- `expires_at: str`
- `url: str`
### Tail Delete Response
- `class TailDeleteResponse: …`
- `errors: List[Error]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[ErrorSource]`
- `pointer: Optional[str]`
- `messages: List[Message]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[MessageSource]`
- `pointer: Optional[str]`
- `success: Literal[true]`
Whether the API call was successful.
- `true`
# Content
## Get script content
`workers.scripts.content.get(strscript_name, ContentGetParams**kwargs) -> BinaryResponseContent`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/content/v2`
Fetch script content only.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
### Returns
- `BinaryResponseContent`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
content = client.workers.scripts.content.get(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(content)
data = content.read()
print(data)
```
## Put script content
`workers.scripts.content.update(strscript_name, ContentUpdateParams**kwargs) -> Script`
**put** `/accounts/{account_id}/workers/scripts/{script_name}/content`
Put script content without touching config or metadata.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `metadata: Metadata`
JSON-encoded metadata about the uploaded parts and Worker configuration.
- `body_part: Optional[str]`
Name of the uploaded file that contains the Worker script (e.g. the file adding a listener to the `fetch` event). Indicates a `service worker syntax` Worker.
- `main_module: Optional[str]`
Name of the uploaded file that contains the main module (e.g. the file exporting a `fetch` handler). Indicates a `module syntax` Worker.
- `files: Optional[Sequence[FileTypes]]`
An array of modules (often JavaScript files) comprising a Worker script. At least one module must be present and referenced in the metadata as `main_module` or `body_part` by filename.
Possible Content-Type(s) are: `application/javascript+module`, `text/javascript+module`, `application/javascript`, `text/javascript`, `text/x-python`, `text/x-python-requirement`, `application/wasm`, `text/plain`, `application/octet-stream`, `application/source-map`.
- `cf_worker_body_part: Optional[str]`
- `cf_worker_main_module_part: Optional[str]`
### Returns
- `class Script: …`
- `id: Optional[str]`
The name used to identify the script.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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`.
- `created_on: Optional[datetime]`
When the script was created.
- `etag: Optional[str]`
Hashed script content, can be used in a If-None-Match header when updating.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the default export.
- `has_assets: Optional[bool]`
Whether a Worker contains assets.
- `has_modules: Optional[bool]`
Whether a Worker contains modules.
- `last_deployed_from: Optional[str]`
The client most recently used to deploy this Worker.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `migration_tag: Optional[str]`
The tag of the Durable Object migration that was most recently applied for this Worker.
- `modified_on: Optional[datetime]`
When the script was last modified.
- `named_handlers: Optional[List[NamedHandler]]`
Named exports, such as Durable Object class implementations and named entrypoints.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the named export.
- `name: Optional[str]`
The name of the export.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementUnionMember0: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember1: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember2: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember3: …`
- `host: str`
TCP host and port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `last_analyzed_at: Optional[datetime]`
The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `placement_mode: Optional[Literal["smart", "targeted"]]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `"smart"`
- `"targeted"`
- `placement_status: Optional[Literal["SUCCESS", "UNSUPPORTED_APPLICATION", "INSUFFICIENT_INVOCATIONS"]]`
Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"SUCCESS"`
- `"UNSUPPORTED_APPLICATION"`
- `"INSUFFICIENT_INVOCATIONS"`
- `tag: Optional[str]`
The immutable ID of the script.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
script = client.workers.scripts.content.update(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
metadata={},
)
print(script.id)
```
#### Response
```json
{
"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": "my-workers-script",
"compatibility_date": "2021-01-01",
"compatibility_flags": [
"nodejs_compat"
],
"created_on": "2017-01-01T00:00:00Z",
"etag": "ea95132c15732412d22c1476fa83f27a",
"handlers": [
"fetch",
"scheduled"
],
"has_assets": false,
"has_modules": false,
"last_deployed_from": "wrangler",
"logpush": false,
"migration_tag": "v1",
"modified_on": "2017-01-01T00:00:00Z",
"named_handlers": [
{
"handlers": [
"class"
],
"name": "MyDurableObject"
}
],
"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",
"last_analyzed_at": "2025-01-01T00:00:00Z",
"status": "SUCCESS"
},
"placement_mode": "smart",
"placement_status": "SUCCESS",
"tag": "e8f70fdbc8b1fb0b8ddb1af166186758",
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"service": "my-log-consumer",
"environment": "production",
"namespace": "my-namespace"
}
],
"usage_model": "standard"
},
"success": true
}
```
# Settings
## Get Script Settings
`workers.scripts.settings.get(strscript_name, SettingGetParams**kwargs) -> ScriptSetting`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/script-settings`
Get script-level settings when using [Worker Versions](https://developers.cloudflare.com/api/operations/worker-versions-list-versions). Includes Logpush and Tail Consumers.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
### Returns
- `class ScriptSetting: …`
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
script_setting = client.workers.scripts.settings.get(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(script_setting.logpush)
```
#### Response
```json
{
"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": {
"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
}
},
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"service": "my-log-consumer",
"environment": "production",
"namespace": "my-namespace"
}
]
},
"success": true
}
```
## Patch Script Settings
`workers.scripts.settings.edit(strscript_name, SettingEditParams**kwargs) -> ScriptSetting`
**patch** `/accounts/{account_id}/workers/scripts/{script_name}/script-settings`
Patch script-level settings when using [Worker Versions](https://developers.cloudflare.com/api/operations/worker-versions-list-versions). Including but not limited to Logpush and Tail Consumers.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `tags: Optional[Sequence[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[Iterable[ConsumerScriptParam]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
### Returns
- `class ScriptSetting: …`
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
script_setting = client.workers.scripts.settings.edit(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(script_setting.logpush)
```
#### Response
```json
{
"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": {
"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
}
},
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"service": "my-log-consumer",
"environment": "production",
"namespace": "my-namespace"
}
]
},
"success": true
}
```
# Deployments
## List Deployments
`workers.scripts.deployments.list(strscript_name, DeploymentListParams**kwargs) -> DeploymentListResponse`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/deployments`
List of Worker Deployments. The first deployment in the list is the latest deployment actively serving traffic.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
### Returns
- `class DeploymentListResponse: …`
- `deployments: List[Deployment]`
- `id: str`
- `created_on: datetime`
- `source: str`
- `strategy: Literal["percentage"]`
- `"percentage"`
- `versions: List[Version]`
- `percentage: float`
- `version_id: str`
- `annotations: Optional[Annotations]`
- `workers_message: Optional[str]`
Human-readable message about the deployment. Truncated to 1000 bytes if longer.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the deployment.
- `author_email: Optional[str]`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
deployments = client.workers.scripts.deployments.list(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(deployments.deployments)
```
#### Response
```json
{
"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": {
"deployments": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"created_on": "2019-12-27T18:11:19.117Z",
"source": "api",
"strategy": "percentage",
"versions": [
{
"percentage": 100,
"version_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
],
"annotations": {
"workers/message": "Deploy bug fix.",
"workers/triggered_by": "deployment"
},
"author_email": "dev@stainless.com"
}
]
},
"success": true
}
```
## Create Deployment
`workers.scripts.deployments.create(strscript_name, DeploymentCreateParams**kwargs) -> Deployment`
**post** `/accounts/{account_id}/workers/scripts/{script_name}/deployments`
Deployments configure how [Worker Versions](https://developers.cloudflare.com/api/operations/worker-versions-list-versions) are deployed to traffic. A deployment can consist of one or two versions of a Worker.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `strategy: Literal["percentage"]`
- `"percentage"`
- `versions: Iterable[Version]`
- `percentage: float`
- `version_id: str`
- `force: Optional[bool]`
If set to true, the deployment will be created even if normally blocked by something such rolling back to an older version when a secret has changed.
- `annotations: Optional[Annotations]`
- `workers_message: Optional[str]`
Human-readable message about the deployment. Truncated to 1000 bytes if longer.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the deployment.
### Returns
- `class Deployment: …`
- `id: str`
- `created_on: datetime`
- `source: str`
- `strategy: Literal["percentage"]`
- `"percentage"`
- `versions: List[Version]`
- `percentage: float`
- `version_id: str`
- `annotations: Optional[Annotations]`
- `workers_message: Optional[str]`
Human-readable message about the deployment. Truncated to 1000 bytes if longer.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the deployment.
- `author_email: Optional[str]`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
deployment = client.workers.scripts.deployments.create(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
strategy="percentage",
versions=[{
"percentage": 100,
"version_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
}],
)
print(deployment.id)
```
#### Response
```json
{
"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",
"source": "api",
"strategy": "percentage",
"versions": [
{
"percentage": 100,
"version_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
],
"annotations": {
"workers/message": "Deploy bug fix.",
"workers/triggered_by": "deployment"
},
"author_email": "dev@stainless.com"
},
"success": true
}
```
## Get Deployment
`workers.scripts.deployments.get(strdeployment_id, DeploymentGetParams**kwargs) -> Deployment`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}`
Get information about a Worker Deployment.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `deployment_id: str`
### Returns
- `class Deployment: …`
- `id: str`
- `created_on: datetime`
- `source: str`
- `strategy: Literal["percentage"]`
- `"percentage"`
- `versions: List[Version]`
- `percentage: float`
- `version_id: str`
- `annotations: Optional[Annotations]`
- `workers_message: Optional[str]`
Human-readable message about the deployment. Truncated to 1000 bytes if longer.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the deployment.
- `author_email: Optional[str]`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
deployment = client.workers.scripts.deployments.get(
deployment_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
script_name="this-is_my_script-01",
)
print(deployment.id)
```
#### Response
```json
{
"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",
"source": "api",
"strategy": "percentage",
"versions": [
{
"percentage": 100,
"version_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
],
"annotations": {
"workers/message": "Deploy bug fix.",
"workers/triggered_by": "deployment"
},
"author_email": "dev@stainless.com"
},
"success": true
}
```
## Delete Deployment
`workers.scripts.deployments.delete(strdeployment_id, DeploymentDeleteParams**kwargs) -> DeploymentDeleteResponse`
**delete** `/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}`
Delete a Worker Deployment. The latest deployment, which is actively serving traffic, cannot be deleted. All other deployments can be deleted.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `deployment_id: str`
### Returns
- `class DeploymentDeleteResponse: …`
- `errors: List[Error]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[ErrorSource]`
- `pointer: Optional[str]`
- `messages: List[Message]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[MessageSource]`
- `pointer: Optional[str]`
- `success: Literal[true]`
Whether the API call was successful.
- `true`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
deployment = client.workers.scripts.deployments.delete(
deployment_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
script_name="this-is_my_script-01",
)
print(deployment.errors)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true
}
```
## Domain Types
### Deployment
- `class Deployment: …`
- `id: str`
- `created_on: datetime`
- `source: str`
- `strategy: Literal["percentage"]`
- `"percentage"`
- `versions: List[Version]`
- `percentage: float`
- `version_id: str`
- `annotations: Optional[Annotations]`
- `workers_message: Optional[str]`
Human-readable message about the deployment. Truncated to 1000 bytes if longer.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the deployment.
- `author_email: Optional[str]`
### Deployment List Response
- `class DeploymentListResponse: …`
- `deployments: List[Deployment]`
- `id: str`
- `created_on: datetime`
- `source: str`
- `strategy: Literal["percentage"]`
- `"percentage"`
- `versions: List[Version]`
- `percentage: float`
- `version_id: str`
- `annotations: Optional[Annotations]`
- `workers_message: Optional[str]`
Human-readable message about the deployment. Truncated to 1000 bytes if longer.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the deployment.
- `author_email: Optional[str]`
### Deployment Delete Response
- `class DeploymentDeleteResponse: …`
- `errors: List[Error]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[ErrorSource]`
- `pointer: Optional[str]`
- `messages: List[Message]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[MessageSource]`
- `pointer: Optional[str]`
- `success: Literal[true]`
Whether the API call was successful.
- `true`
# Versions
## List Versions
`workers.scripts.versions.list(strscript_name, VersionListParams**kwargs) -> SyncV4PagePagination[VersionListResponse]`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/versions`
List of Worker Versions. The first version in the list is the latest version.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script.
- `deployable: Optional[bool]`
Only return versions that can be used in a deployment. Ignores pagination.
- `page: Optional[int]`
Current page.
- `per_page: Optional[int]`
Items per-page.
### Returns
- `class VersionListResponse: …`
- `id: Optional[str]`
Unique identifier for the version.
- `metadata: Optional[Metadata]`
- `author_email: Optional[str]`
Email of the user who created the version.
- `author_id: Optional[str]`
Identifier of the user who created the version.
- `created_on: Optional[str]`
When the version was created.
- `has_preview: Optional[bool]`
Whether the version can be previewed.
- `modified_on: Optional[str]`
When the version was last modified.
- `source: Optional[Literal["unknown", "api", "wrangler", 7 more]]`
The source of the version upload.
- `"unknown"`
- `"api"`
- `"wrangler"`
- `"terraform"`
- `"dash"`
- `"dash_template"`
- `"integration"`
- `"quick_editor"`
- `"playground"`
- `"workersci"`
- `number: Optional[float]`
Sequential version number.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
page = client.workers.scripts.versions.list(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
page = page.result.items[0]
print(page.id)
```
#### Response
```json
{
"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": {
"items": [
{
"id": "18f97339-c287-4872-9bdd-e2135c07ec12",
"metadata": {
"author_email": "user@example.com",
"author_id": "408cbcdfd4dda4617efef40b04d168a1",
"created_on": "2022-11-08T17:19:29.176266Z",
"hasPreview": true,
"modified_on": "2022-11-08T17:19:29.176266Z",
"source": "api"
},
"number": 1
}
]
},
"success": true
}
```
## Get Version Detail
`workers.scripts.versions.get(strversion_id, VersionGetParams**kwargs) -> VersionGetResponse`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/versions/{version_id}`
Retrieves detailed information about a specific version of a Workers script.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script.
- `version_id: str`
### Returns
- `class VersionGetResponse: …`
- `resources: Resources`
- `bindings: Optional[List[ResourcesBinding]]`
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 ResourcesBindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class ResourcesBindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class ResourcesBindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class ResourcesBindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class ResourcesBindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class ResourcesBindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class ResourcesBindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class ResourcesBindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class ResourcesBindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[ResourcesBindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[ResourcesBindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[ResourcesBindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class ResourcesBindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class ResourcesBindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class ResourcesBindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class ResourcesBindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class ResourcesBindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class ResourcesBindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class ResourcesBindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class ResourcesBindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class ResourcesBindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class ResourcesBindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class ResourcesBindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class ResourcesBindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: ResourcesBindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class ResourcesBindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class ResourcesBindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class ResourcesBindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class ResourcesBindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class ResourcesBindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class ResourcesBindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class ResourcesBindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class ResourcesBindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class ResourcesBindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class ResourcesBindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class ResourcesBindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class ResourcesBindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class ResourcesBindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class ResourcesBindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `script: Optional[ResourcesScript]`
- `etag: Optional[str]`
Hashed script content
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the default export.
- `last_deployed_from: Optional[str]`
The client most recently used to deploy this Worker.
- `named_handlers: Optional[List[ResourcesScriptNamedHandler]]`
Named exports, such as Durable Object class implementations and named entrypoints.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the named export.
- `name: Optional[str]`
The name of the exported class or entrypoint.
- `script_runtime: Optional[ResourcesScriptRuntime]`
Runtime configuration for the Worker.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
Flags that enable or disable certain features in the Workers runtime.
- `limits: Optional[ResourcesScriptRuntimeLimits]`
Resource limits for the Worker.
- `cpu_ms: Optional[int]`
The amount of CPU time this Worker can use in milliseconds.
- `migration_tag: Optional[str]`
The tag of the Durable Object migration that was most recently applied for this Worker.
- `usage_model: Optional[Literal["bundled", "unbound", "standard"]]`
Usage model for the Worker invocations.
- `"bundled"`
- `"unbound"`
- `"standard"`
- `id: Optional[str]`
Unique identifier for the version.
- `metadata: Optional[Metadata]`
- `author_email: Optional[str]`
Email of the user who created the version.
- `author_id: Optional[str]`
Identifier of the user who created the version.
- `created_on: Optional[str]`
When the version was created.
- `has_preview: Optional[bool]`
Whether the version can be previewed.
- `modified_on: Optional[str]`
When the version was last modified.
- `source: Optional[Literal["unknown", "api", "wrangler", 7 more]]`
The source of the version upload.
- `"unknown"`
- `"api"`
- `"wrangler"`
- `"terraform"`
- `"dash"`
- `"dash_template"`
- `"integration"`
- `"quick_editor"`
- `"playground"`
- `"workersci"`
- `number: Optional[float]`
Sequential version number.
### Example
```python
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.scripts.versions.get(
version_id="bcf48806-b317-4351-9ee7-36e7d557d4de",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
script_name="this-is_my_script-01",
)
print(version.id)
```
#### Response
```json
{
"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": {
"resources": {
"bindings": [
{
"name": "MY_ENV_VAR",
"text": "my_data",
"type": "plain_text"
}
],
"script": {
"etag": "13a3240e8fb414561b0366813b0b8f42b3e6cfa0d9e70e99835dae83d0d8a794",
"handlers": [
"fetch"
],
"last_deployed_from": "api",
"named_handlers": [
{
"handlers": [
"fetch"
],
"name": "MyClass"
}
]
},
"script_runtime": {
"compatibility_date": "2022-11-08",
"compatibility_flags": [
"x"
],
"limits": {
"cpu_ms": 50
},
"migration_tag": "v1",
"usage_model": "standard"
}
},
"id": "18f97339-c287-4872-9bdd-e2135c07ec12",
"metadata": {
"author_email": "user@example.com",
"author_id": "408cbcdfd4dda4617efef40b04d168a1",
"created_on": "2022-11-08T17:19:29.176266Z",
"hasPreview": true,
"modified_on": "2022-11-08T17:19:29.176266Z",
"source": "api"
},
"number": 1
},
"success": true
}
```
## Upload Version
`workers.scripts.versions.create(strscript_name, VersionCreateParams**kwargs) -> VersionCreateResponse`
**post** `/accounts/{account_id}/workers/scripts/{script_name}/versions`
Upload a Worker Version without deploying to Cloudflare's network. You can find more about the multipart metadata on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script.
- `metadata: Metadata`
JSON-encoded metadata about the uploaded parts and Worker configuration.
- `main_module: str`
Name of the uploaded file that contains the main module (e.g. the file exporting a `fetch` handler). Indicates a `module syntax` Worker, which is required for Version Upload.
- `annotations: Optional[MetadataAnnotations]`
- `workers_alias: Optional[str]`
Associated alias for a version.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `bindings: Optional[Iterable[MetadataBinding]]`
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 MetadataBindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class MetadataBindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class MetadataBindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class MetadataBindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class MetadataBindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class MetadataBindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class MetadataBindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class MetadataBindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class MetadataBindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[MetadataBindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[Iterable[MetadataBindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[MetadataBindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class MetadataBindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class MetadataBindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class MetadataBindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class MetadataBindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class MetadataBindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class MetadataBindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class MetadataBindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class MetadataBindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class MetadataBindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class MetadataBindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class MetadataBindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class MetadataBindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: MetadataBindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class MetadataBindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class MetadataBindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class MetadataBindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[Sequence[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[Sequence[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class MetadataBindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class MetadataBindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class MetadataBindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class MetadataBindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class MetadataBindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class MetadataBindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class MetadataBindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class MetadataBindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class MetadataBindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class MetadataBindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class MetadataBindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[Sequence[str]]`
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`.
- `keep_bindings: Optional[Sequence[str]]`
List of binding types to keep from previous_upload.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
- `bindings_inherit: Optional[Literal["strict"]]`
When set to "strict", the upload will fail if any `inherit` type bindings cannot be resolved against the previous version of the Worker. Without this, unresolvable inherit bindings are silently dropped.
- `"strict"`
- `files: Optional[Sequence[FileTypes]]`
An array of modules (often JavaScript files) comprising a Worker script. At least one module must be present and referenced in the metadata as `main_module` or `body_part` by filename.
Possible Content-Type(s) are: `application/javascript+module`, `text/javascript+module`, `application/javascript`, `text/javascript`, `text/x-python`, `text/x-python-requirement`, `application/wasm`, `text/plain`, `application/octet-stream`, `application/source-map`.
### Returns
- `class VersionCreateResponse: …`
- `resources: Resources`
- `bindings: Optional[List[ResourcesBinding]]`
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 ResourcesBindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class ResourcesBindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class ResourcesBindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class ResourcesBindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class ResourcesBindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class ResourcesBindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class ResourcesBindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class ResourcesBindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class ResourcesBindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[ResourcesBindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[ResourcesBindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[ResourcesBindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class ResourcesBindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class ResourcesBindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class ResourcesBindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class ResourcesBindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class ResourcesBindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class ResourcesBindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class ResourcesBindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class ResourcesBindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class ResourcesBindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class ResourcesBindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class ResourcesBindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class ResourcesBindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: ResourcesBindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class ResourcesBindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class ResourcesBindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class ResourcesBindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class ResourcesBindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class ResourcesBindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class ResourcesBindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class ResourcesBindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class ResourcesBindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class ResourcesBindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class ResourcesBindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class ResourcesBindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class ResourcesBindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class ResourcesBindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class ResourcesBindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `script: Optional[ResourcesScript]`
- `etag: Optional[str]`
Hashed script content
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the default export.
- `last_deployed_from: Optional[str]`
The client most recently used to deploy this Worker.
- `named_handlers: Optional[List[ResourcesScriptNamedHandler]]`
Named exports, such as Durable Object class implementations and named entrypoints.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the named export.
- `name: Optional[str]`
The name of the exported class or entrypoint.
- `script_runtime: Optional[ResourcesScriptRuntime]`
Runtime configuration for the Worker.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
Flags that enable or disable certain features in the Workers runtime.
- `limits: Optional[ResourcesScriptRuntimeLimits]`
Resource limits for the Worker.
- `cpu_ms: Optional[int]`
The amount of CPU time this Worker can use in milliseconds.
- `migration_tag: Optional[str]`
The tag of the Durable Object migration that was most recently applied for this Worker.
- `usage_model: Optional[Literal["bundled", "unbound", "standard"]]`
Usage model for the Worker invocations.
- `"bundled"`
- `"unbound"`
- `"standard"`
- `id: Optional[str]`
Unique identifier for the version.
- `metadata: Optional[Metadata]`
- `author_email: Optional[str]`
Email of the user who created the version.
- `author_id: Optional[str]`
Identifier of the user who created the version.
- `created_on: Optional[str]`
When the version was created.
- `has_preview: Optional[bool]`
Whether the version can be previewed.
- `modified_on: Optional[str]`
When the version was last modified.
- `source: Optional[Literal["unknown", "api", "wrangler", 7 more]]`
The source of the version upload.
- `"unknown"`
- `"api"`
- `"wrangler"`
- `"terraform"`
- `"dash"`
- `"dash_template"`
- `"integration"`
- `"quick_editor"`
- `"playground"`
- `"workersci"`
- `number: Optional[float]`
Sequential version number.
- `startup_time_ms: Optional[int]`
Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time).
### Example
```python
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.scripts.versions.create(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
metadata={
"main_module": "worker.js"
},
)
print(version.id)
```
#### Response
```json
{
"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": {
"resources": {
"bindings": [
{
"name": "MY_ENV_VAR",
"text": "my_data",
"type": "plain_text"
}
],
"script": {
"etag": "13a3240e8fb414561b0366813b0b8f42b3e6cfa0d9e70e99835dae83d0d8a794",
"handlers": [
"fetch"
],
"last_deployed_from": "api",
"named_handlers": [
{
"handlers": [
"fetch"
],
"name": "MyClass"
}
]
},
"script_runtime": {
"compatibility_date": "2022-11-08",
"compatibility_flags": [
"x"
],
"limits": {
"cpu_ms": 50
},
"migration_tag": "v1",
"usage_model": "standard"
}
},
"id": "18f97339-c287-4872-9bdd-e2135c07ec12",
"metadata": {
"author_email": "user@example.com",
"author_id": "408cbcdfd4dda4617efef40b04d168a1",
"created_on": "2022-11-08T17:19:29.176266Z",
"hasPreview": true,
"modified_on": "2022-11-08T17:19:29.176266Z",
"source": "api"
},
"number": 1,
"startup_time_ms": 10
},
"success": true
}
```
## Domain Types
### Version List Response
- `class VersionListResponse: …`
- `id: Optional[str]`
Unique identifier for the version.
- `metadata: Optional[Metadata]`
- `author_email: Optional[str]`
Email of the user who created the version.
- `author_id: Optional[str]`
Identifier of the user who created the version.
- `created_on: Optional[str]`
When the version was created.
- `has_preview: Optional[bool]`
Whether the version can be previewed.
- `modified_on: Optional[str]`
When the version was last modified.
- `source: Optional[Literal["unknown", "api", "wrangler", 7 more]]`
The source of the version upload.
- `"unknown"`
- `"api"`
- `"wrangler"`
- `"terraform"`
- `"dash"`
- `"dash_template"`
- `"integration"`
- `"quick_editor"`
- `"playground"`
- `"workersci"`
- `number: Optional[float]`
Sequential version number.
### Version Get Response
- `class VersionGetResponse: …`
- `resources: Resources`
- `bindings: Optional[List[ResourcesBinding]]`
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 ResourcesBindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class ResourcesBindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class ResourcesBindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class ResourcesBindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class ResourcesBindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class ResourcesBindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class ResourcesBindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class ResourcesBindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class ResourcesBindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[ResourcesBindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[ResourcesBindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[ResourcesBindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class ResourcesBindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class ResourcesBindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class ResourcesBindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class ResourcesBindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class ResourcesBindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class ResourcesBindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class ResourcesBindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class ResourcesBindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class ResourcesBindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class ResourcesBindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class ResourcesBindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class ResourcesBindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: ResourcesBindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class ResourcesBindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class ResourcesBindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class ResourcesBindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class ResourcesBindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class ResourcesBindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class ResourcesBindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class ResourcesBindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class ResourcesBindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class ResourcesBindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class ResourcesBindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class ResourcesBindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class ResourcesBindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class ResourcesBindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class ResourcesBindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `script: Optional[ResourcesScript]`
- `etag: Optional[str]`
Hashed script content
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the default export.
- `last_deployed_from: Optional[str]`
The client most recently used to deploy this Worker.
- `named_handlers: Optional[List[ResourcesScriptNamedHandler]]`
Named exports, such as Durable Object class implementations and named entrypoints.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the named export.
- `name: Optional[str]`
The name of the exported class or entrypoint.
- `script_runtime: Optional[ResourcesScriptRuntime]`
Runtime configuration for the Worker.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
Flags that enable or disable certain features in the Workers runtime.
- `limits: Optional[ResourcesScriptRuntimeLimits]`
Resource limits for the Worker.
- `cpu_ms: Optional[int]`
The amount of CPU time this Worker can use in milliseconds.
- `migration_tag: Optional[str]`
The tag of the Durable Object migration that was most recently applied for this Worker.
- `usage_model: Optional[Literal["bundled", "unbound", "standard"]]`
Usage model for the Worker invocations.
- `"bundled"`
- `"unbound"`
- `"standard"`
- `id: Optional[str]`
Unique identifier for the version.
- `metadata: Optional[Metadata]`
- `author_email: Optional[str]`
Email of the user who created the version.
- `author_id: Optional[str]`
Identifier of the user who created the version.
- `created_on: Optional[str]`
When the version was created.
- `has_preview: Optional[bool]`
Whether the version can be previewed.
- `modified_on: Optional[str]`
When the version was last modified.
- `source: Optional[Literal["unknown", "api", "wrangler", 7 more]]`
The source of the version upload.
- `"unknown"`
- `"api"`
- `"wrangler"`
- `"terraform"`
- `"dash"`
- `"dash_template"`
- `"integration"`
- `"quick_editor"`
- `"playground"`
- `"workersci"`
- `number: Optional[float]`
Sequential version number.
### Version Create Response
- `class VersionCreateResponse: …`
- `resources: Resources`
- `bindings: Optional[List[ResourcesBinding]]`
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 ResourcesBindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class ResourcesBindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class ResourcesBindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class ResourcesBindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class ResourcesBindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class ResourcesBindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class ResourcesBindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class ResourcesBindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class ResourcesBindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[ResourcesBindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[ResourcesBindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[ResourcesBindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class ResourcesBindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class ResourcesBindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class ResourcesBindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class ResourcesBindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class ResourcesBindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class ResourcesBindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class ResourcesBindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class ResourcesBindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class ResourcesBindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class ResourcesBindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class ResourcesBindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class ResourcesBindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: ResourcesBindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class ResourcesBindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class ResourcesBindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class ResourcesBindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class ResourcesBindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class ResourcesBindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class ResourcesBindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class ResourcesBindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class ResourcesBindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class ResourcesBindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class ResourcesBindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class ResourcesBindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class ResourcesBindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class ResourcesBindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class ResourcesBindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `script: Optional[ResourcesScript]`
- `etag: Optional[str]`
Hashed script content
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the default export.
- `last_deployed_from: Optional[str]`
The client most recently used to deploy this Worker.
- `named_handlers: Optional[List[ResourcesScriptNamedHandler]]`
Named exports, such as Durable Object class implementations and named entrypoints.
- `handlers: Optional[List[str]]`
The names of handlers exported as part of the named export.
- `name: Optional[str]`
The name of the exported class or entrypoint.
- `script_runtime: Optional[ResourcesScriptRuntime]`
Runtime configuration for the Worker.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
Flags that enable or disable certain features in the Workers runtime.
- `limits: Optional[ResourcesScriptRuntimeLimits]`
Resource limits for the Worker.
- `cpu_ms: Optional[int]`
The amount of CPU time this Worker can use in milliseconds.
- `migration_tag: Optional[str]`
The tag of the Durable Object migration that was most recently applied for this Worker.
- `usage_model: Optional[Literal["bundled", "unbound", "standard"]]`
Usage model for the Worker invocations.
- `"bundled"`
- `"unbound"`
- `"standard"`
- `id: Optional[str]`
Unique identifier for the version.
- `metadata: Optional[Metadata]`
- `author_email: Optional[str]`
Email of the user who created the version.
- `author_id: Optional[str]`
Identifier of the user who created the version.
- `created_on: Optional[str]`
When the version was created.
- `has_preview: Optional[bool]`
Whether the version can be previewed.
- `modified_on: Optional[str]`
When the version was last modified.
- `source: Optional[Literal["unknown", "api", "wrangler", 7 more]]`
The source of the version upload.
- `"unknown"`
- `"api"`
- `"wrangler"`
- `"terraform"`
- `"dash"`
- `"dash_template"`
- `"integration"`
- `"quick_editor"`
- `"playground"`
- `"workersci"`
- `number: Optional[float]`
Sequential version number.
- `startup_time_ms: Optional[int]`
Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time).
# Secrets
## List script secrets
`workers.scripts.secrets.list(strscript_name, SecretListParams**kwargs) -> SyncSinglePage[SecretListResponse]`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/secrets`
List secrets bound to a script.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
### Returns
- `SecretListResponse`
A secret value accessible through a binding.
- `class WorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class WorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
page = client.workers.scripts.secrets.list(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
page = page.result[0]
print(page)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": [
{
"name": "myBinding",
"type": "secret_text"
}
]
}
```
## Get secret binding
`workers.scripts.secrets.get(strsecret_name, SecretGetParams**kwargs) -> SecretGetResponse`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}`
Get a given secret binding (value omitted) on a script.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `secret_name: str`
A JavaScript variable name for the secret binding.
- `url_encoded: Optional[bool]`
Flag that indicates whether the secret name is URL encoded.
### Returns
- `SecretGetResponse`
A secret value accessible through a binding.
- `class WorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class WorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
secret = client.workers.scripts.secrets.get(
secret_name="mySecret",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
script_name="this-is_my_script-01",
)
print(secret)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {
"name": "myBinding",
"type": "secret_text"
}
}
```
## Add script secret
`workers.scripts.secrets.update(strscript_name, SecretUpdateParams**kwargs) -> SecretUpdateResponse`
**put** `/accounts/{account_id}/workers/scripts/{script_name}/secrets`
Add a secret to a script.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
### Returns
- `SecretUpdateResponse`
A secret value accessible through a binding.
- `class WorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class WorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
secret = client.workers.scripts.secrets.update(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
name="myBinding",
text="My secret.",
type="secret_text",
)
print(secret)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {
"name": "myBinding",
"type": "secret_text"
}
}
```
## Delete script secret
`workers.scripts.secrets.delete(strsecret_name, SecretDeleteParams**kwargs) -> object`
**delete** `/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}`
Remove a secret from a script.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `secret_name: str`
A JavaScript variable name for the secret binding.
- `url_encoded: Optional[bool]`
Flag that indicates whether the secret name is URL encoded.
### Returns
- `object`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
secret = client.workers.scripts.secrets.delete(
secret_name="mySecret",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
script_name="this-is_my_script-01",
)
print(secret)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {}
}
```
## Domain Types
### Secret List Response
- `SecretListResponse`
A secret value accessible through a binding.
- `class WorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class WorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
### Secret Get Response
- `SecretGetResponse`
A secret value accessible through a binding.
- `class WorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class WorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
### Secret Update Response
- `SecretUpdateResponse`
A secret value accessible through a binding.
- `class WorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class WorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
# Script And Version Settings
## Get Settings
`workers.scripts.script_and_version_settings.get(strscript_name, ScriptAndVersionSettingGetParams**kwargs) -> ScriptAndVersionSettingGetResponse`
**get** `/accounts/{account_id}/workers/scripts/{script_name}/settings`
Get metadata and config, such as bindings or usage model.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
### Returns
- `class ScriptAndVersionSettingGetResponse: …`
- `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.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the version. This is read-only and set by the server.
- `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.
- `class BindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class BindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class BindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class BindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class BindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class BindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class BindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class BindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class BindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[BindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[BindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[BindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class BindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class BindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class BindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class BindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class BindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class BindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class BindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class BindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class BindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class BindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class BindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class BindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: BindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class BindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class BindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class BindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class BindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class BindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class BindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class BindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class BindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class BindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class BindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class BindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class BindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class BindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class BindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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`.
- `limits: Optional[Limits]`
Limits to apply for this Worker.
- `cpu_ms: Optional[int]`
The amount of CPU time this Worker can use in milliseconds.
- `subrequests: Optional[int]`
The number of subrequests this Worker can make per request.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `migrations: Optional[Migrations]`
Migrations to apply for Durable Objects associated with this Worker.
- `class SingleStepMigration: …`
A single set of migrations to apply.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `class MigrationsWorkersMultipleStepMigrations: …`
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `steps: Optional[List[MigrationStep]]`
Migrations to apply in order.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementMode: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `class PlacementRegion: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementHost: …`
- `host: str`
TCP host and port for targeted placement.
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
script_and_version_setting = client.workers.scripts.script_and_version_settings.get(
script_name="this-is_my_script-01",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(script_and_version_setting.annotations)
```
#### Response
```json
{
"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,
"subrequests": 1000
},
"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
}
```
## Patch Settings
`workers.scripts.script_and_version_settings.edit(strscript_name, ScriptAndVersionSettingEditParams**kwargs) -> ScriptAndVersionSettingEditResponse`
**patch** `/accounts/{account_id}/workers/scripts/{script_name}/settings`
Patch metadata or config, such as bindings or usage model.
### Parameters
- `account_id: str`
Identifier.
- `script_name: str`
Name of the script, used in URLs and route configuration.
- `settings: Optional[Settings]`
- `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.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the version. This is read-only and set by the server.
- `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.
- `class SettingsBindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class SettingsBindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class SettingsBindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class SettingsBindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class SettingsBindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class SettingsBindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class SettingsBindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class SettingsBindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class SettingsBindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[SettingsBindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[Iterable[SettingsBindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[SettingsBindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class SettingsBindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class SettingsBindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class SettingsBindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class SettingsBindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class SettingsBindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class SettingsBindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class SettingsBindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class SettingsBindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class SettingsBindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class SettingsBindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class SettingsBindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class SettingsBindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: SettingsBindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class SettingsBindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class SettingsBindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class SettingsBindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[Sequence[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[Sequence[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class SettingsBindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class SettingsBindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class SettingsBindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class SettingsBindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class SettingsBindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class SettingsBindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class SettingsBindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class SettingsBindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class SettingsBindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class SettingsBindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class SettingsBindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[Sequence[str]]`
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`.
- `limits: Optional[SettingsLimits]`
Limits to apply for this Worker.
- `cpu_ms: Optional[int]`
The amount of CPU time this Worker can use in milliseconds.
- `subrequests: Optional[int]`
The number of subrequests this Worker can make per request.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `migrations: Optional[SettingsMigrations]`
Migrations to apply for Durable Objects associated with this Worker.
- `class SingleStepMigration: …`
A single set of migrations to apply.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `class SettingsMigrationsWorkersMultipleStepMigrations: …`
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `steps: Optional[Iterable[MigrationStepParam]]`
Migrations to apply in order.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `observability: Optional[SettingsObservability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[SettingsObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[Sequence[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[SettingsPlacement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class SettingsPlacementMode: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `class SettingsPlacementRegion: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class SettingsPlacementHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class SettingsPlacementHost: …`
- `host: str`
TCP host and port for targeted placement.
- `class SettingsPlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class SettingsPlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class SettingsPlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class SettingsPlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: Iterable[SettingsPlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class SettingsPlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class SettingsPlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class SettingsPlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `tags: Optional[Sequence[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[Iterable[ConsumerScriptParam]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Returns
- `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.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the version. This is read-only and set by the server.
- `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.
- `class BindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class BindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class BindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class BindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class BindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class BindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class BindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class BindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class BindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[BindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[BindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[BindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class BindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class BindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class BindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class BindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class BindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class BindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class BindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class BindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class BindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class BindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class BindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class BindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: BindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class BindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class BindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class BindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class BindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class BindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class BindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class BindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class BindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class BindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class BindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class BindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class BindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class BindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class BindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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`.
- `limits: Optional[Limits]`
Limits to apply for this Worker.
- `cpu_ms: Optional[int]`
The amount of CPU time this Worker can use in milliseconds.
- `subrequests: Optional[int]`
The number of subrequests this Worker can make per request.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `migrations: Optional[Migrations]`
Migrations to apply for Durable Objects associated with this Worker.
- `class SingleStepMigration: …`
A single set of migrations to apply.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `class MigrationsWorkersMultipleStepMigrations: …`
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `steps: Optional[List[MigrationStep]]`
Migrations to apply in order.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementMode: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `class PlacementRegion: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementHost: …`
- `host: str`
TCP host and port for targeted placement.
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Example
```python
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)
```
#### Response
```json
{
"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,
"subrequests": 1000
},
"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
}
```
## Domain Types
### Script And Version Setting Get Response
- `class ScriptAndVersionSettingGetResponse: …`
- `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.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the version. This is read-only and set by the server.
- `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.
- `class BindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class BindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class BindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class BindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class BindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class BindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class BindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class BindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class BindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[BindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[BindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[BindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class BindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class BindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class BindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class BindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class BindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class BindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class BindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class BindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class BindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class BindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class BindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class BindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: BindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class BindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class BindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class BindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class BindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class BindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class BindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class BindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class BindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class BindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class BindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class BindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class BindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class BindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class BindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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`.
- `limits: Optional[Limits]`
Limits to apply for this Worker.
- `cpu_ms: Optional[int]`
The amount of CPU time this Worker can use in milliseconds.
- `subrequests: Optional[int]`
The number of subrequests this Worker can make per request.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `migrations: Optional[Migrations]`
Migrations to apply for Durable Objects associated with this Worker.
- `class SingleStepMigration: …`
A single set of migrations to apply.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `class MigrationsWorkersMultipleStepMigrations: …`
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `steps: Optional[List[MigrationStep]]`
Migrations to apply in order.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementMode: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `class PlacementRegion: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementHost: …`
- `host: str`
TCP host and port for targeted placement.
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
### Script And Version Setting Edit Response
- `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.
- `workers_message: Optional[str]`
Human-readable message about the version. Truncated to 1000 bytes if longer.
- `workers_tag: Optional[str]`
User-provided identifier for the version. Maximum 100 bytes.
- `workers_triggered_by: Optional[str]`
Operation that triggered the creation of the version. This is read-only and set by the server.
- `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.
- `class BindingWorkersBindingKindAI: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai"]`
The kind of resource that the binding provides.
- `"ai"`
- `class BindingWorkersBindingKindAISearch: …`
- `instance_name: str`
The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["ai_search"]`
The kind of resource that the binding provides.
- `"ai_search"`
- `namespace: Optional[str]`
The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field.
- `class BindingWorkersBindingKindAISearchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The user-chosen namespace name. Must exist before deploy -- Wrangler handles auto-creation on deploy failure (R2 bucket pattern). The "default" namespace is auto-created by config-api for new accounts. Grants full access (CRUD + search + chat) to all instances within the namespace.
- `type: Literal["ai_search_namespace"]`
The kind of resource that the binding provides.
- `"ai_search_namespace"`
- `class BindingWorkersBindingKindAnalyticsEngine: …`
- `dataset: str`
The name of the dataset to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["analytics_engine"]`
The kind of resource that the binding provides.
- `"analytics_engine"`
- `class BindingWorkersBindingKindAssets: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["assets"]`
The kind of resource that the binding provides.
- `"assets"`
- `class BindingWorkersBindingKindBrowser: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["browser"]`
The kind of resource that the binding provides.
- `"browser"`
- `class BindingWorkersBindingKindD1: …`
- `database_id: str`
Identifier of the D1 database to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["d1"]`
The kind of resource that the binding provides.
- `"d1"`
- `id: Optional[str]`
Identifier of the D1 database to bind to.
- `class BindingWorkersBindingKindDataBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the data content. Only accepted for `service worker syntax` Workers.
- `type: Literal["data_blob"]`
The kind of resource that the binding provides.
- `"data_blob"`
- `class BindingWorkersBindingKindDispatchNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace: str`
The name of the dispatch namespace.
- `type: Literal["dispatch_namespace"]`
The kind of resource that the binding provides.
- `"dispatch_namespace"`
- `outbound: Optional[BindingWorkersBindingKindDispatchNamespaceOutbound]`
Outbound worker.
- `params: Optional[List[BindingWorkersBindingKindDispatchNamespaceOutboundParam]]`
Pass information from the Dispatch Worker to the Outbound Worker through the parameters.
- `name: str`
Name of the parameter.
- `worker: Optional[BindingWorkersBindingKindDispatchNamespaceOutboundWorker]`
Outbound worker.
- `entrypoint: Optional[str]`
Entrypoint to invoke on the outbound worker.
- `environment: Optional[str]`
Environment of the outbound worker.
- `service: Optional[str]`
Name of the outbound worker.
- `class BindingWorkersBindingKindDurableObjectNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["durable_object_namespace"]`
The kind of resource that the binding provides.
- `"durable_object_namespace"`
- `class_name: Optional[str]`
The exported class name of the Durable Object.
- `dispatch_namespace: Optional[str]`
The dispatch namespace the Durable Object script belongs to.
- `environment: Optional[str]`
The environment of the script_name to bind to.
- `namespace_id: Optional[str]`
Namespace identifier tag.
- `script_name: Optional[str]`
The script where the Durable Object is defined, if it is external to this Worker.
- `class BindingWorkersBindingKindHyperdrive: …`
- `id: str`
Identifier of the Hyperdrive connection to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["hyperdrive"]`
The kind of resource that the binding provides.
- `"hyperdrive"`
- `class BindingWorkersBindingKindInherit: …`
- `name: str`
The name of the inherited binding.
- `type: Literal["inherit"]`
The kind of resource that the binding provides.
- `"inherit"`
- `old_name: Optional[str]`
The old name of the inherited binding. If set, the binding will be renamed from `old_name` to `name` in the new version. If not set, the binding will keep the same name between versions.
- `version_id: Optional[str]`
Identifier for the version to inherit the binding from, which can be the version ID or the literal "latest" to inherit from the latest version. Defaults to inheriting the binding from the latest version.
- `class BindingWorkersBindingKindImages: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["images"]`
The kind of resource that the binding provides.
- `"images"`
- `class BindingWorkersBindingKindJson: …`
- `json: object`
JSON data to use.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["json"]`
The kind of resource that the binding provides.
- `"json"`
- `class BindingWorkersBindingKindKVNamespace: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Namespace identifier tag.
- `type: Literal["kv_namespace"]`
The kind of resource that the binding provides.
- `"kv_namespace"`
- `class BindingWorkersBindingKindMedia: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["media"]`
The kind of resource that the binding provides.
- `"media"`
- `class BindingWorkersBindingKindMTLSCertificate: …`
- `certificate_id: str`
Identifier of the certificate to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["mtls_certificate"]`
The kind of resource that the binding provides.
- `"mtls_certificate"`
- `class BindingWorkersBindingKindPlainText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The text value to use.
- `type: Literal["plain_text"]`
The kind of resource that the binding provides.
- `"plain_text"`
- `class BindingWorkersBindingKindPipelines: …`
- `name: str`
A JavaScript variable name for the binding.
- `pipeline: str`
Name of the Pipeline to bind to.
- `type: Literal["pipelines"]`
The kind of resource that the binding provides.
- `"pipelines"`
- `class BindingWorkersBindingKindQueue: …`
- `name: str`
A JavaScript variable name for the binding.
- `queue_name: str`
Name of the Queue to bind to.
- `type: Literal["queue"]`
The kind of resource that the binding provides.
- `"queue"`
- `class BindingWorkersBindingKindRatelimit: …`
- `name: str`
A JavaScript variable name for the binding.
- `namespace_id: str`
Identifier of the rate limit namespace to bind to.
- `simple: BindingWorkersBindingKindRatelimitSimple`
The rate limit configuration.
- `limit: float`
The limit (requests per period).
- `period: int`
The period in seconds.
- `mitigation_timeout: Optional[int]`
Duration in seconds to apply the mitigation action after the rate limit is exceeded. Valid values are 0 (disabled), 10, or multiples of 60 up to 86400. Must be greater than or equal to the period when non-zero.
- `type: Literal["ratelimit"]`
The kind of resource that the binding provides.
- `"ratelimit"`
- `class BindingWorkersBindingKindR2Bucket: …`
- `bucket_name: str`
R2 bucket to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["r2_bucket"]`
The kind of resource that the binding provides.
- `"r2_bucket"`
- `jurisdiction: Optional[Literal["eu", "fedramp", "fedramp-high"]]`
The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket.
- `"eu"`
- `"fedramp"`
- `"fedramp-high"`
- `class BindingWorkersBindingKindSecretText: …`
- `name: str`
A JavaScript variable name for the binding.
- `text: str`
The secret value to use.
- `type: Literal["secret_text"]`
The kind of resource that the binding provides.
- `"secret_text"`
- `class BindingWorkersBindingKindSendEmail: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["send_email"]`
The kind of resource that the binding provides.
- `"send_email"`
- `allowed_destination_addresses: Optional[List[str]]`
List of allowed destination addresses.
- `allowed_sender_addresses: Optional[List[str]]`
List of allowed sender addresses.
- `destination_address: Optional[str]`
Destination address for the email.
- `class BindingWorkersBindingKindService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service: str`
Name of Worker to bind to.
- `type: Literal["service"]`
The kind of resource that the binding provides.
- `"service"`
- `entrypoint: Optional[str]`
Entrypoint to invoke on the target Worker.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `class BindingWorkersBindingKindTextBlob: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the text content. Only accepted for `service worker syntax` Workers.
- `type: Literal["text_blob"]`
The kind of resource that the binding provides.
- `"text_blob"`
- `class BindingWorkersBindingKindVectorize: …`
- `index_name: str`
Name of the Vectorize index to bind to.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vectorize"]`
The kind of resource that the binding provides.
- `"vectorize"`
- `class BindingWorkersBindingKindVersionMetadata: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["version_metadata"]`
The kind of resource that the binding provides.
- `"version_metadata"`
- `class BindingWorkersBindingKindSecretsStoreSecret: …`
- `name: str`
A JavaScript variable name for the binding.
- `secret_name: str`
Name of the secret in the store.
- `store_id: str`
ID of the store containing the secret.
- `type: Literal["secrets_store_secret"]`
The kind of resource that the binding provides.
- `"secrets_store_secret"`
- `class BindingWorkersBindingKindFlagship: …`
- `app_id: str`
ID of the Flagship app to bind to for feature flag evaluation.
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["flagship"]`
The kind of resource that the binding provides.
- `"flagship"`
- `class BindingWorkersBindingKindSecretKey: …`
- `algorithm: object`
Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm).
- `format: Literal["raw", "pkcs8", "spki", "jwk"]`
Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).
- `"raw"`
- `"pkcs8"`
- `"spki"`
- `"jwk"`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["secret_key"]`
The kind of resource that the binding provides.
- `"secret_key"`
- `usages: List[Literal["encrypt", "decrypt", "sign", 5 more]]`
Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).
- `"encrypt"`
- `"decrypt"`
- `"sign"`
- `"verify"`
- `"deriveKey"`
- `"deriveBits"`
- `"wrapKey"`
- `"unwrapKey"`
- `key_base64: Optional[str]`
Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".
- `key_jwk: Optional[object]`
Key data in [JSON Web Key](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#json_web_key) format. Required if `format` is "jwk".
- `class BindingWorkersBindingKindWorkflow: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["workflow"]`
The kind of resource that the binding provides.
- `"workflow"`
- `workflow_name: str`
Name of the Workflow to bind to.
- `class_name: Optional[str]`
Class name of the Workflow. Should only be provided if the Workflow belongs to this script.
- `script_name: Optional[str]`
Script name that contains the Workflow. If not provided, defaults to this script name.
- `class BindingWorkersBindingKindWasmModule: …`
- `name: str`
A JavaScript variable name for the binding.
- `part: str`
The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers.
- `type: Literal["wasm_module"]`
The kind of resource that the binding provides.
- `"wasm_module"`
- `class BindingWorkersBindingKindVPCService: …`
- `name: str`
A JavaScript variable name for the binding.
- `service_id: str`
Identifier of the VPC service to bind to.
- `type: Literal["vpc_service"]`
The kind of resource that the binding provides.
- `"vpc_service"`
- `class BindingWorkersBindingKindVPCNetwork: …`
- `name: str`
A JavaScript variable name for the binding.
- `type: Literal["vpc_network"]`
The kind of resource that the binding provides.
- `"vpc_network"`
- `network_id: Optional[str]`
Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id.
- `tunnel_id: Optional[str]`
UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id.
- `compatibility_date: Optional[str]`
Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.
- `compatibility_flags: Optional[List[str]]`
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`.
- `limits: Optional[Limits]`
Limits to apply for this Worker.
- `cpu_ms: Optional[int]`
The amount of CPU time this Worker can use in milliseconds.
- `subrequests: Optional[int]`
The number of subrequests this Worker can make per request.
- `logpush: Optional[bool]`
Whether Logpush is turned on for the Worker.
- `migrations: Optional[Migrations]`
Migrations to apply for Durable Objects associated with this Worker.
- `class SingleStepMigration: …`
A single set of migrations to apply.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `class MigrationsWorkersMultipleStepMigrations: …`
- `new_tag: Optional[str]`
Tag to set as the latest migration tag.
- `old_tag: Optional[str]`
Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.
- `steps: Optional[List[MigrationStep]]`
Migrations to apply in order.
- `deleted_classes: Optional[List[str]]`
A list of classes to delete Durable Object namespaces from.
- `new_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces from.
- `new_sqlite_classes: Optional[List[str]]`
A list of classes to create Durable Object namespaces with SQLite from.
- `renamed_classes: Optional[List[RenamedClass]]`
A list of classes with Durable Object namespaces that were renamed.
- `from_: Optional[str]`
- `to: Optional[str]`
- `transferred_classes: Optional[List[TransferredClass]]`
A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.
- `from_: Optional[str]`
- `from_script: Optional[str]`
- `to: Optional[str]`
- `observability: Optional[Observability]`
Observability settings for the Worker.
- `enabled: bool`
Whether observability is enabled for the Worker.
- `head_sampling_rate: Optional[float]`
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.
- `enabled: bool`
Whether logs are enabled for the Worker.
- `invocation_logs: bool`
Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where logs will be exported to.
- `head_sampling_rate: Optional[float]`
The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether log persistence is enabled for the Worker.
- `traces: Optional[ObservabilityTraces]`
Trace settings for the Worker.
- `destinations: Optional[List[str]]`
A list of destinations where traces will be exported to.
- `enabled: Optional[bool]`
Whether traces are enabled for the Worker.
- `head_sampling_rate: Optional[float]`
The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.
- `persist: Optional[bool]`
Whether trace persistence is enabled for the Worker.
- `placement: Optional[Placement]`
Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host.
- `class PlacementMode: …`
- `mode: Literal["smart"]`
Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).
- `"smart"`
- `class PlacementRegion: …`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementHost: …`
- `host: str`
TCP host and port for targeted placement.
- `class PlacementUnionMember4: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `region: str`
Cloud region for targeted placement in format 'provider:region'.
- `class PlacementUnionMember5: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember6: …`
- `host: str`
TCP host and port for targeted placement.
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `class PlacementUnionMember7: …`
- `mode: Literal["targeted"]`
Targeted placement mode.
- `"targeted"`
- `target: List[PlacementUnionMember7Target]`
Array of placement targets (currently limited to single target).
- `class PlacementUnionMember7TargetRegion: …`
- `region: str`
Cloud region in format 'provider:region'.
- `class PlacementUnionMember7TargetHostname: …`
- `hostname: str`
HTTP hostname for targeted placement.
- `class PlacementUnionMember7TargetHost: …`
- `host: str`
TCP host:port for targeted placement.
- `tags: Optional[List[str]]`
Tags associated with the Worker.
- `tail_consumers: Optional[List[ConsumerScript]]`
List of Workers that will consume logs from the attached Worker.
- `service: str`
Name of Worker that is to be the consumer.
- `environment: Optional[str]`
Optional environment if the Worker utilizes one.
- `namespace: Optional[str]`
Optional dispatch namespace the script belongs to.
- `usage_model: Optional[Literal["standard", "bundled", "unbound"]]`
Usage model for the Worker invocations.
- `"standard"`
- `"bundled"`
- `"unbound"`
# Account Settings
## Fetch Worker Account Settings
`workers.account_settings.get(AccountSettingGetParams**kwargs) -> AccountSettingGetResponse`
**get** `/accounts/{account_id}/workers/account-settings`
Fetches Worker account settings for an account.
### Parameters
- `account_id: str`
Identifier.
### Returns
- `class AccountSettingGetResponse: …`
- `default_usage_model: Optional[str]`
- `green_compute: Optional[bool]`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
account_setting = client.workers.account_settings.get(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(account_setting.default_usage_model)
```
#### Response
```json
{
"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": {
"default_usage_model": "default_usage_model",
"green_compute": true
},
"success": true
}
```
## Create Worker Account Settings
`workers.account_settings.update(AccountSettingUpdateParams**kwargs) -> AccountSettingUpdateResponse`
**put** `/accounts/{account_id}/workers/account-settings`
Creates Worker account settings for an account.
### Parameters
- `account_id: str`
Identifier.
- `default_usage_model: Optional[str]`
- `green_compute: Optional[bool]`
### Returns
- `class AccountSettingUpdateResponse: …`
- `default_usage_model: Optional[str]`
- `green_compute: Optional[bool]`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
account_setting = client.workers.account_settings.update(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(account_setting.default_usage_model)
```
#### Response
```json
{
"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": {
"default_usage_model": "default_usage_model",
"green_compute": true
},
"success": true
}
```
## Domain Types
### Account Setting Get Response
- `class AccountSettingGetResponse: …`
- `default_usage_model: Optional[str]`
- `green_compute: Optional[bool]`
### Account Setting Update Response
- `class AccountSettingUpdateResponse: …`
- `default_usage_model: Optional[str]`
- `green_compute: Optional[bool]`
# Domains
## List Domains
`workers.domains.list(DomainListParams**kwargs) -> SyncSinglePage[DomainListResponse]`
**get** `/accounts/{account_id}/workers/domains`
Lists all domains for an account.
### Parameters
- `account_id: str`
Identifier.
- `environment: Optional[str]`
Worker environment associated with the domain.
- `hostname: Optional[str]`
Hostname of the domain.
- `service: Optional[str]`
Name of the Worker associated with the domain.
- `zone_id: Optional[str]`
ID of the zone containing the domain hostname.
- `zone_name: Optional[str]`
Name of the zone containing the domain hostname.
### Returns
- `class DomainListResponse: …`
- `id: str`
Immutable ID of the domain.
- `cert_id: str`
ID of the TLS certificate issued for the domain.
- `environment: str`
Worker environment associated with the domain.
- `hostname: str`
Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.
- `service: str`
Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.
- `zone_id: str`
ID of the zone containing the domain hostname.
- `zone_name: str`
Name of the zone containing the domain hostname.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
page = client.workers.domains.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
page = page.result[0]
print(page.id)
```
#### Response
```json
{
"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": "dbe10b4bc17c295377eabd600e1787fd",
"cert_id": "9fdf92c8-64c2-4a3d-b1af-e15304961145",
"environment": "production",
"hostname": "app.example.com",
"service": "my-worker",
"zone_id": "593c9c94de529bbbfaac7c53ced0447d",
"zone_name": "example.com"
}
],
"success": true,
"result_info": {
"count": 1,
"page": 1,
"per_page": 20,
"total_count": 2000,
"total_pages": 100
}
}
```
## Get Domain
`workers.domains.get(strdomain_id, DomainGetParams**kwargs) -> DomainGetResponse`
**get** `/accounts/{account_id}/workers/domains/{domain_id}`
Gets information about a domain.
### Parameters
- `account_id: str`
Identifier.
- `domain_id: str`
ID of the domain.
### Returns
- `class DomainGetResponse: …`
- `id: str`
Immutable ID of the domain.
- `cert_id: str`
ID of the TLS certificate issued for the domain.
- `environment: str`
Worker environment associated with the domain.
- `hostname: str`
Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.
- `service: str`
Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.
- `zone_id: str`
ID of the zone containing the domain hostname.
- `zone_name: str`
Name of the zone containing the domain hostname.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
domain = client.workers.domains.get(
domain_id="dbe10b4bc17c295377eabd600e1787fd",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(domain.id)
```
#### Response
```json
{
"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": "dbe10b4bc17c295377eabd600e1787fd",
"cert_id": "9fdf92c8-64c2-4a3d-b1af-e15304961145",
"environment": "production",
"hostname": "app.example.com",
"service": "my-worker",
"zone_id": "593c9c94de529bbbfaac7c53ced0447d",
"zone_name": "example.com"
},
"success": true
}
```
## Attach Domain
`workers.domains.update(DomainUpdateParams**kwargs) -> DomainUpdateResponse`
**put** `/accounts/{account_id}/workers/domains`
Attaches a domain that routes traffic to a Worker.
### Parameters
- `account_id: str`
Identifier.
- `hostname: str`
Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.
- `service: str`
Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.
- `environment: Optional[str]`
Worker environment associated with the domain.
- `zone_id: Optional[str]`
ID of the zone containing the domain hostname.
- `zone_name: Optional[str]`
Name of the zone containing the domain hostname.
### Returns
- `class DomainUpdateResponse: …`
- `id: str`
Immutable ID of the domain.
- `cert_id: str`
ID of the TLS certificate issued for the domain.
- `environment: str`
Worker environment associated with the domain.
- `hostname: str`
Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.
- `service: str`
Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.
- `zone_id: str`
ID of the zone containing the domain hostname.
- `zone_name: str`
Name of the zone containing the domain hostname.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
domain = client.workers.domains.update(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
hostname="app.example.com",
service="my-worker",
)
print(domain.id)
```
#### Response
```json
{
"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": "dbe10b4bc17c295377eabd600e1787fd",
"cert_id": "9fdf92c8-64c2-4a3d-b1af-e15304961145",
"environment": "production",
"hostname": "app.example.com",
"service": "my-worker",
"zone_id": "593c9c94de529bbbfaac7c53ced0447d",
"zone_name": "example.com"
},
"success": true
}
```
## Detach Domain
`workers.domains.delete(strdomain_id, DomainDeleteParams**kwargs) -> DomainDeleteResponse`
**delete** `/accounts/{account_id}/workers/domains/{domain_id}`
Detaches a domain from a Worker. Both the Worker and all of its previews are no longer routable using this domain.
### Parameters
- `account_id: str`
Identifier.
- `domain_id: str`
ID of the domain.
### Returns
- `class DomainDeleteResponse: …`
- `errors: List[Error]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[ErrorSource]`
- `pointer: Optional[str]`
- `messages: List[Message]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[MessageSource]`
- `pointer: Optional[str]`
- `success: Literal[true]`
Whether the API call was successful.
- `true`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
domain = client.workers.domains.delete(
domain_id="dbe10b4bc17c295377eabd600e1787fd",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(domain.errors)
```
#### Response
```json
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true
}
```
## Domain Types
### Domain List Response
- `class DomainListResponse: …`
- `id: str`
Immutable ID of the domain.
- `cert_id: str`
ID of the TLS certificate issued for the domain.
- `environment: str`
Worker environment associated with the domain.
- `hostname: str`
Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.
- `service: str`
Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.
- `zone_id: str`
ID of the zone containing the domain hostname.
- `zone_name: str`
Name of the zone containing the domain hostname.
### Domain Get Response
- `class DomainGetResponse: …`
- `id: str`
Immutable ID of the domain.
- `cert_id: str`
ID of the TLS certificate issued for the domain.
- `environment: str`
Worker environment associated with the domain.
- `hostname: str`
Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.
- `service: str`
Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.
- `zone_id: str`
ID of the zone containing the domain hostname.
- `zone_name: str`
Name of the zone containing the domain hostname.
### Domain Update Response
- `class DomainUpdateResponse: …`
- `id: str`
Immutable ID of the domain.
- `cert_id: str`
ID of the TLS certificate issued for the domain.
- `environment: str`
Worker environment associated with the domain.
- `hostname: str`
Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.
- `service: str`
Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.
- `zone_id: str`
ID of the zone containing the domain hostname.
- `zone_name: str`
Name of the zone containing the domain hostname.
### Domain Delete Response
- `class DomainDeleteResponse: …`
- `errors: List[Error]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[ErrorSource]`
- `pointer: Optional[str]`
- `messages: List[Message]`
- `code: int`
- `message: str`
- `documentation_url: Optional[str]`
- `source: Optional[MessageSource]`
- `pointer: Optional[str]`
- `success: Literal[true]`
Whether the API call was successful.
- `true`
# Subdomains
## Get Subdomain
`workers.subdomains.get(SubdomainGetParams**kwargs) -> SubdomainGetResponse`
**get** `/accounts/{account_id}/workers/subdomain`
Returns a Workers subdomain for an account.
### Parameters
- `account_id: str`
Identifier.
### Returns
- `class SubdomainGetResponse: …`
- `subdomain: str`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
subdomain = client.workers.subdomains.get(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(subdomain.subdomain)
```
#### Response
```json
{
"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": {
"subdomain": "my-subdomain"
},
"success": true
}
```
## Create Subdomain
`workers.subdomains.update(SubdomainUpdateParams**kwargs) -> SubdomainUpdateResponse`
**put** `/accounts/{account_id}/workers/subdomain`
Creates a Workers subdomain for an account.
### Parameters
- `account_id: str`
Identifier.
- `subdomain: str`
### Returns
- `class SubdomainUpdateResponse: …`
- `subdomain: str`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
subdomain = client.workers.subdomains.update(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
subdomain="my-subdomain",
)
print(subdomain.subdomain)
```
#### Response
```json
{
"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": {
"subdomain": "my-subdomain"
},
"success": true
}
```
## Delete Subdomain
`workers.subdomains.delete(SubdomainDeleteParams**kwargs)`
**delete** `/accounts/{account_id}/workers/subdomain`
Deletes a Workers subdomain for an account.
### Parameters
- `account_id: str`
Identifier.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
client.workers.subdomains.delete(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
```
## Domain Types
### Subdomain Get Response
- `class SubdomainGetResponse: …`
- `subdomain: str`
### Subdomain Update Response
- `class SubdomainUpdateResponse: …`
- `subdomain: str`
# Observability
# Telemetry
## List keys
`workers.observability.telemetry.keys(TelemetryKeysParams**kwargs) -> SyncSinglePage[TelemetryKeysResponse]`
**post** `/accounts/{account_id}/workers/observability/telemetry/keys`
List all the keys in your telemetry events.
### Parameters
- `account_id: str`
- `datasets: Optional[Sequence[str]]`
Leave this empty to use the default datasets
- `filters: Optional[Iterable[Filter]]`
Apply filters to narrow key discovery. Supports nested groups via kind: 'group'. Maximum nesting depth is 4.
- `class FilterUnionMember0: …`
- `filter_combination: Literal["and", "or", "AND", "OR"]`
- `"and"`
- `"or"`
- `"AND"`
- `"OR"`
- `filters: Iterable[FilterUnionMember0Filter]`
- `class FilterUnionMember0FilterUnionMember0: …`
- `filter_combination: Literal["and", "or", "AND", "OR"]`
- `"and"`
- `"or"`
- `"AND"`
- `"OR"`
- `filters: Iterable[object]`
- `kind: Literal["group"]`
- `"group"`
- `class FilterUnionMember0FilterWorkersObservabilityFilterLeaf: …`
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
- `key: str`
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
- `operation: Literal["includes", "not_includes", "starts_with", 25 more]`
Comparison operator. String operators: includes, not_includes, starts_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
- `"includes"`
- `"not_includes"`
- `"starts_with"`
- `"regex"`
- `"exists"`
- `"is_null"`
- `"in"`
- `"not_in"`
- `"eq"`
- `"neq"`
- `"gt"`
- `"gte"`
- `"lt"`
- `"lte"`
- `"="`
- `"!="`
- `">"`
- `">="`
- `"<"`
- `"<="`
- `"INCLUDES"`
- `"DOES_NOT_INCLUDE"`
- `"MATCH_REGEX"`
- `"EXISTS"`
- `"DOES_NOT_EXIST"`
- `"IN"`
- `"NOT_IN"`
- `"STARTS_WITH"`
- `type: Literal["string", "number", "boolean"]`
Data type of the filter field. Must match the actual type of the key being filtered.
- `"string"`
- `"number"`
- `"boolean"`
- `kind: Optional[Literal["filter"]]`
Discriminator for leaf filter nodes. Always 'filter' when present; may be omitted.
- `"filter"`
- `value: Optional[Union[str, float, bool]]`
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
- `str`
- `float`
- `bool`
- `kind: Literal["group"]`
- `"group"`
- `class FilterWorkersObservabilityFilterLeaf: …`
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
- `key: str`
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
- `operation: Literal["includes", "not_includes", "starts_with", 25 more]`
Comparison operator. String operators: includes, not_includes, starts_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
- `"includes"`
- `"not_includes"`
- `"starts_with"`
- `"regex"`
- `"exists"`
- `"is_null"`
- `"in"`
- `"not_in"`
- `"eq"`
- `"neq"`
- `"gt"`
- `"gte"`
- `"lt"`
- `"lte"`
- `"="`
- `"!="`
- `">"`
- `">="`
- `"<"`
- `"<="`
- `"INCLUDES"`
- `"DOES_NOT_INCLUDE"`
- `"MATCH_REGEX"`
- `"EXISTS"`
- `"DOES_NOT_EXIST"`
- `"IN"`
- `"NOT_IN"`
- `"STARTS_WITH"`
- `type: Literal["string", "number", "boolean"]`
Data type of the filter field. Must match the actual type of the key being filtered.
- `"string"`
- `"number"`
- `"boolean"`
- `kind: Optional[Literal["filter"]]`
Discriminator for leaf filter nodes. Always 'filter' when present; may be omitted.
- `"filter"`
- `value: Optional[Union[str, float, bool]]`
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
- `str`
- `float`
- `bool`
- `from_: Optional[float]`
- `key_needle: Optional[KeyNeedle]`
If the user suggests a key, use this to narrow down the list of keys returned. Make sure matchCase is false to avoid case sensitivity issues.
- `value: Union[str, float, bool]`
The text or pattern to search for.
- `str`
- `float`
- `bool`
- `is_regex: Optional[bool]`
When true, treats the value as a regular expression (RE2 syntax).
- `match_case: Optional[bool]`
When true, performs a case-sensitive search. Defaults to case-insensitive.
- `limit: Optional[float]`
Advanced usage: set limit=1000+ to retrieve comprehensive key options without needing additional filtering.
- `needle: Optional[Needle]`
Search for a specific substring in any of the events
- `value: Union[str, float, bool]`
The text or pattern to search for.
- `str`
- `float`
- `bool`
- `is_regex: Optional[bool]`
When true, treats the value as a regular expression (RE2 syntax).
- `match_case: Optional[bool]`
When true, performs a case-sensitive search. Defaults to case-insensitive.
- `to: Optional[float]`
### Returns
- `class TelemetryKeysResponse: …`
- `key: str`
- `last_seen_at: float`
- `type: Literal["string", "boolean", "number"]`
- `"string"`
- `"boolean"`
- `"number"`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted
api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted
)
page = client.workers.observability.telemetry.keys(
account_id="account_id",
)
page = page.result[0]
print(page.key)
```
#### Response
```json
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": [
{
"key": "key",
"lastSeenAt": 0,
"type": "string"
}
],
"success": true
}
```
## Run a query
`workers.observability.telemetry.query(TelemetryQueryParams**kwargs) -> TelemetryQueryResponse`
**post** `/accounts/{account_id}/workers/observability/telemetry/query`
Run a temporary or saved query.
### Parameters
- `account_id: str`
- `query_id: str`
Identifier for the query. When parameters are omitted, this ID is used to load a previously saved query's parameters. When providing parameters inline, pass any identifier (e.g. an ad-hoc ID).
- `timeframe: Timeframe`
Timeframe for the query using Unix timestamps in milliseconds. Narrower timeframes produce faster responses and more specific results.
- `from_: float`
Start timestamp for the query timeframe (Unix timestamp in milliseconds)
- `to: float`
End timestamp for the query timeframe (Unix timestamp in milliseconds)
- `chart: Optional[bool]`
When true, includes time-series data in the response.
- `compare: Optional[bool]`
When true, includes a comparison dataset from the previous time period of equal length.
- `dry: Optional[bool]`
When true, executes the query without persisting the results. Useful for validation or previewing.
- `granularity: Optional[float]`
Number of time-series buckets. Only used when view is 'calculations'. Omit to let the system auto-detect an appropriate granularity.
- `ignore_series: Optional[bool]`
When true, omits time-series data from the response and returns only aggregated values. Reduces response size when series are not needed.
- `limit: Optional[float]`
Maximum number of events to return when view is 'events'. Also controls the number of group-by rows when view is 'calculations'.
- `offset: Optional[str]`
Cursor for pagination in event, trace, and invocation views. Pass the $metadata.id of the last returned item to fetch the next page.
- `offset_by: Optional[float]`
Numeric offset for paginating grouped/pattern results (top-N lists). Use together with limit. Not used by cursor-based pagination.
- `offset_direction: Optional[str]`
Pagination direction: 'next' for forward, 'prev' for backward.
- `parameters: Optional[Parameters]`
Query parameters defining what data to retrieve — filters, calculations, group-bys, and ordering. In practice this should always be provided for ad-hoc queries. Only omit when executing a previously saved query by queryId. Use the keys and values endpoints to discover available fields before building filters.
- `calculations: Optional[Iterable[ParametersCalculation]]`
Aggregation calculations to compute (e.g. count, avg, p99). Each calculation produces aggregate values and optional time-series data.
- `operator: Literal["uniq", "count", "max", 35 more]`
Aggregation operator to apply. Examples: count, avg, sum, min, max, p50, p90, p95, p99, uniq, stddev, variance.
- `"uniq"`
- `"count"`
- `"max"`
- `"min"`
- `"sum"`
- `"avg"`
- `"median"`
- `"p001"`
- `"p01"`
- `"p05"`
- `"p10"`
- `"p25"`
- `"p75"`
- `"p90"`
- `"p95"`
- `"p99"`
- `"p999"`
- `"stddev"`
- `"variance"`
- `"COUNT_DISTINCT"`
- `"COUNT"`
- `"MAX"`
- `"MIN"`
- `"SUM"`
- `"AVG"`
- `"MEDIAN"`
- `"P001"`
- `"P01"`
- `"P05"`
- `"P10"`
- `"P25"`
- `"P75"`
- `"P90"`
- `"P95"`
- `"P99"`
- `"P999"`
- `"STDDEV"`
- `"VARIANCE"`
- `alias: Optional[str]`
Custom label for this calculation in the results. Useful for distinguishing multiple calculations.
- `key: Optional[str]`
Field name to calculate over. Must exist in the data — verify with the keys endpoint. Omit for operators that don't require a key (e.g. count).
- `key_type: Optional[Literal["string", "number", "boolean"]]`
Data type of the key. Required when key is provided to ensure correct aggregation.
- `"string"`
- `"number"`
- `"boolean"`
- `datasets: Optional[Sequence[str]]`
Datasets to query. Leave empty to query all available datasets.
- `filter_combination: Optional[Literal["and", "or", "AND", "OR"]]`
Logical operator for combining top-level filters: 'and' (all must match) or 'or' (any must match). Defaults to 'and'.
- `"and"`
- `"or"`
- `"AND"`
- `"OR"`
- `filters: Optional[Iterable[ParametersFilter]]`
Filters to narrow query results. Use the keys and values endpoints to discover available fields before building filters. Supports nested groups via kind: 'group'. Maximum nesting depth is 4.
- `class ParametersFilterUnionMember0: …`
- `filter_combination: Literal["and", "or", "AND", "OR"]`
- `"and"`
- `"or"`
- `"AND"`
- `"OR"`
- `filters: Iterable[ParametersFilterUnionMember0Filter]`
- `class ParametersFilterUnionMember0FilterUnionMember0: …`
- `filter_combination: Literal["and", "or", "AND", "OR"]`
- `"and"`
- `"or"`
- `"AND"`
- `"OR"`
- `filters: Iterable[object]`
- `kind: Literal["group"]`
- `"group"`
- `class ParametersFilterUnionMember0FilterWorkersObservabilityFilterLeaf: …`
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
- `key: str`
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
- `operation: Literal["includes", "not_includes", "starts_with", 25 more]`
Comparison operator. String operators: includes, not_includes, starts_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
- `"includes"`
- `"not_includes"`
- `"starts_with"`
- `"regex"`
- `"exists"`
- `"is_null"`
- `"in"`
- `"not_in"`
- `"eq"`
- `"neq"`
- `"gt"`
- `"gte"`
- `"lt"`
- `"lte"`
- `"="`
- `"!="`
- `">"`
- `">="`
- `"<"`
- `"<="`
- `"INCLUDES"`
- `"DOES_NOT_INCLUDE"`
- `"MATCH_REGEX"`
- `"EXISTS"`
- `"DOES_NOT_EXIST"`
- `"IN"`
- `"NOT_IN"`
- `"STARTS_WITH"`
- `type: Literal["string", "number", "boolean"]`
Data type of the filter field. Must match the actual type of the key being filtered.
- `"string"`
- `"number"`
- `"boolean"`
- `kind: Optional[Literal["filter"]]`
Discriminator for leaf filter nodes. Always 'filter' when present; may be omitted.
- `"filter"`
- `value: Optional[Union[str, float, bool]]`
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
- `str`
- `float`
- `bool`
- `kind: Literal["group"]`
- `"group"`
- `class ParametersFilterWorkersObservabilityFilterLeaf: …`
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
- `key: str`
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
- `operation: Literal["includes", "not_includes", "starts_with", 25 more]`
Comparison operator. String operators: includes, not_includes, starts_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
- `"includes"`
- `"not_includes"`
- `"starts_with"`
- `"regex"`
- `"exists"`
- `"is_null"`
- `"in"`
- `"not_in"`
- `"eq"`
- `"neq"`
- `"gt"`
- `"gte"`
- `"lt"`
- `"lte"`
- `"="`
- `"!="`
- `">"`
- `">="`
- `"<"`
- `"<="`
- `"INCLUDES"`
- `"DOES_NOT_INCLUDE"`
- `"MATCH_REGEX"`
- `"EXISTS"`
- `"DOES_NOT_EXIST"`
- `"IN"`
- `"NOT_IN"`
- `"STARTS_WITH"`
- `type: Literal["string", "number", "boolean"]`
Data type of the filter field. Must match the actual type of the key being filtered.
- `"string"`
- `"number"`
- `"boolean"`
- `kind: Optional[Literal["filter"]]`
Discriminator for leaf filter nodes. Always 'filter' when present; may be omitted.
- `"filter"`
- `value: Optional[Union[str, float, bool]]`
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
- `str`
- `float`
- `bool`
- `group_bys: Optional[Iterable[ParametersGroupBy]]`
Fields to group calculation results by. Only applicable when the query view is 'calculations'. Produces per-group aggregate values.
- `type: Literal["string", "number", "boolean"]`
Data type of the group-by field.
- `"string"`
- `"number"`
- `"boolean"`
- `value: str`
Field name to group results by (e.g. $metadata.service, $metadata.statusCode).
- `havings: Optional[Iterable[ParametersHaving]]`
Post-aggregation filters applied to calculation results. Use to filter groups after aggregation (e.g. only groups where count > 100).
- `key: str`
Calculation alias or operator to filter on after aggregation.
- `operation: Literal["eq", "neq", "gt", 3 more]`
Numeric comparison operator: eq, neq, gt, gte, lt, lte.
- `"eq"`
- `"neq"`
- `"gt"`
- `"gte"`
- `"lt"`
- `"lte"`
- `value: float`
Threshold value to compare the calculation result against.
- `limit: Optional[int]`
Maximum number of group-by rows to return in calculation results. A value of 10 is a sensible default for most use cases.
- `needle: Optional[ParametersNeedle]`
Full-text search expression applied across all event fields. Matches events containing the specified text.
- `value: Union[str, float, bool]`
The text or pattern to search for.
- `str`
- `float`
- `bool`
- `is_regex: Optional[bool]`
When true, treats the value as a regular expression (RE2 syntax).
- `match_case: Optional[bool]`
When true, performs a case-sensitive search. Defaults to case-insensitive.
- `order_by: Optional[ParametersOrderBy]`
Ordering for grouped calculation results. Only effective when a group-by is present.
- `value: str`
Alias of the calculation to order results by. Must match the alias (or operator) of a calculation in the query.
- `order: Optional[Literal["asc", "desc"]]`
Sort direction: 'asc' for ascending, 'desc' for descending.
- `"asc"`
- `"desc"`
- `view: Optional[Literal["traces", "events", "calculations", 3 more]]`
Controls the shape of the response. 'events': individual log lines matching the query. 'calculations': aggregated metrics (count, avg, p99, etc.) with optional group-by breakdowns and time-series. 'invocations': events grouped by request ID. 'traces': distributed trace summaries. 'agents': Durable Object agent summaries.
- `"traces"`
- `"events"`
- `"calculations"`
- `"invocations"`
- `"requests"`
- `"agents"`
### Returns
- `class TelemetryQueryResponse: …`
Complete results of a query run. The populated fields depend on the requested view type (events, calculations, invocations, traces, or agents).
- `run: Run`
The query run metadata including the query definition, execution status, and timeframe.
- `id: str`
Unique identifier for this query run.
- `account_id: str`
Cloudflare account ID that owns this query run.
- `dry: bool`
Whether this was a dry run (results not persisted).
- `granularity: float`
Number of time-series buckets used for the query. Higher values produce more detailed series data.
- `query: RunQuery`
A saved query definition with its parameters, metadata, and ownership information.
- `id: str`
- `adhoc: bool`
If the query wasn't explcitly saved
- `created: str`
- `created_by: str`
- `description: Optional[str]`
- `name: str`
Query name
- `parameters: RunQueryParameters`
- `calculations: Optional[List[RunQueryParametersCalculation]]`
Create Calculations to compute as part of the query.
- `operator: Literal["uniq", "count", "max", 35 more]`
- `"uniq"`
- `"count"`
- `"max"`
- `"min"`
- `"sum"`
- `"avg"`
- `"median"`
- `"p001"`
- `"p01"`
- `"p05"`
- `"p10"`
- `"p25"`
- `"p75"`
- `"p90"`
- `"p95"`
- `"p99"`
- `"p999"`
- `"stddev"`
- `"variance"`
- `"COUNT_DISTINCT"`
- `"COUNT"`
- `"MAX"`
- `"MIN"`
- `"SUM"`
- `"AVG"`
- `"MEDIAN"`
- `"P001"`
- `"P01"`
- `"P05"`
- `"P10"`
- `"P25"`
- `"P75"`
- `"P90"`
- `"P95"`
- `"P99"`
- `"P999"`
- `"STDDEV"`
- `"VARIANCE"`
- `alias: Optional[str]`
- `key: Optional[str]`
- `key_type: Optional[Literal["string", "number", "boolean"]]`
- `"string"`
- `"number"`
- `"boolean"`
- `datasets: Optional[List[str]]`
Set the Datasets to query. Leave it empty to query all the datasets.
- `filter_combination: Optional[Literal["and", "or", "AND", "OR"]]`
Set a Flag to describe how to combine the filters on the query.
- `"and"`
- `"or"`
- `"AND"`
- `"OR"`
- `filters: Optional[List[RunQueryParametersFilter]]`
Configure the Filters to apply to the query. Supports nested groups via kind: 'group'.
- `class RunQueryParametersFilterUnionMember0: …`
- `filter_combination: Literal["and", "or", "AND", "OR"]`
- `"and"`
- `"or"`
- `"AND"`
- `"OR"`
- `filters: List[object]`
- `kind: Literal["group"]`
- `"group"`
- `class RunQueryParametersFilterWorkersObservabilityFilterLeaf: …`
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
- `key: str`
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
- `operation: Literal["includes", "not_includes", "starts_with", 25 more]`
Comparison operator. String operators: includes, not_includes, starts_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
- `"includes"`
- `"not_includes"`
- `"starts_with"`
- `"regex"`
- `"exists"`
- `"is_null"`
- `"in"`
- `"not_in"`
- `"eq"`
- `"neq"`
- `"gt"`
- `"gte"`
- `"lt"`
- `"lte"`
- `"="`
- `"!="`
- `">"`
- `">="`
- `"<"`
- `"<="`
- `"INCLUDES"`
- `"DOES_NOT_INCLUDE"`
- `"MATCH_REGEX"`
- `"EXISTS"`
- `"DOES_NOT_EXIST"`
- `"IN"`
- `"NOT_IN"`
- `"STARTS_WITH"`
- `type: Literal["string", "number", "boolean"]`
Data type of the filter field. Must match the actual type of the key being filtered.
- `"string"`
- `"number"`
- `"boolean"`
- `kind: Optional[Literal["filter"]]`
Discriminator for leaf filter nodes. Always 'filter' when present; may be omitted.
- `"filter"`
- `value: Optional[Union[str, float, bool, null]]`
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
- `str`
- `float`
- `bool`
- `group_bys: Optional[List[RunQueryParametersGroupBy]]`
Define how to group the results of the query.
- `type: Literal["string", "number", "boolean"]`
- `"string"`
- `"number"`
- `"boolean"`
- `value: str`
- `havings: Optional[List[RunQueryParametersHaving]]`
Configure the Having clauses that filter on calculations in the query result.
- `key: str`
- `operation: Literal["eq", "neq", "gt", 3 more]`
- `"eq"`
- `"neq"`
- `"gt"`
- `"gte"`
- `"lt"`
- `"lte"`
- `value: float`
- `limit: Optional[int]`
Set a limit on the number of results / records returned by the query
- `needle: Optional[RunQueryParametersNeedle]`
Define an expression to search using full-text search.
- `value: RunQueryParametersNeedleValue`
- `is_regex: Optional[bool]`
- `match_case: Optional[bool]`
- `order_by: Optional[RunQueryParametersOrderBy]`
Configure the order of the results returned by the query.
- `value: str`
Configure which Calculation to order the results by.
- `order: Optional[Literal["asc", "desc"]]`
Set the order of the results
- `"asc"`
- `"desc"`
- `updated: str`
- `updated_by: str`
- `status: Literal["STARTED", "COMPLETED"]`
Current execution status of the query run.
- `"STARTED"`
- `"COMPLETED"`
- `timeframe: RunTimeframe`
Time range for the query execution
- `from_: float`
Start timestamp for the query timeframe (Unix timestamp in milliseconds)
- `to: float`
End timestamp for the query timeframe (Unix timestamp in milliseconds)
- `user_id: str`
ID of the user who initiated the query run.
- `created: Optional[str]`
ISO-8601 timestamp when the query run was created.
- `statistics: Optional[RunStatistics]`
Query performance statistics from the database (does not include network latency).
- `bytes_read: float`
Number of uncompressed bytes read from the table.
- `elapsed: float`
Time in seconds for the query to run.
- `rows_read: float`
Number of rows scanned from the table.
- `abr_level: Optional[float]`
The level of Adaptive Bit Rate (ABR) sampling used for the query. If empty the ABR level is 1
- `updated: Optional[str]`
ISO-8601 timestamp when the query run was last updated.
- `statistics: Statistics`
Query performance statistics from the database. Includes execution time, rows scanned, and bytes read. Does not include network latency.
- `bytes_read: float`
Number of uncompressed bytes read from the table.
- `elapsed: float`
Time in seconds for the query to run.
- `rows_read: float`
Number of rows scanned from the table.
- `abr_level: Optional[float]`
The level of Adaptive Bit Rate (ABR) sampling used for the query. If empty the ABR level is 1
- `agents: Optional[List[Agent]]`
Durable Object agent summaries. Present when the query view is 'agents'. Each entry represents an agent with its event counts and status.
- `agent_class: str`
Class name of the Durable Object agent.
- `event_type_counts: Dict[str, float]`
Breakdown of event counts by event type.
- `first_event_ms: float`
Timestamp of the earliest event from this agent in the queried window (Unix epoch ms).
- `has_errors: bool`
Whether the agent emitted any error events in the queried window.
- `last_event_ms: float`
Timestamp of the most recent event from this agent (Unix epoch ms).
- `namespace: str`
Durable Object namespace the agent belongs to.
- `service: str`
Worker service name that hosts this agent.
- `total_events: float`
Total number of events emitted by this agent in the queried window.
- `calculations: Optional[List[Calculation]]`
Aggregated calculation results. Present when the query view is 'calculations'. Contains computed metrics (count, avg, p99, etc.) with optional group-by breakdowns and time-series data.
- `aggregates: List[CalculationAggregate]`
- `count: float`
- `interval: float`
- `sample_interval: float`
- `value: float`
- `groups: Optional[List[CalculationAggregateGroup]]`
- `key: str`
- `value: Union[str, float, bool]`
- `str`
- `float`
- `bool`
- `calculation: str`
- `series: List[CalculationSeries]`
- `data: List[CalculationSeriesData]`
- `count: float`
- `interval: float`
- `sample_interval: float`
- `value: float`
- `first_seen: Optional[str]`
- `groups: Optional[List[CalculationSeriesDataGroup]]`
- `key: str`
- `value: Union[str, float, bool]`
- `str`
- `float`
- `bool`
- `last_seen: Optional[str]`
- `time: str`
- `alias: Optional[str]`
- `compare: Optional[List[Compare]]`
Comparison calculation results from the previous time period. Present when the compare option is enabled. Same structure as calculations.
- `aggregates: List[CompareAggregate]`
- `count: float`
- `interval: float`
- `sample_interval: float`
- `value: float`
- `groups: Optional[List[CompareAggregateGroup]]`
- `key: str`
- `value: Union[str, float, bool]`
- `str`
- `float`
- `bool`
- `calculation: str`
- `series: List[CompareSeries]`
- `data: List[CompareSeriesData]`
- `count: float`
- `interval: float`
- `sample_interval: float`
- `value: float`
- `first_seen: Optional[str]`
- `groups: Optional[List[CompareSeriesDataGroup]]`
- `key: str`
- `value: Union[str, float, bool]`
- `str`
- `float`
- `bool`
- `last_seen: Optional[str]`
- `time: str`
- `alias: Optional[str]`
- `events: Optional[Events]`
Individual event results. Present when the query view is 'events'. Contains the matching log lines and their metadata.
- `count: Optional[float]`
Total number of events matching the query (may exceed the number returned due to limits).
- `events: Optional[List[EventsEvent]]`
List of individual telemetry events matching the query.
- `metadata: EventsEventMetadata`
Structured metadata extracted from the event. These fields are indexed and available for filtering and aggregation.
- `id: str`
Unique event ID. Use as the cursor value for offset-based pagination.
- `account: Optional[str]`
Cloudflare account identifier.
- `cloud_service: Optional[str]`
Cloudflare product that generated this event (e.g. workers, pages).
- `cold_start: Optional[int]`
Whether this was a cold start (1) or warm invocation (0).
- `cost: Optional[int]`
Estimated cost units for this invocation.
- `duration: Optional[int]`
Span duration in milliseconds.
- `end_time: Optional[int]`
Span end time as a Unix epoch in milliseconds.
- `error: Optional[str]`
Error message, present when the log represents an error.
- `error_template: Optional[str]`
Templatized version of the error message used for grouping similar errors.
- `fingerprint: Optional[str]`
Content-based fingerprint used to group similar events.
- `level: Optional[str]`
Log level (e.g. log, debug, info, warn, error).
- `message: Optional[str]`
Log message text.
- `message_template: Optional[str]`
Templatized version of the log message used for grouping similar messages.
- `metric_name: Optional[str]`
Metric name when the event represents a metric data point.
- `origin: Optional[str]`
Origin of the event (e.g. fetch, scheduled, queue).
- `parent_span_id: Optional[str]`
Span ID of the parent span in the trace hierarchy.
- `provider: Optional[str]`
Infrastructure provider identifier.
- `region: Optional[str]`
Cloudflare data center / region that handled the request.
- `request_id: Optional[str]`
Cloudflare request ID that ties all logs from a single invocation together.
- `service: Optional[str]`
Worker script name that produced this event.
- `span_id: Optional[str]`
Span ID for this individual unit of work within a trace.
- `span_name: Optional[str]`
Human-readable name for this span.
- `stack_id: Optional[str]`
Stack / deployment identifier.
- `start_time: Optional[int]`
Span start time as a Unix epoch in milliseconds.
- `status_code: Optional[int]`
HTTP response status code returned by the Worker.
- `trace_duration: Optional[int]`
Total duration of the entire trace in milliseconds.
- `trace_id: Optional[str]`
Distributed trace ID linking spans across services.
- `transaction_name: Optional[str]`
Logical transaction name for this request.
- `trigger: Optional[str]`
What triggered the invocation (e.g. GET /users, POST /orders, queue message).
- `type: Optional[str]`
Event type classifier (e.g. cf-worker-event, cf-worker-log).
- `url: Optional[str]`
Request URL that triggered the Worker invocation.
- `dataset: str`
The dataset this event belongs to (e.g. cloudflare-workers).
- `source: Union[str, object]`
Raw log payload. May be a string or a structured object depending on how the log was emitted.
- `str`
- `object`
- `timestamp: int`
Event timestamp as a Unix epoch in milliseconds.
- `containers: Optional[object]`
Cloudflare Containers event information that enriches your logs for identifying and debugging issues.
- `workers: Optional[EventsEventWorkers]`
Cloudflare Workers event information that enriches your logs for identifying and debugging issues.
- `class EventsEventWorkersUnionMember0: …`
- `event_type: Literal["fetch", "scheduled", "alarm", 8 more]`
- `"fetch"`
- `"scheduled"`
- `"alarm"`
- `"cron"`
- `"queue"`
- `"email"`
- `"tail"`
- `"rpc"`
- `"websocket"`
- `"workflow"`
- `"unknown"`
- `request_id: str`
- `script_name: str`
- `durable_object_id: Optional[str]`
- `entrypoint: Optional[str]`
- `event: Optional[Dict[str, object]]`
- `execution_model: Optional[Literal["durableObject", "stateless"]]`
- `"durableObject"`
- `"stateless"`
- `outcome: Optional[str]`
- `script_version: Optional[EventsEventWorkersUnionMember0ScriptVersion]`
- `id: Optional[str]`
- `message: Optional[str]`
- `tag: Optional[str]`
- `span_id: Optional[str]`
- `trace_id: Optional[str]`
- `truncated: Optional[bool]`
- `class EventsEventWorkersUnionMember1: …`
- `cpu_time_ms: float`
- `event_type: Literal["fetch", "scheduled", "alarm", 8 more]`
- `"fetch"`
- `"scheduled"`
- `"alarm"`
- `"cron"`
- `"queue"`
- `"email"`
- `"tail"`
- `"rpc"`
- `"websocket"`
- `"workflow"`
- `"unknown"`
- `outcome: str`
- `request_id: str`
- `script_name: str`
- `wall_time_ms: float`
- `diagnostics_channel_events: Optional[List[EventsEventWorkersUnionMember1DiagnosticsChannelEvent]]`
- `channel: str`
- `message: str`
- `timestamp: float`
- `dispatch_namespace: Optional[str]`
- `durable_object_id: Optional[str]`
- `entrypoint: Optional[str]`
- `event: Optional[Dict[str, object]]`
- `execution_model: Optional[Literal["durableObject", "stateless"]]`
- `"durableObject"`
- `"stateless"`
- `script_version: Optional[EventsEventWorkersUnionMember1ScriptVersion]`
- `id: Optional[str]`
- `message: Optional[str]`
- `tag: Optional[str]`
- `span_id: Optional[str]`
- `trace_id: Optional[str]`
- `truncated: Optional[bool]`
- `fields: Optional[List[EventsField]]`
List of fields discovered in the matched events. Useful for building dynamic UIs.
- `key: str`
Field name present in the matched events.
- `type: str`
Data type of the field (string, number, or boolean).
- `series: Optional[List[EventsSeries]]`
Time-series data for the matched events, bucketed by the query granularity.
- `data: List[EventsSeriesData]`
- `aggregates: EventsSeriesDataAggregates`
- `_count: int`
- `_interval: float`
- `_first_seen: Optional[str]`
- `_last_seen: Optional[str]`
- `bin: Optional[object]`
- `count: float`
- `interval: float`
- `sample_interval: float`
- `errors: Optional[float]`
- `groups: Optional[Dict[str, Union[str, float, bool]]]`
Groups in the query results.
- `str`
- `float`
- `bool`
- `time: str`
- `invocations: Optional[Dict[str, List[Invocation]]]`
Events grouped by invocation (request ID). Present when the query view is 'invocations'. Each key is a request ID mapping to all events from that invocation.
- `metadata: InvocationMetadata`
Structured metadata extracted from the event. These fields are indexed and available for filtering and aggregation.
- `id: str`
Unique event ID. Use as the cursor value for offset-based pagination.
- `account: Optional[str]`
Cloudflare account identifier.
- `cloud_service: Optional[str]`
Cloudflare product that generated this event (e.g. workers, pages).
- `cold_start: Optional[int]`
Whether this was a cold start (1) or warm invocation (0).
- `cost: Optional[int]`
Estimated cost units for this invocation.
- `duration: Optional[int]`
Span duration in milliseconds.
- `end_time: Optional[int]`
Span end time as a Unix epoch in milliseconds.
- `error: Optional[str]`
Error message, present when the log represents an error.
- `error_template: Optional[str]`
Templatized version of the error message used for grouping similar errors.
- `fingerprint: Optional[str]`
Content-based fingerprint used to group similar events.
- `level: Optional[str]`
Log level (e.g. log, debug, info, warn, error).
- `message: Optional[str]`
Log message text.
- `message_template: Optional[str]`
Templatized version of the log message used for grouping similar messages.
- `metric_name: Optional[str]`
Metric name when the event represents a metric data point.
- `origin: Optional[str]`
Origin of the event (e.g. fetch, scheduled, queue).
- `parent_span_id: Optional[str]`
Span ID of the parent span in the trace hierarchy.
- `provider: Optional[str]`
Infrastructure provider identifier.
- `region: Optional[str]`
Cloudflare data center / region that handled the request.
- `request_id: Optional[str]`
Cloudflare request ID that ties all logs from a single invocation together.
- `service: Optional[str]`
Worker script name that produced this event.
- `span_id: Optional[str]`
Span ID for this individual unit of work within a trace.
- `span_name: Optional[str]`
Human-readable name for this span.
- `stack_id: Optional[str]`
Stack / deployment identifier.
- `start_time: Optional[int]`
Span start time as a Unix epoch in milliseconds.
- `status_code: Optional[int]`
HTTP response status code returned by the Worker.
- `trace_duration: Optional[int]`
Total duration of the entire trace in milliseconds.
- `trace_id: Optional[str]`
Distributed trace ID linking spans across services.
- `transaction_name: Optional[str]`
Logical transaction name for this request.
- `trigger: Optional[str]`
What triggered the invocation (e.g. GET /users, POST /orders, queue message).
- `type: Optional[str]`
Event type classifier (e.g. cf-worker-event, cf-worker-log).
- `url: Optional[str]`
Request URL that triggered the Worker invocation.
- `dataset: str`
The dataset this event belongs to (e.g. cloudflare-workers).
- `source: Union[str, object]`
Raw log payload. May be a string or a structured object depending on how the log was emitted.
- `str`
- `object`
- `timestamp: int`
Event timestamp as a Unix epoch in milliseconds.
- `containers: Optional[object]`
Cloudflare Containers event information that enriches your logs for identifying and debugging issues.
- `workers: Optional[InvocationWorkers]`
Cloudflare Workers event information that enriches your logs for identifying and debugging issues.
- `class InvocationWorkersUnionMember0: …`
- `event_type: Literal["fetch", "scheduled", "alarm", 8 more]`
- `"fetch"`
- `"scheduled"`
- `"alarm"`
- `"cron"`
- `"queue"`
- `"email"`
- `"tail"`
- `"rpc"`
- `"websocket"`
- `"workflow"`
- `"unknown"`
- `request_id: str`
- `script_name: str`
- `durable_object_id: Optional[str]`
- `entrypoint: Optional[str]`
- `event: Optional[Dict[str, object]]`
- `execution_model: Optional[Literal["durableObject", "stateless"]]`
- `"durableObject"`
- `"stateless"`
- `outcome: Optional[str]`
- `script_version: Optional[InvocationWorkersUnionMember0ScriptVersion]`
- `id: Optional[str]`
- `message: Optional[str]`
- `tag: Optional[str]`
- `span_id: Optional[str]`
- `trace_id: Optional[str]`
- `truncated: Optional[bool]`
- `class InvocationWorkersUnionMember1: …`
- `cpu_time_ms: float`
- `event_type: Literal["fetch", "scheduled", "alarm", 8 more]`
- `"fetch"`
- `"scheduled"`
- `"alarm"`
- `"cron"`
- `"queue"`
- `"email"`
- `"tail"`
- `"rpc"`
- `"websocket"`
- `"workflow"`
- `"unknown"`
- `outcome: str`
- `request_id: str`
- `script_name: str`
- `wall_time_ms: float`
- `diagnostics_channel_events: Optional[List[InvocationWorkersUnionMember1DiagnosticsChannelEvent]]`
- `channel: str`
- `message: str`
- `timestamp: float`
- `dispatch_namespace: Optional[str]`
- `durable_object_id: Optional[str]`
- `entrypoint: Optional[str]`
- `event: Optional[Dict[str, object]]`
- `execution_model: Optional[Literal["durableObject", "stateless"]]`
- `"durableObject"`
- `"stateless"`
- `script_version: Optional[InvocationWorkersUnionMember1ScriptVersion]`
- `id: Optional[str]`
- `message: Optional[str]`
- `tag: Optional[str]`
- `span_id: Optional[str]`
- `trace_id: Optional[str]`
- `truncated: Optional[bool]`
- `traces: Optional[List[Trace]]`
Trace summaries matching the query. Present when the query view is 'traces'. Each entry represents a distributed trace with its spans, duration, and services involved.
- `root_span_name: str`
Name of the root span that initiated the trace.
- `root_transaction_name: str`
Logical transaction name for the root span.
- `service: List[str]`
List of Worker services involved in the trace.
- `spans: float`
Total number of spans in the trace.
- `trace_duration_ms: float`
Total duration of the trace in milliseconds.
- `trace_end_ms: float`
Trace end time as a Unix epoch in milliseconds.
- `trace_id: str`
Unique identifier for the distributed trace.
- `trace_start_ms: float`
Trace start time as a Unix epoch in milliseconds.
- `errors: Optional[List[str]]`
Error messages encountered during the trace, if any.
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted
api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted
)
response = client.workers.observability.telemetry.query(
account_id="account_id",
query_id="queryId",
timeframe={
"from": 0,
"to": 0,
},
)
print(response.run)
```
#### Response
```json
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": {
"run": {
"id": "id",
"accountId": "accountId",
"dry": true,
"granularity": 0,
"query": {
"id": "id",
"adhoc": true,
"created": "created",
"createdBy": "createdBy",
"description": "Query description",
"name": "x",
"parameters": {
"calculations": [
{
"operator": "uniq",
"alias": "alias",
"key": "key",
"keyType": "string"
}
],
"datasets": [
"string"
],
"filterCombination": "and",
"filters": [
{
"filterCombination": "and",
"filters": [
{}
],
"kind": "group"
}
],
"groupBys": [
{
"type": "string",
"value": "value"
}
],
"havings": [
{
"key": "key",
"operation": "eq",
"value": 0
}
],
"limit": 0,
"needle": {
"value": {
"0": "s",
"1": "t",
"2": "r",
"3": "i",
"4": "n",
"5": "g"
},
"isRegex": true,
"matchCase": true
},
"orderBy": {
"value": "value",
"order": "asc"
}
},
"updated": "updated",
"updatedBy": "updatedBy"
},
"status": "STARTED",
"timeframe": {
"from": 0,
"to": 0
},
"userId": "userId",
"created": "created",
"statistics": {
"bytes_read": 0,
"elapsed": 0,
"rows_read": 0,
"abr_level": 0
},
"updated": "updated"
},
"statistics": {
"bytes_read": 0,
"elapsed": 0,
"rows_read": 0,
"abr_level": 0
},
"agents": [
{
"agentClass": "agentClass",
"eventTypeCounts": {
"foo": 0
},
"firstEventMs": 0,
"hasErrors": true,
"lastEventMs": 0,
"namespace": "namespace",
"service": "service",
"totalEvents": 0
}
],
"calculations": [
{
"aggregates": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"groups": [
{
"key": "key",
"value": "string"
}
]
}
],
"calculation": "calculation",
"series": [
{
"data": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"firstSeen": "firstSeen",
"groups": [
{
"key": "key",
"value": "string"
}
],
"lastSeen": "lastSeen"
}
],
"time": "time"
}
],
"alias": "alias"
}
],
"compare": [
{
"aggregates": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"groups": [
{
"key": "key",
"value": "string"
}
]
}
],
"calculation": "calculation",
"series": [
{
"data": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"firstSeen": "firstSeen",
"groups": [
{
"key": "key",
"value": "string"
}
],
"lastSeen": "lastSeen"
}
],
"time": "time"
}
],
"alias": "alias"
}
],
"events": {
"count": 0,
"events": [
{
"$metadata": {
"id": "id",
"account": "account",
"cloudService": "cloudService",
"coldStart": 1,
"cost": 1,
"duration": 1,
"endTime": 0,
"error": "error",
"errorTemplate": "errorTemplate",
"fingerprint": "fingerprint",
"level": "level",
"message": "message",
"messageTemplate": "messageTemplate",
"metricName": "metricName",
"origin": "origin",
"parentSpanId": "parentSpanId",
"provider": "provider",
"region": "region",
"requestId": "requestId",
"service": "service",
"spanId": "spanId",
"spanName": "spanName",
"stackId": "stackId",
"startTime": 0,
"statusCode": 1,
"traceDuration": 1,
"traceId": "traceId",
"transactionName": "transactionName",
"trigger": "trigger",
"type": "type",
"url": "url"
},
"dataset": "dataset",
"source": "string",
"timestamp": 0,
"$containers": {},
"$workers": {
"eventType": "fetch",
"requestId": "requestId",
"scriptName": "scriptName",
"durableObjectId": "durableObjectId",
"entrypoint": "entrypoint",
"event": {
"foo": "bar"
},
"executionModel": "durableObject",
"outcome": "outcome",
"scriptVersion": {
"id": "id",
"message": "message",
"tag": "tag"
},
"spanId": "spanId",
"traceId": "traceId",
"truncated": true
}
}
],
"fields": [
{
"key": "key",
"type": "type"
}
],
"series": [
{
"data": [
{
"aggregates": {
"_count": 1,
"_interval": 1,
"_firstSeen": "_firstSeen",
"_lastSeen": "_lastSeen",
"bin": {}
},
"count": 0,
"interval": 0,
"sampleInterval": 0,
"errors": 0,
"groups": {
"foo": "string"
}
}
],
"time": "time"
}
]
},
"invocations": {
"foo": [
{
"$metadata": {
"id": "id",
"account": "account",
"cloudService": "cloudService",
"coldStart": 1,
"cost": 1,
"duration": 1,
"endTime": 0,
"error": "error",
"errorTemplate": "errorTemplate",
"fingerprint": "fingerprint",
"level": "level",
"message": "message",
"messageTemplate": "messageTemplate",
"metricName": "metricName",
"origin": "origin",
"parentSpanId": "parentSpanId",
"provider": "provider",
"region": "region",
"requestId": "requestId",
"service": "service",
"spanId": "spanId",
"spanName": "spanName",
"stackId": "stackId",
"startTime": 0,
"statusCode": 1,
"traceDuration": 1,
"traceId": "traceId",
"transactionName": "transactionName",
"trigger": "trigger",
"type": "type",
"url": "url"
},
"dataset": "dataset",
"source": "string",
"timestamp": 0,
"$containers": {},
"$workers": {
"eventType": "fetch",
"requestId": "requestId",
"scriptName": "scriptName",
"durableObjectId": "durableObjectId",
"entrypoint": "entrypoint",
"event": {
"foo": "bar"
},
"executionModel": "durableObject",
"outcome": "outcome",
"scriptVersion": {
"id": "id",
"message": "message",
"tag": "tag"
},
"spanId": "spanId",
"traceId": "traceId",
"truncated": true
}
}
]
},
"traces": [
{
"rootSpanName": "rootSpanName",
"rootTransactionName": "rootTransactionName",
"service": [
"string"
],
"spans": 0,
"traceDurationMs": 0,
"traceEndMs": 0,
"traceId": "traceId",
"traceStartMs": 0,
"errors": [
"string"
]
}
]
},
"success": true
}
```
## List values
`workers.observability.telemetry.values(TelemetryValuesParams**kwargs) -> SyncSinglePage[TelemetryValuesResponse]`
**post** `/accounts/{account_id}/workers/observability/telemetry/values`
List unique values found in your events.
### Parameters
- `account_id: str`
- `datasets: Sequence[str]`
Leave this empty to use the default datasets
- `key: str`
- `timeframe: Timeframe`
- `from_: float`
- `to: float`
- `type: Literal["string", "boolean", "number"]`
- `"string"`
- `"boolean"`
- `"number"`
- `filters: Optional[Iterable[Filter]]`
Apply filters before listing values. Supports nested groups via kind: 'group'. Maximum nesting depth is 4.
- `class FilterUnionMember0: …`
- `filter_combination: Literal["and", "or", "AND", "OR"]`
- `"and"`
- `"or"`
- `"AND"`
- `"OR"`
- `filters: Iterable[FilterUnionMember0Filter]`
- `class FilterUnionMember0FilterUnionMember0: …`
- `filter_combination: Literal["and", "or", "AND", "OR"]`
- `"and"`
- `"or"`
- `"AND"`
- `"OR"`
- `filters: Iterable[object]`
- `kind: Literal["group"]`
- `"group"`
- `class FilterUnionMember0FilterWorkersObservabilityFilterLeaf: …`
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
- `key: str`
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
- `operation: Literal["includes", "not_includes", "starts_with", 25 more]`
Comparison operator. String operators: includes, not_includes, starts_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
- `"includes"`
- `"not_includes"`
- `"starts_with"`
- `"regex"`
- `"exists"`
- `"is_null"`
- `"in"`
- `"not_in"`
- `"eq"`
- `"neq"`
- `"gt"`
- `"gte"`
- `"lt"`
- `"lte"`
- `"="`
- `"!="`
- `">"`
- `">="`
- `"<"`
- `"<="`
- `"INCLUDES"`
- `"DOES_NOT_INCLUDE"`
- `"MATCH_REGEX"`
- `"EXISTS"`
- `"DOES_NOT_EXIST"`
- `"IN"`
- `"NOT_IN"`
- `"STARTS_WITH"`
- `type: Literal["string", "number", "boolean"]`
Data type of the filter field. Must match the actual type of the key being filtered.
- `"string"`
- `"number"`
- `"boolean"`
- `kind: Optional[Literal["filter"]]`
Discriminator for leaf filter nodes. Always 'filter' when present; may be omitted.
- `"filter"`
- `value: Optional[Union[str, float, bool]]`
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
- `str`
- `float`
- `bool`
- `kind: Literal["group"]`
- `"group"`
- `class FilterWorkersObservabilityFilterLeaf: …`
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
- `key: str`
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
- `operation: Literal["includes", "not_includes", "starts_with", 25 more]`
Comparison operator. String operators: includes, not_includes, starts_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
- `"includes"`
- `"not_includes"`
- `"starts_with"`
- `"regex"`
- `"exists"`
- `"is_null"`
- `"in"`
- `"not_in"`
- `"eq"`
- `"neq"`
- `"gt"`
- `"gte"`
- `"lt"`
- `"lte"`
- `"="`
- `"!="`
- `">"`
- `">="`
- `"<"`
- `"<="`
- `"INCLUDES"`
- `"DOES_NOT_INCLUDE"`
- `"MATCH_REGEX"`
- `"EXISTS"`
- `"DOES_NOT_EXIST"`
- `"IN"`
- `"NOT_IN"`
- `"STARTS_WITH"`
- `type: Literal["string", "number", "boolean"]`
Data type of the filter field. Must match the actual type of the key being filtered.
- `"string"`
- `"number"`
- `"boolean"`
- `kind: Optional[Literal["filter"]]`
Discriminator for leaf filter nodes. Always 'filter' when present; may be omitted.
- `"filter"`
- `value: Optional[Union[str, float, bool]]`
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
- `str`
- `float`
- `bool`
- `limit: Optional[float]`
- `needle: Optional[Needle]`
Full-text search expression to match events containing the specified text or pattern.
- `value: Union[str, float, bool]`
The text or pattern to search for.
- `str`
- `float`
- `bool`
- `is_regex: Optional[bool]`
When true, treats the value as a regular expression (RE2 syntax).
- `match_case: Optional[bool]`
When true, performs a case-sensitive search. Defaults to case-insensitive.
### Returns
- `class TelemetryValuesResponse: …`
- `dataset: str`
- `key: str`
- `type: Literal["string", "boolean", "number"]`
- `"string"`
- `"boolean"`
- `"number"`
- `value: Union[str, float, bool]`
- `str`
- `float`
- `bool`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted
api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted
)
page = client.workers.observability.telemetry.values(
account_id="account_id",
datasets=["string"],
key="key",
timeframe={
"from": 0,
"to": 0,
},
type="string",
)
page = page.result[0]
print(page.dataset)
```
#### Response
```json
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": [
{
"dataset": "dataset",
"key": "key",
"type": "string",
"value": "string"
}
],
"success": true
}
```
## Domain Types
### Telemetry Keys Response
- `class TelemetryKeysResponse: …`
- `key: str`
- `last_seen_at: float`
- `type: Literal["string", "boolean", "number"]`
- `"string"`
- `"boolean"`
- `"number"`
### Telemetry Query Response
- `class TelemetryQueryResponse: …`
Complete results of a query run. The populated fields depend on the requested view type (events, calculations, invocations, traces, or agents).
- `run: Run`
The query run metadata including the query definition, execution status, and timeframe.
- `id: str`
Unique identifier for this query run.
- `account_id: str`
Cloudflare account ID that owns this query run.
- `dry: bool`
Whether this was a dry run (results not persisted).
- `granularity: float`
Number of time-series buckets used for the query. Higher values produce more detailed series data.
- `query: RunQuery`
A saved query definition with its parameters, metadata, and ownership information.
- `id: str`
- `adhoc: bool`
If the query wasn't explcitly saved
- `created: str`
- `created_by: str`
- `description: Optional[str]`
- `name: str`
Query name
- `parameters: RunQueryParameters`
- `calculations: Optional[List[RunQueryParametersCalculation]]`
Create Calculations to compute as part of the query.
- `operator: Literal["uniq", "count", "max", 35 more]`
- `"uniq"`
- `"count"`
- `"max"`
- `"min"`
- `"sum"`
- `"avg"`
- `"median"`
- `"p001"`
- `"p01"`
- `"p05"`
- `"p10"`
- `"p25"`
- `"p75"`
- `"p90"`
- `"p95"`
- `"p99"`
- `"p999"`
- `"stddev"`
- `"variance"`
- `"COUNT_DISTINCT"`
- `"COUNT"`
- `"MAX"`
- `"MIN"`
- `"SUM"`
- `"AVG"`
- `"MEDIAN"`
- `"P001"`
- `"P01"`
- `"P05"`
- `"P10"`
- `"P25"`
- `"P75"`
- `"P90"`
- `"P95"`
- `"P99"`
- `"P999"`
- `"STDDEV"`
- `"VARIANCE"`
- `alias: Optional[str]`
- `key: Optional[str]`
- `key_type: Optional[Literal["string", "number", "boolean"]]`
- `"string"`
- `"number"`
- `"boolean"`
- `datasets: Optional[List[str]]`
Set the Datasets to query. Leave it empty to query all the datasets.
- `filter_combination: Optional[Literal["and", "or", "AND", "OR"]]`
Set a Flag to describe how to combine the filters on the query.
- `"and"`
- `"or"`
- `"AND"`
- `"OR"`
- `filters: Optional[List[RunQueryParametersFilter]]`
Configure the Filters to apply to the query. Supports nested groups via kind: 'group'.
- `class RunQueryParametersFilterUnionMember0: …`
- `filter_combination: Literal["and", "or", "AND", "OR"]`
- `"and"`
- `"or"`
- `"AND"`
- `"OR"`
- `filters: List[object]`
- `kind: Literal["group"]`
- `"group"`
- `class RunQueryParametersFilterWorkersObservabilityFilterLeaf: …`
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
- `key: str`
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
- `operation: Literal["includes", "not_includes", "starts_with", 25 more]`
Comparison operator. String operators: includes, not_includes, starts_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
- `"includes"`
- `"not_includes"`
- `"starts_with"`
- `"regex"`
- `"exists"`
- `"is_null"`
- `"in"`
- `"not_in"`
- `"eq"`
- `"neq"`
- `"gt"`
- `"gte"`
- `"lt"`
- `"lte"`
- `"="`
- `"!="`
- `">"`
- `">="`
- `"<"`
- `"<="`
- `"INCLUDES"`
- `"DOES_NOT_INCLUDE"`
- `"MATCH_REGEX"`
- `"EXISTS"`
- `"DOES_NOT_EXIST"`
- `"IN"`
- `"NOT_IN"`
- `"STARTS_WITH"`
- `type: Literal["string", "number", "boolean"]`
Data type of the filter field. Must match the actual type of the key being filtered.
- `"string"`
- `"number"`
- `"boolean"`
- `kind: Optional[Literal["filter"]]`
Discriminator for leaf filter nodes. Always 'filter' when present; may be omitted.
- `"filter"`
- `value: Optional[Union[str, float, bool, null]]`
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
- `str`
- `float`
- `bool`
- `group_bys: Optional[List[RunQueryParametersGroupBy]]`
Define how to group the results of the query.
- `type: Literal["string", "number", "boolean"]`
- `"string"`
- `"number"`
- `"boolean"`
- `value: str`
- `havings: Optional[List[RunQueryParametersHaving]]`
Configure the Having clauses that filter on calculations in the query result.
- `key: str`
- `operation: Literal["eq", "neq", "gt", 3 more]`
- `"eq"`
- `"neq"`
- `"gt"`
- `"gte"`
- `"lt"`
- `"lte"`
- `value: float`
- `limit: Optional[int]`
Set a limit on the number of results / records returned by the query
- `needle: Optional[RunQueryParametersNeedle]`
Define an expression to search using full-text search.
- `value: RunQueryParametersNeedleValue`
- `is_regex: Optional[bool]`
- `match_case: Optional[bool]`
- `order_by: Optional[RunQueryParametersOrderBy]`
Configure the order of the results returned by the query.
- `value: str`
Configure which Calculation to order the results by.
- `order: Optional[Literal["asc", "desc"]]`
Set the order of the results
- `"asc"`
- `"desc"`
- `updated: str`
- `updated_by: str`
- `status: Literal["STARTED", "COMPLETED"]`
Current execution status of the query run.
- `"STARTED"`
- `"COMPLETED"`
- `timeframe: RunTimeframe`
Time range for the query execution
- `from_: float`
Start timestamp for the query timeframe (Unix timestamp in milliseconds)
- `to: float`
End timestamp for the query timeframe (Unix timestamp in milliseconds)
- `user_id: str`
ID of the user who initiated the query run.
- `created: Optional[str]`
ISO-8601 timestamp when the query run was created.
- `statistics: Optional[RunStatistics]`
Query performance statistics from the database (does not include network latency).
- `bytes_read: float`
Number of uncompressed bytes read from the table.
- `elapsed: float`
Time in seconds for the query to run.
- `rows_read: float`
Number of rows scanned from the table.
- `abr_level: Optional[float]`
The level of Adaptive Bit Rate (ABR) sampling used for the query. If empty the ABR level is 1
- `updated: Optional[str]`
ISO-8601 timestamp when the query run was last updated.
- `statistics: Statistics`
Query performance statistics from the database. Includes execution time, rows scanned, and bytes read. Does not include network latency.
- `bytes_read: float`
Number of uncompressed bytes read from the table.
- `elapsed: float`
Time in seconds for the query to run.
- `rows_read: float`
Number of rows scanned from the table.
- `abr_level: Optional[float]`
The level of Adaptive Bit Rate (ABR) sampling used for the query. If empty the ABR level is 1
- `agents: Optional[List[Agent]]`
Durable Object agent summaries. Present when the query view is 'agents'. Each entry represents an agent with its event counts and status.
- `agent_class: str`
Class name of the Durable Object agent.
- `event_type_counts: Dict[str, float]`
Breakdown of event counts by event type.
- `first_event_ms: float`
Timestamp of the earliest event from this agent in the queried window (Unix epoch ms).
- `has_errors: bool`
Whether the agent emitted any error events in the queried window.
- `last_event_ms: float`
Timestamp of the most recent event from this agent (Unix epoch ms).
- `namespace: str`
Durable Object namespace the agent belongs to.
- `service: str`
Worker service name that hosts this agent.
- `total_events: float`
Total number of events emitted by this agent in the queried window.
- `calculations: Optional[List[Calculation]]`
Aggregated calculation results. Present when the query view is 'calculations'. Contains computed metrics (count, avg, p99, etc.) with optional group-by breakdowns and time-series data.
- `aggregates: List[CalculationAggregate]`
- `count: float`
- `interval: float`
- `sample_interval: float`
- `value: float`
- `groups: Optional[List[CalculationAggregateGroup]]`
- `key: str`
- `value: Union[str, float, bool]`
- `str`
- `float`
- `bool`
- `calculation: str`
- `series: List[CalculationSeries]`
- `data: List[CalculationSeriesData]`
- `count: float`
- `interval: float`
- `sample_interval: float`
- `value: float`
- `first_seen: Optional[str]`
- `groups: Optional[List[CalculationSeriesDataGroup]]`
- `key: str`
- `value: Union[str, float, bool]`
- `str`
- `float`
- `bool`
- `last_seen: Optional[str]`
- `time: str`
- `alias: Optional[str]`
- `compare: Optional[List[Compare]]`
Comparison calculation results from the previous time period. Present when the compare option is enabled. Same structure as calculations.
- `aggregates: List[CompareAggregate]`
- `count: float`
- `interval: float`
- `sample_interval: float`
- `value: float`
- `groups: Optional[List[CompareAggregateGroup]]`
- `key: str`
- `value: Union[str, float, bool]`
- `str`
- `float`
- `bool`
- `calculation: str`
- `series: List[CompareSeries]`
- `data: List[CompareSeriesData]`
- `count: float`
- `interval: float`
- `sample_interval: float`
- `value: float`
- `first_seen: Optional[str]`
- `groups: Optional[List[CompareSeriesDataGroup]]`
- `key: str`
- `value: Union[str, float, bool]`
- `str`
- `float`
- `bool`
- `last_seen: Optional[str]`
- `time: str`
- `alias: Optional[str]`
- `events: Optional[Events]`
Individual event results. Present when the query view is 'events'. Contains the matching log lines and their metadata.
- `count: Optional[float]`
Total number of events matching the query (may exceed the number returned due to limits).
- `events: Optional[List[EventsEvent]]`
List of individual telemetry events matching the query.
- `metadata: EventsEventMetadata`
Structured metadata extracted from the event. These fields are indexed and available for filtering and aggregation.
- `id: str`
Unique event ID. Use as the cursor value for offset-based pagination.
- `account: Optional[str]`
Cloudflare account identifier.
- `cloud_service: Optional[str]`
Cloudflare product that generated this event (e.g. workers, pages).
- `cold_start: Optional[int]`
Whether this was a cold start (1) or warm invocation (0).
- `cost: Optional[int]`
Estimated cost units for this invocation.
- `duration: Optional[int]`
Span duration in milliseconds.
- `end_time: Optional[int]`
Span end time as a Unix epoch in milliseconds.
- `error: Optional[str]`
Error message, present when the log represents an error.
- `error_template: Optional[str]`
Templatized version of the error message used for grouping similar errors.
- `fingerprint: Optional[str]`
Content-based fingerprint used to group similar events.
- `level: Optional[str]`
Log level (e.g. log, debug, info, warn, error).
- `message: Optional[str]`
Log message text.
- `message_template: Optional[str]`
Templatized version of the log message used for grouping similar messages.
- `metric_name: Optional[str]`
Metric name when the event represents a metric data point.
- `origin: Optional[str]`
Origin of the event (e.g. fetch, scheduled, queue).
- `parent_span_id: Optional[str]`
Span ID of the parent span in the trace hierarchy.
- `provider: Optional[str]`
Infrastructure provider identifier.
- `region: Optional[str]`
Cloudflare data center / region that handled the request.
- `request_id: Optional[str]`
Cloudflare request ID that ties all logs from a single invocation together.
- `service: Optional[str]`
Worker script name that produced this event.
- `span_id: Optional[str]`
Span ID for this individual unit of work within a trace.
- `span_name: Optional[str]`
Human-readable name for this span.
- `stack_id: Optional[str]`
Stack / deployment identifier.
- `start_time: Optional[int]`
Span start time as a Unix epoch in milliseconds.
- `status_code: Optional[int]`
HTTP response status code returned by the Worker.
- `trace_duration: Optional[int]`
Total duration of the entire trace in milliseconds.
- `trace_id: Optional[str]`
Distributed trace ID linking spans across services.
- `transaction_name: Optional[str]`
Logical transaction name for this request.
- `trigger: Optional[str]`
What triggered the invocation (e.g. GET /users, POST /orders, queue message).
- `type: Optional[str]`
Event type classifier (e.g. cf-worker-event, cf-worker-log).
- `url: Optional[str]`
Request URL that triggered the Worker invocation.
- `dataset: str`
The dataset this event belongs to (e.g. cloudflare-workers).
- `source: Union[str, object]`
Raw log payload. May be a string or a structured object depending on how the log was emitted.
- `str`
- `object`
- `timestamp: int`
Event timestamp as a Unix epoch in milliseconds.
- `containers: Optional[object]`
Cloudflare Containers event information that enriches your logs for identifying and debugging issues.
- `workers: Optional[EventsEventWorkers]`
Cloudflare Workers event information that enriches your logs for identifying and debugging issues.
- `class EventsEventWorkersUnionMember0: …`
- `event_type: Literal["fetch", "scheduled", "alarm", 8 more]`
- `"fetch"`
- `"scheduled"`
- `"alarm"`
- `"cron"`
- `"queue"`
- `"email"`
- `"tail"`
- `"rpc"`
- `"websocket"`
- `"workflow"`
- `"unknown"`
- `request_id: str`
- `script_name: str`
- `durable_object_id: Optional[str]`
- `entrypoint: Optional[str]`
- `event: Optional[Dict[str, object]]`
- `execution_model: Optional[Literal["durableObject", "stateless"]]`
- `"durableObject"`
- `"stateless"`
- `outcome: Optional[str]`
- `script_version: Optional[EventsEventWorkersUnionMember0ScriptVersion]`
- `id: Optional[str]`
- `message: Optional[str]`
- `tag: Optional[str]`
- `span_id: Optional[str]`
- `trace_id: Optional[str]`
- `truncated: Optional[bool]`
- `class EventsEventWorkersUnionMember1: …`
- `cpu_time_ms: float`
- `event_type: Literal["fetch", "scheduled", "alarm", 8 more]`
- `"fetch"`
- `"scheduled"`
- `"alarm"`
- `"cron"`
- `"queue"`
- `"email"`
- `"tail"`
- `"rpc"`
- `"websocket"`
- `"workflow"`
- `"unknown"`
- `outcome: str`
- `request_id: str`
- `script_name: str`
- `wall_time_ms: float`
- `diagnostics_channel_events: Optional[List[EventsEventWorkersUnionMember1DiagnosticsChannelEvent]]`
- `channel: str`
- `message: str`
- `timestamp: float`
- `dispatch_namespace: Optional[str]`
- `durable_object_id: Optional[str]`
- `entrypoint: Optional[str]`
- `event: Optional[Dict[str, object]]`
- `execution_model: Optional[Literal["durableObject", "stateless"]]`
- `"durableObject"`
- `"stateless"`
- `script_version: Optional[EventsEventWorkersUnionMember1ScriptVersion]`
- `id: Optional[str]`
- `message: Optional[str]`
- `tag: Optional[str]`
- `span_id: Optional[str]`
- `trace_id: Optional[str]`
- `truncated: Optional[bool]`
- `fields: Optional[List[EventsField]]`
List of fields discovered in the matched events. Useful for building dynamic UIs.
- `key: str`
Field name present in the matched events.
- `type: str`
Data type of the field (string, number, or boolean).
- `series: Optional[List[EventsSeries]]`
Time-series data for the matched events, bucketed by the query granularity.
- `data: List[EventsSeriesData]`
- `aggregates: EventsSeriesDataAggregates`
- `_count: int`
- `_interval: float`
- `_first_seen: Optional[str]`
- `_last_seen: Optional[str]`
- `bin: Optional[object]`
- `count: float`
- `interval: float`
- `sample_interval: float`
- `errors: Optional[float]`
- `groups: Optional[Dict[str, Union[str, float, bool]]]`
Groups in the query results.
- `str`
- `float`
- `bool`
- `time: str`
- `invocations: Optional[Dict[str, List[Invocation]]]`
Events grouped by invocation (request ID). Present when the query view is 'invocations'. Each key is a request ID mapping to all events from that invocation.
- `metadata: InvocationMetadata`
Structured metadata extracted from the event. These fields are indexed and available for filtering and aggregation.
- `id: str`
Unique event ID. Use as the cursor value for offset-based pagination.
- `account: Optional[str]`
Cloudflare account identifier.
- `cloud_service: Optional[str]`
Cloudflare product that generated this event (e.g. workers, pages).
- `cold_start: Optional[int]`
Whether this was a cold start (1) or warm invocation (0).
- `cost: Optional[int]`
Estimated cost units for this invocation.
- `duration: Optional[int]`
Span duration in milliseconds.
- `end_time: Optional[int]`
Span end time as a Unix epoch in milliseconds.
- `error: Optional[str]`
Error message, present when the log represents an error.
- `error_template: Optional[str]`
Templatized version of the error message used for grouping similar errors.
- `fingerprint: Optional[str]`
Content-based fingerprint used to group similar events.
- `level: Optional[str]`
Log level (e.g. log, debug, info, warn, error).
- `message: Optional[str]`
Log message text.
- `message_template: Optional[str]`
Templatized version of the log message used for grouping similar messages.
- `metric_name: Optional[str]`
Metric name when the event represents a metric data point.
- `origin: Optional[str]`
Origin of the event (e.g. fetch, scheduled, queue).
- `parent_span_id: Optional[str]`
Span ID of the parent span in the trace hierarchy.
- `provider: Optional[str]`
Infrastructure provider identifier.
- `region: Optional[str]`
Cloudflare data center / region that handled the request.
- `request_id: Optional[str]`
Cloudflare request ID that ties all logs from a single invocation together.
- `service: Optional[str]`
Worker script name that produced this event.
- `span_id: Optional[str]`
Span ID for this individual unit of work within a trace.
- `span_name: Optional[str]`
Human-readable name for this span.
- `stack_id: Optional[str]`
Stack / deployment identifier.
- `start_time: Optional[int]`
Span start time as a Unix epoch in milliseconds.
- `status_code: Optional[int]`
HTTP response status code returned by the Worker.
- `trace_duration: Optional[int]`
Total duration of the entire trace in milliseconds.
- `trace_id: Optional[str]`
Distributed trace ID linking spans across services.
- `transaction_name: Optional[str]`
Logical transaction name for this request.
- `trigger: Optional[str]`
What triggered the invocation (e.g. GET /users, POST /orders, queue message).
- `type: Optional[str]`
Event type classifier (e.g. cf-worker-event, cf-worker-log).
- `url: Optional[str]`
Request URL that triggered the Worker invocation.
- `dataset: str`
The dataset this event belongs to (e.g. cloudflare-workers).
- `source: Union[str, object]`
Raw log payload. May be a string or a structured object depending on how the log was emitted.
- `str`
- `object`
- `timestamp: int`
Event timestamp as a Unix epoch in milliseconds.
- `containers: Optional[object]`
Cloudflare Containers event information that enriches your logs for identifying and debugging issues.
- `workers: Optional[InvocationWorkers]`
Cloudflare Workers event information that enriches your logs for identifying and debugging issues.
- `class InvocationWorkersUnionMember0: …`
- `event_type: Literal["fetch", "scheduled", "alarm", 8 more]`
- `"fetch"`
- `"scheduled"`
- `"alarm"`
- `"cron"`
- `"queue"`
- `"email"`
- `"tail"`
- `"rpc"`
- `"websocket"`
- `"workflow"`
- `"unknown"`
- `request_id: str`
- `script_name: str`
- `durable_object_id: Optional[str]`
- `entrypoint: Optional[str]`
- `event: Optional[Dict[str, object]]`
- `execution_model: Optional[Literal["durableObject", "stateless"]]`
- `"durableObject"`
- `"stateless"`
- `outcome: Optional[str]`
- `script_version: Optional[InvocationWorkersUnionMember0ScriptVersion]`
- `id: Optional[str]`
- `message: Optional[str]`
- `tag: Optional[str]`
- `span_id: Optional[str]`
- `trace_id: Optional[str]`
- `truncated: Optional[bool]`
- `class InvocationWorkersUnionMember1: …`
- `cpu_time_ms: float`
- `event_type: Literal["fetch", "scheduled", "alarm", 8 more]`
- `"fetch"`
- `"scheduled"`
- `"alarm"`
- `"cron"`
- `"queue"`
- `"email"`
- `"tail"`
- `"rpc"`
- `"websocket"`
- `"workflow"`
- `"unknown"`
- `outcome: str`
- `request_id: str`
- `script_name: str`
- `wall_time_ms: float`
- `diagnostics_channel_events: Optional[List[InvocationWorkersUnionMember1DiagnosticsChannelEvent]]`
- `channel: str`
- `message: str`
- `timestamp: float`
- `dispatch_namespace: Optional[str]`
- `durable_object_id: Optional[str]`
- `entrypoint: Optional[str]`
- `event: Optional[Dict[str, object]]`
- `execution_model: Optional[Literal["durableObject", "stateless"]]`
- `"durableObject"`
- `"stateless"`
- `script_version: Optional[InvocationWorkersUnionMember1ScriptVersion]`
- `id: Optional[str]`
- `message: Optional[str]`
- `tag: Optional[str]`
- `span_id: Optional[str]`
- `trace_id: Optional[str]`
- `truncated: Optional[bool]`
- `traces: Optional[List[Trace]]`
Trace summaries matching the query. Present when the query view is 'traces'. Each entry represents a distributed trace with its spans, duration, and services involved.
- `root_span_name: str`
Name of the root span that initiated the trace.
- `root_transaction_name: str`
Logical transaction name for the root span.
- `service: List[str]`
List of Worker services involved in the trace.
- `spans: float`
Total number of spans in the trace.
- `trace_duration_ms: float`
Total duration of the trace in milliseconds.
- `trace_end_ms: float`
Trace end time as a Unix epoch in milliseconds.
- `trace_id: str`
Unique identifier for the distributed trace.
- `trace_start_ms: float`
Trace start time as a Unix epoch in milliseconds.
- `errors: Optional[List[str]]`
Error messages encountered during the trace, if any.
### Telemetry Values Response
- `class TelemetryValuesResponse: …`
- `dataset: str`
- `key: str`
- `type: Literal["string", "boolean", "number"]`
- `"string"`
- `"boolean"`
- `"number"`
- `value: Union[str, float, bool]`
- `str`
- `float`
- `bool`
# Destinations
## Get Destinations
`workers.observability.destinations.list(DestinationListParams**kwargs) -> SyncSinglePage[DestinationListResponse]`
**get** `/accounts/{account_id}/workers/observability/destinations`
List your Workers Observability Telemetry Destinations.
### Parameters
- `account_id: str`
- `order: Optional[Literal["asc", "desc"]]`
- `"asc"`
- `"desc"`
- `order_by: Optional[Literal["created", "updated"]]`
- `"created"`
- `"updated"`
- `page: Optional[float]`
- `per_page: Optional[float]`
### Returns
- `class DestinationListResponse: …`
- `configuration: Configuration`
- `destination_conf: str`
- `headers: Dict[str, str]`
- `job_status: ConfigurationJobStatus`
- `error_message: str`
- `last_complete: str`
- `last_error: str`
- `logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"]`
- `"opentelemetry-traces"`
- `"opentelemetry-logs"`
- `type: Literal["logpush"]`
- `"logpush"`
- `url: str`
- `enabled: bool`
- `name: str`
- `scripts: List[str]`
- `slug: str`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted
api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted
)
page = client.workers.observability.destinations.list(
account_id="account_id",
)
page = page.result[0]
print(page.configuration)
```
#### Response
```json
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": [
{
"configuration": {
"destination_conf": "destination_conf",
"headers": {
"foo": "string"
},
"jobStatus": {
"error_message": "error_message",
"last_complete": "last_complete",
"last_error": "last_error"
},
"logpushDataset": "opentelemetry-traces",
"type": "logpush",
"url": "url"
},
"enabled": true,
"name": "name",
"scripts": [
"string"
],
"slug": "slug"
}
],
"success": true
}
```
## Create Destination
`workers.observability.destinations.create(DestinationCreateParams**kwargs) -> DestinationCreateResponse`
**post** `/accounts/{account_id}/workers/observability/destinations`
Create a new Workers Observability Telemetry Destination.
### Parameters
- `account_id: str`
- `configuration: Configuration`
- `headers: Dict[str, str]`
- `logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"]`
- `"opentelemetry-traces"`
- `"opentelemetry-logs"`
- `type: Literal["logpush"]`
- `"logpush"`
- `url: str`
- `enabled: bool`
- `name: str`
- `skip_preflight_check: Optional[bool]`
### Returns
- `class DestinationCreateResponse: …`
- `configuration: Configuration`
- `destination_conf: str`
- `logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"]`
- `"opentelemetry-traces"`
- `"opentelemetry-logs"`
- `logpush_job: float`
- `type: Literal["logpush"]`
- `"logpush"`
- `url: str`
- `enabled: bool`
- `name: str`
- `scripts: List[str]`
- `slug: str`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted
api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted
)
destination = client.workers.observability.destinations.create(
account_id="account_id",
configuration={
"headers": {
"foo": "string"
},
"logpush_dataset": "opentelemetry-traces",
"type": "logpush",
"url": "url",
},
enabled=True,
name="name",
)
print(destination.configuration)
```
#### Response
```json
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Resource created"
}
],
"result": {
"configuration": {
"destination_conf": "destination_conf",
"logpushDataset": "opentelemetry-traces",
"logpushJob": 0,
"type": "logpush",
"url": "url"
},
"enabled": true,
"name": "name",
"scripts": [
"string"
],
"slug": "slug"
},
"success": true
}
```
## Update Destination
`workers.observability.destinations.update(strslug, DestinationUpdateParams**kwargs) -> DestinationUpdateResponse`
**patch** `/accounts/{account_id}/workers/observability/destinations/{slug}`
Update an existing Workers Observability Telemetry Destination.
### Parameters
- `account_id: str`
- `slug: str`
- `configuration: Configuration`
- `headers: Dict[str, str]`
- `type: Literal["logpush"]`
- `"logpush"`
- `url: str`
- `enabled: bool`
### Returns
- `class DestinationUpdateResponse: …`
- `configuration: Configuration`
- `destination_conf: str`
- `logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"]`
- `"opentelemetry-traces"`
- `"opentelemetry-logs"`
- `logpush_job: float`
- `type: Literal["logpush"]`
- `"logpush"`
- `url: str`
- `enabled: bool`
- `name: str`
- `scripts: List[str]`
- `slug: str`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted
api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted
)
destination = client.workers.observability.destinations.update(
slug="slug",
account_id="account_id",
configuration={
"headers": {
"foo": "string"
},
"type": "logpush",
"url": "url",
},
enabled=True,
)
print(destination.configuration)
```
#### Response
```json
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": {
"configuration": {
"destination_conf": "destination_conf",
"logpushDataset": "opentelemetry-traces",
"logpushJob": 0,
"type": "logpush",
"url": "url"
},
"enabled": true,
"name": "name",
"scripts": [
"string"
],
"slug": "slug"
},
"success": true
}
```
## Delete Destination
`workers.observability.destinations.delete(strslug, DestinationDeleteParams**kwargs) -> DestinationDeleteResponse`
**delete** `/accounts/{account_id}/workers/observability/destinations/{slug}`
Delete a Workers Observability Telemetry Destination.
### Parameters
- `account_id: str`
- `slug: str`
### Returns
- `class DestinationDeleteResponse: …`
- `configuration: Configuration`
- `destination_conf: str`
- `logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"]`
- `"opentelemetry-traces"`
- `"opentelemetry-logs"`
- `logpush_job: float`
- `type: Literal["logpush"]`
- `"logpush"`
- `url: str`
- `enabled: bool`
- `name: str`
- `scripts: List[str]`
- `slug: str`
### Example
```python
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted
api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted
)
destination = client.workers.observability.destinations.delete(
slug="slug",
account_id="account_id",
)
print(destination.configuration)
```
#### Response
```json
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"success": true,
"result": {
"configuration": {
"destination_conf": "destination_conf",
"logpushDataset": "opentelemetry-traces",
"logpushJob": 0,
"type": "logpush",
"url": "url"
},
"enabled": true,
"name": "name",
"scripts": [
"string"
],
"slug": "slug"
}
}
```
## Domain Types
### Destination List Response
- `class DestinationListResponse: …`
- `configuration: Configuration`
- `destination_conf: str`
- `headers: Dict[str, str]`
- `job_status: ConfigurationJobStatus`
- `error_message: str`
- `last_complete: str`
- `last_error: str`
- `logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"]`
- `"opentelemetry-traces"`
- `"opentelemetry-logs"`
- `type: Literal["logpush"]`
- `"logpush"`
- `url: str`
- `enabled: bool`
- `name: str`
- `scripts: List[str]`
- `slug: str`
### Destination Create Response
- `class DestinationCreateResponse: …`
- `configuration: Configuration`
- `destination_conf: str`
- `logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"]`
- `"opentelemetry-traces"`
- `"opentelemetry-logs"`
- `logpush_job: float`
- `type: Literal["logpush"]`
- `"logpush"`
- `url: str`
- `enabled: bool`
- `name: str`
- `scripts: List[str]`
- `slug: str`
### Destination Update Response
- `class DestinationUpdateResponse: …`
- `configuration: Configuration`
- `destination_conf: str`
- `logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"]`
- `"opentelemetry-traces"`
- `"opentelemetry-logs"`
- `logpush_job: float`
- `type: Literal["logpush"]`
- `"logpush"`
- `url: str`
- `enabled: bool`
- `name: str`
- `scripts: List[str]`
- `slug: str`
### Destination Delete Response
- `class DestinationDeleteResponse: …`
- `configuration: Configuration`
- `destination_conf: str`
- `logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"]`
- `"opentelemetry-traces"`
- `"opentelemetry-logs"`
- `logpush_job: float`
- `type: Literal["logpush"]`
- `"logpush"`
- `url: str`
- `enabled: bool`
- `name: str`
- `scripts: List[str]`
- `slug: str`