# Workers ## Domain Types ### Migration Step - `MigrationStep` - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` ### Single Step Migration - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` ### Worker Metadata - `WorkerMetadata` JSON-encoded metadata about the uploaded parts and Worker configuration. - `body_part?: string` 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?: string` 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 `client.workers.beta.workers.list(WorkerListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/workers/workers` List all Workers for an account. ### Parameters - `params: WorkerListParams` - `account_id: string` Path param: Identifier. - `order?: "asc" | "desc"` Query param: Sort direction. - `"asc"` - `"desc"` - `order_by?: "deployed_on" | "updated_on" | "created_on" | "name"` Query param: Property to sort results by. - `"deployed_on"` - `"updated_on"` - `"created_on"` - `"name"` - `page?: number` Query param: Current page. - `per_page?: number` Query param: Items per-page. ### Returns - `Worker` - `id: string` Immutable ID of the Worker. - `created_on: string` When the Worker was created. - `logpush: boolean` Whether logpush is enabled for the Worker. - `name: string` Name of the Worker. - `observability: Observability` Observability settings for the Worker. - `enabled?: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%). - `logs?: Logs` Log settings for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `enabled?: boolean` Whether logs are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). - `invocation_logs?: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `references: References` Other resources that reference the Worker and depend on it existing. - `dispatch_namespace_outbounds: Array` Other Workers that reference the Worker as an outbound for a dispatch namespace. - `namespace_id: string` ID of the dispatch namespace. - `namespace_name: string` Name of the dispatch namespace. - `worker_id: string` ID of the Worker using the dispatch namespace. - `worker_name: string` Name of the Worker using the dispatch namespace. - `domains: Array` Custom domains connected to the Worker. - `id: string` ID of the custom domain. - `certificate_id: string` ID of the TLS certificate issued for the custom domain. - `hostname: string` Full hostname of the custom domain, including the zone name. - `zone_id: string` ID of the zone. - `zone_name: string` Name of the zone. - `durable_objects: Array` Other Workers that reference Durable Object classes implemented by the Worker. - `namespace_id: string` ID of the Durable Object namespace being used. - `namespace_name: string` Name of the Durable Object namespace being used. - `worker_id: string` ID of the Worker using the Durable Object implementation. - `worker_name: string` Name of the Worker using the Durable Object implementation. - `queues: Array` Queues that send messages to the Worker. - `queue_consumer_id: string` ID of the queue consumer configuration. - `queue_id: string` ID of the queue. - `queue_name: string` Name of the queue. - `workers: Array` Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/). - `id: string` ID of the referencing Worker. - `name: string` Name of the referencing Worker. - `subdomain: Subdomain` Subdomain settings for the Worker. - `enabled?: boolean` Whether the *.workers.dev subdomain is enabled for the Worker. - `previews_enabled?: boolean` Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker. - `tags: Array` Tags associated with the Worker. - `tail_consumers: Array` Other Workers that should consume logs from the Worker. - `name: string` Name of the consumer Worker. - `updated_on: string` When the Worker was most recently updated. - `deployed_on?: string | null` When the Worker's most recent deployment was created. `null` if the Worker has never been deployed. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const worker of client.workers.beta.workers.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', })) { console.log(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, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Get Worker `client.workers.beta.workers.get(stringworkerId, WorkerGetParamsparams, RequestOptionsoptions?): Worker` **get** `/accounts/{account_id}/workers/workers/{worker_id}` Get details about a specific Worker. ### Parameters - `workerId: string` Identifier for the Worker, which can be ID or name. - `params: WorkerGetParams` - `account_id: string` Identifier. ### Returns - `Worker` - `id: string` Immutable ID of the Worker. - `created_on: string` When the Worker was created. - `logpush: boolean` Whether logpush is enabled for the Worker. - `name: string` Name of the Worker. - `observability: Observability` Observability settings for the Worker. - `enabled?: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%). - `logs?: Logs` Log settings for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `enabled?: boolean` Whether logs are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). - `invocation_logs?: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `references: References` Other resources that reference the Worker and depend on it existing. - `dispatch_namespace_outbounds: Array` Other Workers that reference the Worker as an outbound for a dispatch namespace. - `namespace_id: string` ID of the dispatch namespace. - `namespace_name: string` Name of the dispatch namespace. - `worker_id: string` ID of the Worker using the dispatch namespace. - `worker_name: string` Name of the Worker using the dispatch namespace. - `domains: Array` Custom domains connected to the Worker. - `id: string` ID of the custom domain. - `certificate_id: string` ID of the TLS certificate issued for the custom domain. - `hostname: string` Full hostname of the custom domain, including the zone name. - `zone_id: string` ID of the zone. - `zone_name: string` Name of the zone. - `durable_objects: Array` Other Workers that reference Durable Object classes implemented by the Worker. - `namespace_id: string` ID of the Durable Object namespace being used. - `namespace_name: string` Name of the Durable Object namespace being used. - `worker_id: string` ID of the Worker using the Durable Object implementation. - `worker_name: string` Name of the Worker using the Durable Object implementation. - `queues: Array` Queues that send messages to the Worker. - `queue_consumer_id: string` ID of the queue consumer configuration. - `queue_id: string` ID of the queue. - `queue_name: string` Name of the queue. - `workers: Array` Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/). - `id: string` ID of the referencing Worker. - `name: string` Name of the referencing Worker. - `subdomain: Subdomain` Subdomain settings for the Worker. - `enabled?: boolean` Whether the *.workers.dev subdomain is enabled for the Worker. - `previews_enabled?: boolean` Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker. - `tags: Array` Tags associated with the Worker. - `tail_consumers: Array` Other Workers that should consume logs from the Worker. - `name: string` Name of the consumer Worker. - `updated_on: string` When the Worker was most recently updated. - `deployed_on?: string | null` When the Worker's most recent deployment was created. `null` if the Worker has never been deployed. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const worker = await client.workers.beta.workers.get('worker_id', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 `client.workers.beta.workers.create(WorkerCreateParamsparams, RequestOptionsoptions?): Worker` **post** `/accounts/{account_id}/workers/workers` Create a new Worker. ### Parameters - `params: WorkerCreateParams` - `account_id: string` Path param: Identifier. - `name: string` Body param: Name of the Worker. - `logpush?: boolean` Body param: Whether logpush is enabled for the Worker. - `observability?: Observability` Body param: Observability settings for the Worker. - `enabled?: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%). - `logs?: Logs` Log settings for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `enabled?: boolean` Whether logs are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). - `invocation_logs?: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `subdomain?: Subdomain` Body param: Subdomain settings for the Worker. - `enabled?: boolean` Whether the *.workers.dev subdomain is enabled for the Worker. - `previews_enabled?: boolean` Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker. - `tags?: Array` Body param: Tags associated with the Worker. - `tail_consumers?: Array` Body param: Other Workers that should consume logs from the Worker. - `name: string` Name of the consumer Worker. ### Returns - `Worker` - `id: string` Immutable ID of the Worker. - `created_on: string` When the Worker was created. - `logpush: boolean` Whether logpush is enabled for the Worker. - `name: string` Name of the Worker. - `observability: Observability` Observability settings for the Worker. - `enabled?: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%). - `logs?: Logs` Log settings for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `enabled?: boolean` Whether logs are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). - `invocation_logs?: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `references: References` Other resources that reference the Worker and depend on it existing. - `dispatch_namespace_outbounds: Array` Other Workers that reference the Worker as an outbound for a dispatch namespace. - `namespace_id: string` ID of the dispatch namespace. - `namespace_name: string` Name of the dispatch namespace. - `worker_id: string` ID of the Worker using the dispatch namespace. - `worker_name: string` Name of the Worker using the dispatch namespace. - `domains: Array` Custom domains connected to the Worker. - `id: string` ID of the custom domain. - `certificate_id: string` ID of the TLS certificate issued for the custom domain. - `hostname: string` Full hostname of the custom domain, including the zone name. - `zone_id: string` ID of the zone. - `zone_name: string` Name of the zone. - `durable_objects: Array` Other Workers that reference Durable Object classes implemented by the Worker. - `namespace_id: string` ID of the Durable Object namespace being used. - `namespace_name: string` Name of the Durable Object namespace being used. - `worker_id: string` ID of the Worker using the Durable Object implementation. - `worker_name: string` Name of the Worker using the Durable Object implementation. - `queues: Array` Queues that send messages to the Worker. - `queue_consumer_id: string` ID of the queue consumer configuration. - `queue_id: string` ID of the queue. - `queue_name: string` Name of the queue. - `workers: Array` Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/). - `id: string` ID of the referencing Worker. - `name: string` Name of the referencing Worker. - `subdomain: Subdomain` Subdomain settings for the Worker. - `enabled?: boolean` Whether the *.workers.dev subdomain is enabled for the Worker. - `previews_enabled?: boolean` Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker. - `tags: Array` Tags associated with the Worker. - `tail_consumers: Array` Other Workers that should consume logs from the Worker. - `name: string` Name of the consumer Worker. - `updated_on: string` When the Worker was most recently updated. - `deployed_on?: string | null` When the Worker's most recent deployment was created. `null` if the Worker has never been deployed. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const worker = await client.workers.beta.workers.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', name: 'my-worker', }); console.log(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 `client.workers.beta.workers.update(stringworkerId, WorkerUpdateParamsparams, RequestOptionsoptions?): 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 - `workerId: string` Identifier for the Worker, which can be ID or name. - `params: WorkerUpdateParams` - `account_id: string` Path param: Identifier. - `name: string` Body param: Name of the Worker. - `logpush?: boolean` Body param: Whether logpush is enabled for the Worker. - `observability?: Observability` Body param: Observability settings for the Worker. - `enabled?: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%). - `logs?: Logs` Log settings for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `enabled?: boolean` Whether logs are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). - `invocation_logs?: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `subdomain?: Subdomain` Body param: Subdomain settings for the Worker. - `enabled?: boolean` Whether the *.workers.dev subdomain is enabled for the Worker. - `previews_enabled?: boolean` Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker. - `tags?: Array` Body param: Tags associated with the Worker. - `tail_consumers?: Array` Body param: Other Workers that should consume logs from the Worker. - `name: string` Name of the consumer Worker. ### Returns - `Worker` - `id: string` Immutable ID of the Worker. - `created_on: string` When the Worker was created. - `logpush: boolean` Whether logpush is enabled for the Worker. - `name: string` Name of the Worker. - `observability: Observability` Observability settings for the Worker. - `enabled?: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%). - `logs?: Logs` Log settings for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `enabled?: boolean` Whether logs are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). - `invocation_logs?: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `references: References` Other resources that reference the Worker and depend on it existing. - `dispatch_namespace_outbounds: Array` Other Workers that reference the Worker as an outbound for a dispatch namespace. - `namespace_id: string` ID of the dispatch namespace. - `namespace_name: string` Name of the dispatch namespace. - `worker_id: string` ID of the Worker using the dispatch namespace. - `worker_name: string` Name of the Worker using the dispatch namespace. - `domains: Array` Custom domains connected to the Worker. - `id: string` ID of the custom domain. - `certificate_id: string` ID of the TLS certificate issued for the custom domain. - `hostname: string` Full hostname of the custom domain, including the zone name. - `zone_id: string` ID of the zone. - `zone_name: string` Name of the zone. - `durable_objects: Array` Other Workers that reference Durable Object classes implemented by the Worker. - `namespace_id: string` ID of the Durable Object namespace being used. - `namespace_name: string` Name of the Durable Object namespace being used. - `worker_id: string` ID of the Worker using the Durable Object implementation. - `worker_name: string` Name of the Worker using the Durable Object implementation. - `queues: Array` Queues that send messages to the Worker. - `queue_consumer_id: string` ID of the queue consumer configuration. - `queue_id: string` ID of the queue. - `queue_name: string` Name of the queue. - `workers: Array` Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/). - `id: string` ID of the referencing Worker. - `name: string` Name of the referencing Worker. - `subdomain: Subdomain` Subdomain settings for the Worker. - `enabled?: boolean` Whether the *.workers.dev subdomain is enabled for the Worker. - `previews_enabled?: boolean` Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker. - `tags: Array` Tags associated with the Worker. - `tail_consumers: Array` Other Workers that should consume logs from the Worker. - `name: string` Name of the consumer Worker. - `updated_on: string` When the Worker was most recently updated. - `deployed_on?: string | null` When the Worker's most recent deployment was created. `null` if the Worker has never been deployed. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const worker = await client.workers.beta.workers.update('worker_id', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', name: 'my-worker', }); console.log(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 `client.workers.beta.workers.edit(stringworkerId, WorkerEditParamsparams, RequestOptionsoptions?): 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 - `workerId: string` Identifier for the Worker, which can be ID or name. - `params: WorkerEditParams` - `account_id: string` Path param: Identifier. - `logpush: boolean` Body param: Whether logpush is enabled for the Worker. - `name: string` Body param: Name of the Worker. - `observability: Observability` Body param: Observability settings for the Worker. - `enabled?: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%). - `logs?: Logs` Log settings for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `enabled?: boolean` Whether logs are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). - `invocation_logs?: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `subdomain: Subdomain` Body param: Subdomain settings for the Worker. - `enabled?: boolean` Whether the *.workers.dev subdomain is enabled for the Worker. - `previews_enabled?: boolean` Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker. - `tags: Array` Body param: Tags associated with the Worker. - `tail_consumers: Array` Body param: Other Workers that should consume logs from the Worker. - `name: string` Name of the consumer Worker. ### Returns - `Worker` - `id: string` Immutable ID of the Worker. - `created_on: string` When the Worker was created. - `logpush: boolean` Whether logpush is enabled for the Worker. - `name: string` Name of the Worker. - `observability: Observability` Observability settings for the Worker. - `enabled?: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%). - `logs?: Logs` Log settings for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `enabled?: boolean` Whether logs are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). - `invocation_logs?: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `references: References` Other resources that reference the Worker and depend on it existing. - `dispatch_namespace_outbounds: Array` Other Workers that reference the Worker as an outbound for a dispatch namespace. - `namespace_id: string` ID of the dispatch namespace. - `namespace_name: string` Name of the dispatch namespace. - `worker_id: string` ID of the Worker using the dispatch namespace. - `worker_name: string` Name of the Worker using the dispatch namespace. - `domains: Array` Custom domains connected to the Worker. - `id: string` ID of the custom domain. - `certificate_id: string` ID of the TLS certificate issued for the custom domain. - `hostname: string` Full hostname of the custom domain, including the zone name. - `zone_id: string` ID of the zone. - `zone_name: string` Name of the zone. - `durable_objects: Array` Other Workers that reference Durable Object classes implemented by the Worker. - `namespace_id: string` ID of the Durable Object namespace being used. - `namespace_name: string` Name of the Durable Object namespace being used. - `worker_id: string` ID of the Worker using the Durable Object implementation. - `worker_name: string` Name of the Worker using the Durable Object implementation. - `queues: Array` Queues that send messages to the Worker. - `queue_consumer_id: string` ID of the queue consumer configuration. - `queue_id: string` ID of the queue. - `queue_name: string` Name of the queue. - `workers: Array` Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/). - `id: string` ID of the referencing Worker. - `name: string` Name of the referencing Worker. - `subdomain: Subdomain` Subdomain settings for the Worker. - `enabled?: boolean` Whether the *.workers.dev subdomain is enabled for the Worker. - `previews_enabled?: boolean` Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker. - `tags: Array` Tags associated with the Worker. - `tail_consumers: Array` Other Workers that should consume logs from the Worker. - `name: string` Name of the consumer Worker. - `updated_on: string` When the Worker was most recently updated. - `deployed_on?: string | null` When the Worker's most recent deployment was created. `null` if the Worker has never been deployed. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const worker = await client.workers.beta.workers.edit('worker_id', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', logpush: true, name: 'my-worker', observability: {}, subdomain: {}, tags: ['my-team', 'my-public-api'], tail_consumers: [{ name: 'my-tail-consumer' }], }); console.log(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 `client.workers.beta.workers.delete(stringworkerId, WorkerDeleteParamsparams, RequestOptionsoptions?): WorkerDeleteResponse` **delete** `/accounts/{account_id}/workers/workers/{worker_id}` Delete a Worker and all its associated resources (versions, deployments, etc.). ### Parameters - `workerId: string` Identifier for the Worker, which can be ID or name. - `params: WorkerDeleteParams` - `account_id: string` Identifier. ### Returns - `WorkerDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const worker = await client.workers.beta.workers.delete('worker_id', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 - `Worker` - `id: string` Immutable ID of the Worker. - `created_on: string` When the Worker was created. - `logpush: boolean` Whether logpush is enabled for the Worker. - `name: string` Name of the Worker. - `observability: Observability` Observability settings for the Worker. - `enabled?: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%). - `logs?: Logs` Log settings for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `enabled?: boolean` Whether logs are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). - `invocation_logs?: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `references: References` Other resources that reference the Worker and depend on it existing. - `dispatch_namespace_outbounds: Array` Other Workers that reference the Worker as an outbound for a dispatch namespace. - `namespace_id: string` ID of the dispatch namespace. - `namespace_name: string` Name of the dispatch namespace. - `worker_id: string` ID of the Worker using the dispatch namespace. - `worker_name: string` Name of the Worker using the dispatch namespace. - `domains: Array` Custom domains connected to the Worker. - `id: string` ID of the custom domain. - `certificate_id: string` ID of the TLS certificate issued for the custom domain. - `hostname: string` Full hostname of the custom domain, including the zone name. - `zone_id: string` ID of the zone. - `zone_name: string` Name of the zone. - `durable_objects: Array` Other Workers that reference Durable Object classes implemented by the Worker. - `namespace_id: string` ID of the Durable Object namespace being used. - `namespace_name: string` Name of the Durable Object namespace being used. - `worker_id: string` ID of the Worker using the Durable Object implementation. - `worker_name: string` Name of the Worker using the Durable Object implementation. - `queues: Array` Queues that send messages to the Worker. - `queue_consumer_id: string` ID of the queue consumer configuration. - `queue_id: string` ID of the queue. - `queue_name: string` Name of the queue. - `workers: Array` Other Workers that reference the Worker using [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/). - `id: string` ID of the referencing Worker. - `name: string` Name of the referencing Worker. - `subdomain: Subdomain` Subdomain settings for the Worker. - `enabled?: boolean` Whether the *.workers.dev subdomain is enabled for the Worker. - `previews_enabled?: boolean` Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker. - `tags: Array` Tags associated with the Worker. - `tail_consumers: Array` Other Workers that should consume logs from the Worker. - `name: string` Name of the consumer Worker. - `updated_on: string` When the Worker was most recently updated. - `deployed_on?: string | null` When the Worker's most recent deployment was created. `null` if the Worker has never been deployed. ### Worker Delete Response - `WorkerDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` # Versions ## List Versions `client.workers.beta.workers.versions.list(stringworkerId, VersionListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/workers/workers/{worker_id}/versions` List all versions for a Worker. ### Parameters - `workerId: string` Identifier for the Worker, which can be ID or name. - `params: VersionListParams` - `account_id: string` Path param: Identifier. - `page?: number` Query param: Current page. - `per_page?: number` Query param: Items per-page. ### Returns - `Version` - `id: string` Version identifier. - `created_on: string` When the version was created. - `number: number` The integer version number, starting from one. - `urls: Array` 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?: Annotations` Metadata about the version. - `"workers/message"?: string` Human-readable message about the version. - `"workers/tag"?: string` User-provided identifier for the version. - `"workers/triggered_by"?: string` Operation that triggered the creation of the version. - `assets?: 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?: Config` Configuration for assets within a Worker. - `html_handling?: "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?: "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?: Array | boolean` 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. - `Array` - `boolean` - `jwt?: string` Token provided upon successful upload of all files from a registered manifest. - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: Limits` Resource limits enforced at runtime. - `cpu_ms: number` CPU time limit in milliseconds. - `main_module?: string` The name of the main module in the `modules` array (e.g. the name of the module that exports a `fetch` handler). - `migrations?: SingleStepMigration | WorkersMultipleStepMigrations` Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed. - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `WorkersMultipleStepMigrations` - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `steps?: Array` Migrations to apply in order. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `modules?: Array` 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: string` The base64-encoded module content. - `content_type: string` The content type of the module. - `name: string` The name of the module. - `placement?: Mode | Region | Hostname | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `Mode` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `Region` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host and port for targeted placement. - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `source?: string` The client used to create the version. - `startup_time_ms?: number` Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time). - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the version. - `"standard"` - `"bundled"` - `"unbound"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const version of client.workers.beta.workers.versions.list('worker_id', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', })) { console.log(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": [ "string" ] }, "jwt": "jwt" }, "bindings": [ { "name": "MY_ENV_VAR", "text": "my_data", "type": "plain_text" } ], "compatibility_date": "2021-01-01", "compatibility_flags": [ "nodejs_compat" ], "limits": { "cpu_ms": 50 }, "main_module": "index.js", "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 `client.workers.beta.workers.versions.get(stringworkerId, stringversionId, VersionGetParamsparams, RequestOptionsoptions?): Version` **get** `/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}` Get details about a specific version. ### Parameters - `workerId: string` Identifier for the Worker, which can be ID or name. - `versionId: string` 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. - `params: VersionGetParams` - `account_id: string` Path param: Identifier. - `include?: "modules"` Query param: 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 - `Version` - `id: string` Version identifier. - `created_on: string` When the version was created. - `number: number` The integer version number, starting from one. - `urls: Array` 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?: Annotations` Metadata about the version. - `"workers/message"?: string` Human-readable message about the version. - `"workers/tag"?: string` User-provided identifier for the version. - `"workers/triggered_by"?: string` Operation that triggered the creation of the version. - `assets?: 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?: Config` Configuration for assets within a Worker. - `html_handling?: "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?: "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?: Array | boolean` 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. - `Array` - `boolean` - `jwt?: string` Token provided upon successful upload of all files from a registered manifest. - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: Limits` Resource limits enforced at runtime. - `cpu_ms: number` CPU time limit in milliseconds. - `main_module?: string` The name of the main module in the `modules` array (e.g. the name of the module that exports a `fetch` handler). - `migrations?: SingleStepMigration | WorkersMultipleStepMigrations` Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed. - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `WorkersMultipleStepMigrations` - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `steps?: Array` Migrations to apply in order. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `modules?: Array` 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: string` The base64-encoded module content. - `content_type: string` The content type of the module. - `name: string` The name of the module. - `placement?: Mode | Region | Hostname | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `Mode` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `Region` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host and port for targeted placement. - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `source?: string` The client used to create the version. - `startup_time_ms?: number` Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time). - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the version. - `"standard"` - `"bundled"` - `"unbound"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const version = await client.workers.beta.workers.versions.get('worker_id', 'version_id', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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": [ "string" ] }, "jwt": "jwt" }, "bindings": [ { "name": "MY_ENV_VAR", "text": "my_data", "type": "plain_text" } ], "compatibility_date": "2021-01-01", "compatibility_flags": [ "nodejs_compat" ], "limits": { "cpu_ms": 50 }, "main_module": "index.js", "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 `client.workers.beta.workers.versions.create(stringworkerId, VersionCreateParamsparams, RequestOptionsoptions?): Version` **post** `/accounts/{account_id}/workers/workers/{worker_id}/versions` Create a new version. ### Parameters - `workerId: string` Identifier for the Worker, which can be ID or name. - `params: VersionCreateParams` - `account_id: string` Path param: Identifier. - `deploy?: boolean` Query param: If true, a deployment will be created that sends 100% of traffic to the new version. - `annotations?: Annotations` Body param: Metadata about the version. - `"workers/message"?: string` Human-readable message about the version. - `"workers/tag"?: string` User-provided identifier for the version. - `"workers/triggered_by"?: string` Operation that triggered the creation of the version. - `assets?: Assets` Body param: 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?: Config` Configuration for assets within a Worker. - `html_handling?: "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?: "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?: Array | boolean` 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. - `Array` - `boolean` - `jwt?: string` Token provided upon successful upload of all files from a registered manifest. - `bindings?: Array` Body param: 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `compatibility_date?: string` Body param: Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` Body param: 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?: Limits` Body param: Resource limits enforced at runtime. - `cpu_ms: number` CPU time limit in milliseconds. - `main_module?: string` Body param: The name of the main module in the `modules` array (e.g. the name of the module that exports a `fetch` handler). - `migrations?: SingleStepMigration | WorkersMultipleStepMigrations` Body param: Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed. - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `WorkersMultipleStepMigrations` - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `steps?: Array` Migrations to apply in order. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `modules?: Array` Body param: 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: string` The base64-encoded module content. - `content_type: string` The content type of the module. - `name: string` The name of the module. - `placement?: Mode | Region | Hostname | 5 more` Body param: Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `Mode` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `Region` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host and port for targeted placement. - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `usage_model?: "standard" | "bundled" | "unbound"` Body param: Usage model for the version. - `"standard"` - `"bundled"` - `"unbound"` ### Returns - `Version` - `id: string` Version identifier. - `created_on: string` When the version was created. - `number: number` The integer version number, starting from one. - `urls: Array` 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?: Annotations` Metadata about the version. - `"workers/message"?: string` Human-readable message about the version. - `"workers/tag"?: string` User-provided identifier for the version. - `"workers/triggered_by"?: string` Operation that triggered the creation of the version. - `assets?: 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?: Config` Configuration for assets within a Worker. - `html_handling?: "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?: "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?: Array | boolean` 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. - `Array` - `boolean` - `jwt?: string` Token provided upon successful upload of all files from a registered manifest. - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: Limits` Resource limits enforced at runtime. - `cpu_ms: number` CPU time limit in milliseconds. - `main_module?: string` The name of the main module in the `modules` array (e.g. the name of the module that exports a `fetch` handler). - `migrations?: SingleStepMigration | WorkersMultipleStepMigrations` Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed. - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `WorkersMultipleStepMigrations` - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `steps?: Array` Migrations to apply in order. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `modules?: Array` 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: string` The base64-encoded module content. - `content_type: string` The content type of the module. - `name: string` The name of the module. - `placement?: Mode | Region | Hostname | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `Mode` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `Region` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host and port for targeted placement. - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `source?: string` The client used to create the version. - `startup_time_ms?: number` Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time). - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the version. - `"standard"` - `"bundled"` - `"unbound"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const version = await client.workers.beta.workers.versions.create('worker_id', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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": [ "string" ] }, "jwt": "jwt" }, "bindings": [ { "name": "MY_ENV_VAR", "text": "my_data", "type": "plain_text" } ], "compatibility_date": "2021-01-01", "compatibility_flags": [ "nodejs_compat" ], "limits": { "cpu_ms": 50 }, "main_module": "index.js", "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 `client.workers.beta.workers.versions.delete(stringworkerId, stringversionId, VersionDeleteParamsparams, RequestOptionsoptions?): VersionDeleteResponse` **delete** `/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}` Delete a version. ### Parameters - `workerId: string` Identifier for the Worker, which can be ID or name. - `versionId: string` 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. - `params: VersionDeleteParams` - `account_id: string` Identifier. ### Returns - `VersionDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const version = await client.workers.beta.workers.versions.delete('worker_id', 'version_id', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 - `Version` - `id: string` Version identifier. - `created_on: string` When the version was created. - `number: number` The integer version number, starting from one. - `urls: Array` 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?: Annotations` Metadata about the version. - `"workers/message"?: string` Human-readable message about the version. - `"workers/tag"?: string` User-provided identifier for the version. - `"workers/triggered_by"?: string` Operation that triggered the creation of the version. - `assets?: 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?: Config` Configuration for assets within a Worker. - `html_handling?: "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?: "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?: Array | boolean` 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. - `Array` - `boolean` - `jwt?: string` Token provided upon successful upload of all files from a registered manifest. - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: Limits` Resource limits enforced at runtime. - `cpu_ms: number` CPU time limit in milliseconds. - `main_module?: string` The name of the main module in the `modules` array (e.g. the name of the module that exports a `fetch` handler). - `migrations?: SingleStepMigration | WorkersMultipleStepMigrations` Migrations for Durable Objects associated with the version. Migrations are applied when the version is deployed. - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `WorkersMultipleStepMigrations` - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `steps?: Array` Migrations to apply in order. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `modules?: Array` 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: string` The base64-encoded module content. - `content_type: string` The content type of the module. - `name: string` The name of the module. - `placement?: Mode | Region | Hostname | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `Mode` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `Region` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host and port for targeted placement. - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `source?: string` The client used to create the version. - `startup_time_ms?: number` Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time). - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the version. - `"standard"` - `"bundled"` - `"unbound"` ### Version Delete Response - `VersionDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` # Routes ## List Routes `client.workers.routes.list(RouteListParamsparams, RequestOptionsoptions?): SinglePage` **get** `/zones/{zone_id}/workers/routes` Returns routes for a zone. ### Parameters - `params: RouteListParams` - `zone_id: string` Identifier. ### Returns - `RouteListResponse` - `id: string` Identifier. - `pattern: string` Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Name of the script to run if the route matches. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const routeListResponse of client.workers.routes.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', })) { console.log(routeListResponse.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 `client.workers.routes.get(stringrouteId, RouteGetParamsparams, RequestOptionsoptions?): RouteGetResponse` **get** `/zones/{zone_id}/workers/routes/{route_id}` Returns information about a route, including URL pattern and Worker. ### Parameters - `routeId: string` Identifier. - `params: RouteGetParams` - `zone_id: string` Identifier. ### Returns - `RouteGetResponse` - `id: string` Identifier. - `pattern: string` Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Name of the script to run if the route matches. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const route = await client.workers.routes.get('023e105f4ecef8ad9ca31a8372d0c353', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 `client.workers.routes.create(RouteCreateParamsparams, RequestOptionsoptions?): RouteCreateResponse` **post** `/zones/{zone_id}/workers/routes` Creates a route that maps a URL pattern to a Worker. ### Parameters - `params: RouteCreateParams` - `zone_id: string` Path param: Identifier. - `pattern: string` Body param: Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Body param: Name of the script to run if the route matches. ### Returns - `RouteCreateResponse` - `id: string` Identifier. - `pattern: string` Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Name of the script to run if the route matches. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const route = await client.workers.routes.create({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', pattern: 'example.com/*', }); console.log(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 `client.workers.routes.update(stringrouteId, RouteUpdateParamsparams, RequestOptionsoptions?): RouteUpdateResponse` **put** `/zones/{zone_id}/workers/routes/{route_id}` Updates the URL pattern or Worker associated with a route. ### Parameters - `routeId: string` Identifier. - `params: RouteUpdateParams` - `zone_id: string` Path param: Identifier. - `pattern: string` Body param: Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Body param: Name of the script to run if the route matches. ### Returns - `RouteUpdateResponse` - `id: string` Identifier. - `pattern: string` Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Name of the script to run if the route matches. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const route = await client.workers.routes.update('023e105f4ecef8ad9ca31a8372d0c353', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', pattern: 'example.com/*', }); console.log(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 `client.workers.routes.delete(stringrouteId, RouteDeleteParamsparams, RequestOptionsoptions?): RouteDeleteResponse` **delete** `/zones/{zone_id}/workers/routes/{route_id}` Deletes a route. ### Parameters - `routeId: string` Identifier. - `params: RouteDeleteParams` - `zone_id: string` Identifier. ### Returns - `RouteDeleteResponse` - `id?: string` Identifier. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const route = await client.workers.routes.delete('023e105f4ecef8ad9ca31a8372d0c353', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 - `RouteListResponse` - `id: string` Identifier. - `pattern: string` Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Name of the script to run if the route matches. ### Route Get Response - `RouteGetResponse` - `id: string` Identifier. - `pattern: string` Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Name of the script to run if the route matches. ### Route Create Response - `RouteCreateResponse` - `id: string` Identifier. - `pattern: string` Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Name of the script to run if the route matches. ### Route Update Response - `RouteUpdateResponse` - `id: string` Identifier. - `pattern: string` Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Name of the script to run if the route matches. ### Route Delete Response - `RouteDeleteResponse` - `id?: string` Identifier. # Assets # Upload ## Upload Assets `client.workers.assets.upload.create(UploadCreateParamsparams, RequestOptionsoptions?): 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 - `params: UploadCreateParams` - `account_id: string` Path param: Identifier. - `base64: true` Query param: Whether the file contents are base64-encoded. Must be `true`. - `true` - `body: Record` Body param ### Returns - `UploadCreateResponse` - `jwt?: string` A "completion" JWT which can be redeemed when creating a Worker version. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare(); const upload = await client.workers.assets.upload.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', base64: true, body: { foo: 'string' }, }); console.log(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 - `UploadCreateResponse` - `jwt?: string` A "completion" JWT which can be redeemed when creating a Worker version. # Scripts ## List Workers `client.workers.scripts.list(ScriptListParamsparams, RequestOptionsoptions?): SinglePage` **get** `/accounts/{account_id}/workers/scripts` Fetch a list of uploaded workers. ### Parameters - `params: ScriptListParams` - `account_id: string` Path param: Identifier. - `tags?: string` Query param: Filter scripts by tags. Format: comma-separated list of tag:allowed pairs where allowed is 'yes' or 'no'. ### Returns - `ScriptListResponse` - `id?: string` The name used to identify the script. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: string` When the script was created. - `etag?: string` Hashed script content, can be used in a If-None-Match header when updating. - `handlers?: Array` The names of handlers exported as part of the default export. - `has_assets?: boolean` Whether a Worker contains assets. - `has_modules?: boolean` Whether a Worker contains modules. - `last_deployed_from?: string` The client most recently used to deploy this Worker. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `migration_tag?: string` The tag of the Durable Object migration that was most recently applied for this Worker. - `modified_on?: string` When the script was last modified. - `named_handlers?: Array` Named exports, such as Durable Object class implementations and named entrypoints. - `handlers?: Array` The names of handlers exported as part of the named export. - `name?: string` The name of the export. - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: UnionMember0 | UnionMember1 | UnionMember2 | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `UnionMember0` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember1` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember2` - `hostname: string` HTTP hostname for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember3` - `host: string` TCP host and port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `placement_mode?: "smart" | "targeted"` - `"smart"` - `"targeted"` - `placement_status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `routes?: Array | null` Routes associated with the Worker. - `id: string` Identifier. - `pattern: string` Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Name of the script to run if the route matches. - `tag?: string` The immutable ID of the script. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const scriptListResponse of client.workers.scripts.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', })) { console.log(scriptListResponse.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 `client.workers.scripts.search(ScriptSearchParamsparams, RequestOptionsoptions?): ScriptSearchResponse` **get** `/accounts/{account_id}/workers/scripts-search` Search for Workers in an account. ### Parameters - `params: ScriptSearchParams` - `account_id: string` Path param: Identifier. - `id?: string` Query param: Worker ID (also called tag) to search for. Only exact matches are returned. - `name?: string` Query param: Worker name to search for. Both exact and partial matches are returned. - `order_by?: "created_on" | "modified_on" | "name"` Query param: Property to sort results by. Results are sorted in ascending order. - `"created_on"` - `"modified_on"` - `"name"` - `page?: number` Query param: Current page. - `per_page?: number` Query param: Items per page. ### Returns - `ScriptSearchResponse = Array` - `id: string` Identifier. - `created_on: string` When the script was created. - `modified_on: string` When the script was last modified. - `script_name: string` Name of the script, used in URLs and route configuration. - `environment_is_default?: boolean` Whether the environment is the default environment. - `environment_name?: string` Name of the environment. - `service_name?: string` Name of the service. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.workers.scripts.search({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 `client.workers.scripts.get(stringscriptName, ScriptGetParamsparams, RequestOptionsoptions?): 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 - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: ScriptGetParams` - `account_id: string` Identifier. ### Returns - `ScriptGetResponse = string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const script = await client.workers.scripts.get('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(script); ``` ## Upload Worker Module `client.workers.scripts.update(stringscriptName, ScriptUpdateParamsparams, RequestOptionsoptions?): 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 - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: ScriptUpdateParams` - `account_id: string` Path param: Identifier. - `metadata: Metadata` Body param: JSON-encoded metadata about the uploaded parts and Worker configuration. - `annotations?: Annotations` Annotations for the version created by this upload. - `"workers/message"?: string` Human-readable message about the version. - `"workers/tag"?: string` User-provided identifier for the version. - `assets?: Assets` Configuration for assets within a Worker. - `config?: Config` Configuration for assets within a Worker. - `_headers?: string` The contents of a _headers file (used to attach custom headers on asset responses). - `_redirects?: string` The contents of a _redirects file (used to apply redirects or proxy paths ahead of asset serving). - `html_handling?: "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?: "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?: Array | boolean` 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. - `Array` - `boolean` - `serve_directly?: boolean` 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?: string` Token provided upon successful upload of all files from a registered manifest. - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `body_part?: string` 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?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: boolean` Retain assets which exist for a previously uploaded Worker version; used in lieu of providing a completion token. - `keep_bindings?: Array` List of binding types to keep from previous_upload. - `limits?: Limits` Limits to apply for this Worker. - `cpu_ms?: number` The amount of CPU time this Worker can use in milliseconds. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `main_module?: string` Name of the uploaded file that contains the main module (e.g. the file exporting a `fetch` handler). Indicates a `module syntax` Worker. - `migrations?: SingleStepMigration | WorkersMultipleStepMigrations` Migrations to apply for Durable Objects associated with this Worker. - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `WorkersMultipleStepMigrations` - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `steps?: Array` Migrations to apply in order. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: UnionMember0 | UnionMember1 | UnionMember2 | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `UnionMember0` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember1` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember2` - `hostname: string` HTTP hostname for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember3` - `host: string` TCP host and port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `tags?: Array` List of strings to use as tags for this Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` - `bindings_inherit?: "strict"` Query param: 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?: Array` Body param: 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 - `ScriptUpdateResponse` - `startup_time_ms: number` - `id?: string` The name used to identify the script. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: string` When the script was created. - `entry_point?: string` The entry point for the script. - `etag?: string` Hashed script content, can be used in a If-None-Match header when updating. - `handlers?: Array` The names of handlers exported as part of the default export. - `has_assets?: boolean` Whether a Worker contains assets. - `has_modules?: boolean` Whether a Worker contains modules. - `last_deployed_from?: string` The client most recently used to deploy this Worker. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `migration_tag?: string` The tag of the Durable Object migration that was most recently applied for this Worker. - `modified_on?: string` When the script was last modified. - `named_handlers?: Array` Named exports, such as Durable Object class implementations and named entrypoints. - `handlers?: Array` The names of handlers exported as part of the named export. - `name?: string` The name of the export. - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: UnionMember0 | UnionMember1 | UnionMember2 | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `UnionMember0` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember1` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember2` - `hostname: string` HTTP hostname for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember3` - `host: string` TCP host and port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `placement_mode?: "smart" | "targeted"` - `"smart"` - `"targeted"` - `placement_status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `tag?: string` The immutable ID of the script. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const script = await client.workers.scripts.update('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', metadata: {}, }); console.log(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 `client.workers.scripts.delete(stringscriptName, ScriptDeleteParamsparams, RequestOptionsoptions?): ScriptDeleteResponse | null` **delete** `/accounts/{account_id}/workers/scripts/{script_name}` Delete your worker. This call has no response body on a successful delete. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: ScriptDeleteParams` - `account_id: string` Path param: Identifier. - `force?: boolean` Query param: 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 - `ScriptDeleteResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const script = await client.workers.scripts.delete('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 - `Script` - `id?: string` The name used to identify the script. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: string` When the script was created. - `etag?: string` Hashed script content, can be used in a If-None-Match header when updating. - `handlers?: Array` The names of handlers exported as part of the default export. - `has_assets?: boolean` Whether a Worker contains assets. - `has_modules?: boolean` Whether a Worker contains modules. - `last_deployed_from?: string` The client most recently used to deploy this Worker. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `migration_tag?: string` The tag of the Durable Object migration that was most recently applied for this Worker. - `modified_on?: string` When the script was last modified. - `named_handlers?: Array` Named exports, such as Durable Object class implementations and named entrypoints. - `handlers?: Array` The names of handlers exported as part of the named export. - `name?: string` The name of the export. - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: UnionMember0 | UnionMember1 | UnionMember2 | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `UnionMember0` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember1` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember2` - `hostname: string` HTTP hostname for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember3` - `host: string` TCP host and port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `placement_mode?: "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?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `tag?: string` The immutable ID of the script. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` ### Script Setting - `ScriptSetting` - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `observability?: Observability | null` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. ### Script List Response - `ScriptListResponse` - `id?: string` The name used to identify the script. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: string` When the script was created. - `etag?: string` Hashed script content, can be used in a If-None-Match header when updating. - `handlers?: Array` The names of handlers exported as part of the default export. - `has_assets?: boolean` Whether a Worker contains assets. - `has_modules?: boolean` Whether a Worker contains modules. - `last_deployed_from?: string` The client most recently used to deploy this Worker. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `migration_tag?: string` The tag of the Durable Object migration that was most recently applied for this Worker. - `modified_on?: string` When the script was last modified. - `named_handlers?: Array` Named exports, such as Durable Object class implementations and named entrypoints. - `handlers?: Array` The names of handlers exported as part of the named export. - `name?: string` The name of the export. - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: UnionMember0 | UnionMember1 | UnionMember2 | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `UnionMember0` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember1` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember2` - `hostname: string` HTTP hostname for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember3` - `host: string` TCP host and port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `placement_mode?: "smart" | "targeted"` - `"smart"` - `"targeted"` - `placement_status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `routes?: Array | null` Routes associated with the Worker. - `id: string` Identifier. - `pattern: string` Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Name of the script to run if the route matches. - `tag?: string` The immutable ID of the script. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` ### Script Search Response - `ScriptSearchResponse = Array` - `id: string` Identifier. - `created_on: string` When the script was created. - `modified_on: string` When the script was last modified. - `script_name: string` Name of the script, used in URLs and route configuration. - `environment_is_default?: boolean` Whether the environment is the default environment. - `environment_name?: string` Name of the environment. - `service_name?: string` Name of the service. ### Script Get Response - `ScriptGetResponse = string` ### Script Update Response - `ScriptUpdateResponse` - `startup_time_ms: number` - `id?: string` The name used to identify the script. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: string` When the script was created. - `entry_point?: string` The entry point for the script. - `etag?: string` Hashed script content, can be used in a If-None-Match header when updating. - `handlers?: Array` The names of handlers exported as part of the default export. - `has_assets?: boolean` Whether a Worker contains assets. - `has_modules?: boolean` Whether a Worker contains modules. - `last_deployed_from?: string` The client most recently used to deploy this Worker. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `migration_tag?: string` The tag of the Durable Object migration that was most recently applied for this Worker. - `modified_on?: string` When the script was last modified. - `named_handlers?: Array` Named exports, such as Durable Object class implementations and named entrypoints. - `handlers?: Array` The names of handlers exported as part of the named export. - `name?: string` The name of the export. - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: UnionMember0 | UnionMember1 | UnionMember2 | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `UnionMember0` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember1` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember2` - `hostname: string` HTTP hostname for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember3` - `host: string` TCP host and port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `placement_mode?: "smart" | "targeted"` - `"smart"` - `"targeted"` - `placement_status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `tag?: string` The immutable ID of the script. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` ### Script Delete Response - `ScriptDeleteResponse = unknown` # Assets # Upload ## Create Assets Upload Session `client.workers.scripts.assets.upload.create(stringscriptName, UploadCreateParamsparams, RequestOptionsoptions?): 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 - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: UploadCreateParams` - `account_id: string` Path param: Identifier. - `manifest: Record` Body param: A manifest ([path]: {hash, size}) map of files to upload. As an example, `/blog/hello-world.html` would be a valid path key. - `hash: string` The hash of the file. - `size: number` The size of the file in bytes. ### Returns - `UploadCreateResponse` - `buckets?: Array>` The requests to make to upload assets. - `jwt?: string` A JWT to use as authentication for uploading assets. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const upload = await client.workers.scripts.assets.upload.create('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', manifest: { foo: { hash: 'hash', size: 0 } }, }); console.log(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 - `UploadCreateResponse` - `buckets?: Array>` The requests to make to upload assets. - `jwt?: string` A JWT to use as authentication for uploading assets. # Subdomain ## Get Worker subdomain `client.workers.scripts.subdomain.get(stringscriptName, SubdomainGetParamsparams, RequestOptionsoptions?): SubdomainGetResponse` **get** `/accounts/{account_id}/workers/scripts/{script_name}/subdomain` Get if the Worker is available on the workers.dev subdomain. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: SubdomainGetParams` - `account_id: string` Identifier. ### Returns - `SubdomainGetResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const subdomain = await client.workers.scripts.subdomain.get('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 `client.workers.scripts.subdomain.create(stringscriptName, SubdomainCreateParamsparams, RequestOptionsoptions?): SubdomainCreateResponse` **post** `/accounts/{account_id}/workers/scripts/{script_name}/subdomain` Enable or disable the Worker on the workers.dev subdomain. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: SubdomainCreateParams` - `account_id: string` Path param: Identifier. - `enabled: boolean` Body param: Whether the Worker should be available on the workers.dev subdomain. - `previews_enabled?: boolean` Body param: Whether the Worker's Preview URLs should be available on the workers.dev subdomain. ### Returns - `SubdomainCreateResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const subdomain = await client.workers.scripts.subdomain.create('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', enabled: true, }); console.log(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 `client.workers.scripts.subdomain.delete(stringscriptName, SubdomainDeleteParamsparams, RequestOptionsoptions?): SubdomainDeleteResponse` **delete** `/accounts/{account_id}/workers/scripts/{script_name}/subdomain` Disable all workers.dev subdomains for a Worker. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: SubdomainDeleteParams` - `account_id: string` Identifier. ### Returns - `SubdomainDeleteResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const subdomain = await client.workers.scripts.subdomain.delete('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 - `SubdomainGetResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain. ### Subdomain Create Response - `SubdomainCreateResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain. ### Subdomain Delete Response - `SubdomainDeleteResponse` - `enabled: boolean` Whether the Worker is available on the workers.dev subdomain. - `previews_enabled: boolean` Whether the Worker's Preview URLs are available on the workers.dev subdomain. # Schedules ## Get Cron Triggers `client.workers.scripts.schedules.get(stringscriptName, ScheduleGetParamsparams, RequestOptionsoptions?): ScheduleGetResponse` **get** `/accounts/{account_id}/workers/scripts/{script_name}/schedules` Fetches Cron Triggers for a Worker. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: ScheduleGetParams` - `account_id: string` Identifier. ### Returns - `ScheduleGetResponse` - `schedules: Array` - `cron: string` - `created_on?: string` - `modified_on?: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const schedule = await client.workers.scripts.schedules.get('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 `client.workers.scripts.schedules.update(stringscriptName, ScheduleUpdateParamsparams, RequestOptionsoptions?): ScheduleUpdateResponse` **put** `/accounts/{account_id}/workers/scripts/{script_name}/schedules` Updates Cron Triggers for a Worker. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: ScheduleUpdateParams` - `account_id: string` Path param: Identifier. - `body: Array` Body param - `cron: string` - `created_on?: string` - `modified_on?: string` ### Returns - `ScheduleUpdateResponse` - `schedules: Array` - `cron: string` - `created_on?: string` - `modified_on?: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const schedule = await client.workers.scripts.schedules.update('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', body: [{ cron: '*/30 * * * *' }], }); console.log(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 - `ScheduleGetResponse` - `schedules: Array` - `cron: string` - `created_on?: string` - `modified_on?: string` ### Schedule Update Response - `ScheduleUpdateResponse` - `schedules: Array` - `cron: string` - `created_on?: string` - `modified_on?: string` # Tail ## List Tails `client.workers.scripts.tail.get(stringscriptName, TailGetParamsparams, RequestOptionsoptions?): TailGetResponse` **get** `/accounts/{account_id}/workers/scripts/{script_name}/tails` Get list of tails currently deployed on a Worker. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: TailGetParams` - `account_id: string` Identifier. ### Returns - `TailGetResponse` - `id: string` Identifier. - `expires_at: string` - `url: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const tail = await client.workers.scripts.tail.get('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 `client.workers.scripts.tail.create(stringscriptName, TailCreateParamsparams, RequestOptionsoptions?): TailCreateResponse` **post** `/accounts/{account_id}/workers/scripts/{script_name}/tails` Starts a tail that receives logs and exception from a Worker. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: TailCreateParams` - `account_id: string` Path param: Identifier. - `body: unknown` Body param ### Returns - `TailCreateResponse` - `id: string` Identifier. - `expires_at: string` - `url: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const tail = await client.workers.scripts.tail.create('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', body: {}, }); console.log(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 `client.workers.scripts.tail.delete(stringscriptName, stringid, TailDeleteParamsparams, RequestOptionsoptions?): TailDeleteResponse` **delete** `/accounts/{account_id}/workers/scripts/{script_name}/tails/{id}` Deletes a tail from a Worker. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `id: string` Identifier. - `params: TailDeleteParams` - `account_id: string` Identifier. ### Returns - `TailDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const tail = await client.workers.scripts.tail.delete( 'this-is_my_script-01', '023e105f4ecef8ad9ca31a8372d0c353', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(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 - `ConsumerScript` A reference to a script that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. ### Tail Get Response - `TailGetResponse` - `id: string` Identifier. - `expires_at: string` - `url: string` ### Tail Create Response - `TailCreateResponse` - `id: string` Identifier. - `expires_at: string` - `url: string` ### Tail Delete Response - `TailDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` # Content ## Get script content `client.workers.scripts.content.get(stringscriptName, ContentGetParamsparams, RequestOptionsoptions?): Response` **get** `/accounts/{account_id}/workers/scripts/{script_name}/content/v2` Fetch script content only. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: ContentGetParams` - `account_id: string` Identifier. ### Returns - `unnamed_schema_0 = Response` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const content = await client.workers.scripts.content.get('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(content); const data = await content.blob(); console.log(data); ``` ## Put script content `client.workers.scripts.content.update(stringscriptName, ContentUpdateParamsparams, RequestOptionsoptions?): Script` **put** `/accounts/{account_id}/workers/scripts/{script_name}/content` Put script content without touching config or metadata. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: ContentUpdateParams` - `account_id: string` Path param: Identifier. - `metadata: Metadata` Body param: JSON-encoded metadata about the uploaded parts and Worker configuration. - `body_part?: string` 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?: string` Name of the uploaded file that contains the main module (e.g. the file exporting a `fetch` handler). Indicates a `module syntax` Worker. - `files?: Array` Body param: 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`. - `cfWorkerBodyPart?: string` Header param: The multipart name of a script upload part containing script content in service worker format. Alternative to including in a metadata part. - `cfWorkerMainModulePart?: string` Header param: The multipart name of a script upload part containing script content in es module format. Alternative to including in a metadata part. ### Returns - `Script` - `id?: string` The name used to identify the script. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: string` When the script was created. - `etag?: string` Hashed script content, can be used in a If-None-Match header when updating. - `handlers?: Array` The names of handlers exported as part of the default export. - `has_assets?: boolean` Whether a Worker contains assets. - `has_modules?: boolean` Whether a Worker contains modules. - `last_deployed_from?: string` The client most recently used to deploy this Worker. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `migration_tag?: string` The tag of the Durable Object migration that was most recently applied for this Worker. - `modified_on?: string` When the script was last modified. - `named_handlers?: Array` Named exports, such as Durable Object class implementations and named entrypoints. - `handlers?: Array` The names of handlers exported as part of the named export. - `name?: string` The name of the export. - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: UnionMember0 | UnionMember1 | UnionMember2 | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `UnionMember0` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember1` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember2` - `hostname: string` HTTP hostname for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember3` - `host: string` TCP host and port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `last_analyzed_at?: string` The last time the script was analyzed for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `status?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `placement_mode?: "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?: "SUCCESS" | "UNSUPPORTED_APPLICATION" | "INSUFFICIENT_INVOCATIONS"` Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"SUCCESS"` - `"UNSUPPORTED_APPLICATION"` - `"INSUFFICIENT_INVOCATIONS"` - `tag?: string` The immutable ID of the script. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const script = await client.workers.scripts.content.update('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', metadata: {}, }); console.log(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 `client.workers.scripts.settings.get(stringscriptName, SettingGetParamsparams, RequestOptionsoptions?): 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 - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: SettingGetParams` - `account_id: string` Identifier. ### Returns - `ScriptSetting` - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `observability?: Observability | null` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const scriptSetting = await client.workers.scripts.settings.get('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(scriptSetting.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 `client.workers.scripts.settings.edit(stringscriptName, SettingEditParamsparams, RequestOptionsoptions?): 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 - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: SettingEditParams` - `account_id: string` Path param: Identifier. - `logpush?: boolean` Body param: Whether Logpush is turned on for the Worker. - `observability?: Observability | null` Body param: Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `tags?: Array | null` Body param: Tags associated with the Worker. - `tail_consumers?: Array | null` Body param: List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. ### Returns - `ScriptSetting` - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `observability?: Observability | null` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const scriptSetting = await client.workers.scripts.settings.edit('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(scriptSetting.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 `client.workers.scripts.deployments.list(stringscriptName, DeploymentListParamsparams, RequestOptionsoptions?): 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 - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: DeploymentListParams` - `account_id: string` Identifier. ### Returns - `DeploymentListResponse` - `deployments: Array` - `id: string` - `created_on: string` - `source: string` - `strategy: "percentage"` - `"percentage"` - `versions: Array` - `percentage: number` - `version_id: string` - `annotations?: Annotations` - `"workers/message"?: string` Human-readable message about the deployment. Truncated to 100 bytes. - `"workers/triggered_by"?: string` Operation that triggered the creation of the deployment. - `author_email?: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const deployments = await client.workers.scripts.deployments.list('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 `client.workers.scripts.deployments.create(stringscriptName, DeploymentCreateParamsparams, RequestOptionsoptions?): 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 - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: DeploymentCreateParams` - `account_id: string` Path param: Identifier. - `strategy: "percentage"` Body param - `"percentage"` - `versions: Array` Body param - `percentage: number` - `version_id: string` - `force?: boolean` Query param: 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?: Annotations` Body param - `"workers/message"?: string` Human-readable message about the deployment. Truncated to 100 bytes. - `"workers/triggered_by"?: string` Operation that triggered the creation of the deployment. ### Returns - `Deployment` - `id: string` - `created_on: string` - `source: string` - `strategy: "percentage"` - `"percentage"` - `versions: Array` - `percentage: number` - `version_id: string` - `annotations?: Annotations` - `"workers/message"?: string` Human-readable message about the deployment. Truncated to 100 bytes. - `"workers/triggered_by"?: string` Operation that triggered the creation of the deployment. - `author_email?: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const deployment = await client.workers.scripts.deployments.create('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', strategy: 'percentage', versions: [{ percentage: 100, version_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' }], }); console.log(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 `client.workers.scripts.deployments.get(stringscriptName, stringdeploymentId, DeploymentGetParamsparams, RequestOptionsoptions?): Deployment` **get** `/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}` Get information about a Worker Deployment. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `deploymentId: string` - `params: DeploymentGetParams` - `account_id: string` Identifier. ### Returns - `Deployment` - `id: string` - `created_on: string` - `source: string` - `strategy: "percentage"` - `"percentage"` - `versions: Array` - `percentage: number` - `version_id: string` - `annotations?: Annotations` - `"workers/message"?: string` Human-readable message about the deployment. Truncated to 100 bytes. - `"workers/triggered_by"?: string` Operation that triggered the creation of the deployment. - `author_email?: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const deployment = await client.workers.scripts.deployments.get( 'this-is_my_script-01', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(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 `client.workers.scripts.deployments.delete(stringscriptName, stringdeploymentId, DeploymentDeleteParamsparams, RequestOptionsoptions?): 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 - `scriptName: string` Name of the script, used in URLs and route configuration. - `deploymentId: string` - `params: DeploymentDeleteParams` - `account_id: string` Identifier. ### Returns - `DeploymentDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const deployment = await client.workers.scripts.deployments.delete( 'this-is_my_script-01', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(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 - `Deployment` - `id: string` - `created_on: string` - `source: string` - `strategy: "percentage"` - `"percentage"` - `versions: Array` - `percentage: number` - `version_id: string` - `annotations?: Annotations` - `"workers/message"?: string` Human-readable message about the deployment. Truncated to 100 bytes. - `"workers/triggered_by"?: string` Operation that triggered the creation of the deployment. - `author_email?: string` ### Deployment List Response - `DeploymentListResponse` - `deployments: Array` - `id: string` - `created_on: string` - `source: string` - `strategy: "percentage"` - `"percentage"` - `versions: Array` - `percentage: number` - `version_id: string` - `annotations?: Annotations` - `"workers/message"?: string` Human-readable message about the deployment. Truncated to 100 bytes. - `"workers/triggered_by"?: string` Operation that triggered the creation of the deployment. - `author_email?: string` ### Deployment Delete Response - `DeploymentDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` # Versions ## List Versions `client.workers.scripts.versions.list(stringscriptName, VersionListParamsparams, RequestOptionsoptions?): V4PagePagination` **get** `/accounts/{account_id}/workers/scripts/{script_name}/versions` List of Worker Versions. The first version in the list is the latest version. ### Parameters - `scriptName: string` Name of the script. - `params: VersionListParams` - `account_id: string` Path param: Identifier. - `deployable?: boolean` Query param: Only return versions that can be used in a deployment. Ignores pagination. - `page?: number` Query param: Current page. - `per_page?: number` Query param: Items per-page. ### Returns - `VersionListResponse` - `id?: string` Unique identifier for the version. - `metadata?: Metadata` - `author_email?: string` Email of the user who created the version. - `author_id?: string` Identifier of the user who created the version. - `created_on?: string` When the version was created. - `hasPreview?: boolean` Whether the version can be previewed. - `modified_on?: string` When the version was last modified. - `source?: "unknown" | "api" | "wrangler" | 7 more` The source of the version upload. - `"unknown"` - `"api"` - `"wrangler"` - `"terraform"` - `"dash"` - `"dash_template"` - `"integration"` - `"quick_editor"` - `"playground"` - `"workersci"` - `number?: number` Sequential version number. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const versionListResponse of client.workers.scripts.versions.list( 'this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, )) { console.log(versionListResponse.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 `client.workers.scripts.versions.get(stringscriptName, stringversionId, VersionGetParamsparams, RequestOptionsoptions?): VersionGetResponse` **get** `/accounts/{account_id}/workers/scripts/{script_name}/versions/{version_id}` Retrieves detailed information about a specific version of a Workers script. ### Parameters - `scriptName: string` Name of the script. - `versionId: string` - `params: VersionGetParams` - `account_id: string` Identifier. ### Returns - `VersionGetResponse` - `resources: Resources` - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `script?: Script` - `etag?: string` Hashed script content - `handlers?: Array` The names of handlers exported as part of the default export. - `last_deployed_from?: string` The client most recently used to deploy this Worker. - `named_handlers?: Array` Named exports, such as Durable Object class implementations and named entrypoints. - `handlers?: Array` The names of handlers exported as part of the named export. - `name?: string` The name of the exported class or entrypoint. - `script_runtime?: ScriptRuntime` Runtime configuration for the Worker. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` Flags that enable or disable certain features in the Workers runtime. - `limits?: Limits` Resource limits for the Worker. - `cpu_ms?: number` The amount of CPU time this Worker can use in milliseconds. - `migration_tag?: string` The tag of the Durable Object migration that was most recently applied for this Worker. - `usage_model?: "bundled" | "unbound" | "standard"` Usage model for the Worker invocations. - `"bundled"` - `"unbound"` - `"standard"` - `id?: string` Unique identifier for the version. - `metadata?: Metadata` - `author_email?: string` Email of the user who created the version. - `author_id?: string` Identifier of the user who created the version. - `created_on?: string` When the version was created. - `hasPreview?: boolean` Whether the version can be previewed. - `modified_on?: string` When the version was last modified. - `source?: "unknown" | "api" | "wrangler" | 7 more` The source of the version upload. - `"unknown"` - `"api"` - `"wrangler"` - `"terraform"` - `"dash"` - `"dash_template"` - `"integration"` - `"quick_editor"` - `"playground"` - `"workersci"` - `number?: number` Sequential version number. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const version = await client.workers.scripts.versions.get( 'this-is_my_script-01', 'bcf48806-b317-4351-9ee7-36e7d557d4de', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(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 `client.workers.scripts.versions.create(stringscriptName, VersionCreateParamsparams, RequestOptionsoptions?): 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 - `scriptName: string` Name of the script. - `params: VersionCreateParams` - `account_id: string` Path param: Identifier. - `metadata: Metadata` Body param: JSON-encoded metadata about the uploaded parts and Worker configuration. - `main_module: string` 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?: Annotations` - `"workers/alias"?: string` Associated alias for a version. - `"workers/message"?: string` Human-readable message about the version. Truncated to 100 bytes. - `"workers/tag"?: string` User-provided identifier for the version. - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: Array` List of binding types to keep from previous_upload. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` - `bindings_inherit?: "strict"` Query param: 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?: Array` Body param: 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 - `VersionCreateResponse` - `resources: Resources` - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `script?: Script` - `etag?: string` Hashed script content - `handlers?: Array` The names of handlers exported as part of the default export. - `last_deployed_from?: string` The client most recently used to deploy this Worker. - `named_handlers?: Array` Named exports, such as Durable Object class implementations and named entrypoints. - `handlers?: Array` The names of handlers exported as part of the named export. - `name?: string` The name of the exported class or entrypoint. - `script_runtime?: ScriptRuntime` Runtime configuration for the Worker. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` Flags that enable or disable certain features in the Workers runtime. - `limits?: Limits` Resource limits for the Worker. - `cpu_ms?: number` The amount of CPU time this Worker can use in milliseconds. - `migration_tag?: string` The tag of the Durable Object migration that was most recently applied for this Worker. - `usage_model?: "bundled" | "unbound" | "standard"` Usage model for the Worker invocations. - `"bundled"` - `"unbound"` - `"standard"` - `id?: string` Unique identifier for the version. - `metadata?: Metadata` - `author_email?: string` Email of the user who created the version. - `author_id?: string` Identifier of the user who created the version. - `created_on?: string` When the version was created. - `hasPreview?: boolean` Whether the version can be previewed. - `modified_on?: string` When the version was last modified. - `source?: "unknown" | "api" | "wrangler" | 7 more` The source of the version upload. - `"unknown"` - `"api"` - `"wrangler"` - `"terraform"` - `"dash"` - `"dash_template"` - `"integration"` - `"quick_editor"` - `"playground"` - `"workersci"` - `number?: number` Sequential version number. - `startup_time_ms?: number` Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time). ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const version = await client.workers.scripts.versions.create('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', metadata: { main_module: 'worker.js' }, }); console.log(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 - `VersionListResponse` - `id?: string` Unique identifier for the version. - `metadata?: Metadata` - `author_email?: string` Email of the user who created the version. - `author_id?: string` Identifier of the user who created the version. - `created_on?: string` When the version was created. - `hasPreview?: boolean` Whether the version can be previewed. - `modified_on?: string` When the version was last modified. - `source?: "unknown" | "api" | "wrangler" | 7 more` The source of the version upload. - `"unknown"` - `"api"` - `"wrangler"` - `"terraform"` - `"dash"` - `"dash_template"` - `"integration"` - `"quick_editor"` - `"playground"` - `"workersci"` - `number?: number` Sequential version number. ### Version Get Response - `VersionGetResponse` - `resources: Resources` - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `script?: Script` - `etag?: string` Hashed script content - `handlers?: Array` The names of handlers exported as part of the default export. - `last_deployed_from?: string` The client most recently used to deploy this Worker. - `named_handlers?: Array` Named exports, such as Durable Object class implementations and named entrypoints. - `handlers?: Array` The names of handlers exported as part of the named export. - `name?: string` The name of the exported class or entrypoint. - `script_runtime?: ScriptRuntime` Runtime configuration for the Worker. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` Flags that enable or disable certain features in the Workers runtime. - `limits?: Limits` Resource limits for the Worker. - `cpu_ms?: number` The amount of CPU time this Worker can use in milliseconds. - `migration_tag?: string` The tag of the Durable Object migration that was most recently applied for this Worker. - `usage_model?: "bundled" | "unbound" | "standard"` Usage model for the Worker invocations. - `"bundled"` - `"unbound"` - `"standard"` - `id?: string` Unique identifier for the version. - `metadata?: Metadata` - `author_email?: string` Email of the user who created the version. - `author_id?: string` Identifier of the user who created the version. - `created_on?: string` When the version was created. - `hasPreview?: boolean` Whether the version can be previewed. - `modified_on?: string` When the version was last modified. - `source?: "unknown" | "api" | "wrangler" | 7 more` The source of the version upload. - `"unknown"` - `"api"` - `"wrangler"` - `"terraform"` - `"dash"` - `"dash_template"` - `"integration"` - `"quick_editor"` - `"playground"` - `"workersci"` - `number?: number` Sequential version number. ### Version Create Response - `VersionCreateResponse` - `resources: Resources` - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `script?: Script` - `etag?: string` Hashed script content - `handlers?: Array` The names of handlers exported as part of the default export. - `last_deployed_from?: string` The client most recently used to deploy this Worker. - `named_handlers?: Array` Named exports, such as Durable Object class implementations and named entrypoints. - `handlers?: Array` The names of handlers exported as part of the named export. - `name?: string` The name of the exported class or entrypoint. - `script_runtime?: ScriptRuntime` Runtime configuration for the Worker. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` Flags that enable or disable certain features in the Workers runtime. - `limits?: Limits` Resource limits for the Worker. - `cpu_ms?: number` The amount of CPU time this Worker can use in milliseconds. - `migration_tag?: string` The tag of the Durable Object migration that was most recently applied for this Worker. - `usage_model?: "bundled" | "unbound" | "standard"` Usage model for the Worker invocations. - `"bundled"` - `"unbound"` - `"standard"` - `id?: string` Unique identifier for the version. - `metadata?: Metadata` - `author_email?: string` Email of the user who created the version. - `author_id?: string` Identifier of the user who created the version. - `created_on?: string` When the version was created. - `hasPreview?: boolean` Whether the version can be previewed. - `modified_on?: string` When the version was last modified. - `source?: "unknown" | "api" | "wrangler" | 7 more` The source of the version upload. - `"unknown"` - `"api"` - `"wrangler"` - `"terraform"` - `"dash"` - `"dash_template"` - `"integration"` - `"quick_editor"` - `"playground"` - `"workersci"` - `number?: number` Sequential version number. - `startup_time_ms?: number` Time in milliseconds spent on [Worker startup](https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time). # Secrets ## List script secrets `client.workers.scripts.secrets.list(stringscriptName, SecretListParamsparams, RequestOptionsoptions?): SinglePage` **get** `/accounts/{account_id}/workers/scripts/{script_name}/secrets` List secrets bound to a script. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: SecretListParams` - `account_id: string` Identifier. ### Returns - `SecretListResponse = WorkersBindingKindSecretText | WorkersBindingKindSecretKey` A secret value accessible through a binding. - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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 ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const secretListResponse of client.workers.scripts.secrets.list('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', })) { console.log(secretListResponse); } ``` #### 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 `client.workers.scripts.secrets.get(stringscriptName, stringsecretName, SecretGetParamsparams, RequestOptionsoptions?): SecretGetResponse` **get** `/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}` Get a given secret binding (value omitted) on a script. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `secretName: string` A JavaScript variable name for the secret binding. - `params: SecretGetParams` - `account_id: string` Path param: Identifier. - `url_encoded?: boolean` Query param: Flag that indicates whether the secret name is URL encoded. ### Returns - `SecretGetResponse = WorkersBindingKindSecretText | WorkersBindingKindSecretKey` A secret value accessible through a binding. - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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 ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const secret = await client.workers.scripts.secrets.get('this-is_my_script-01', 'mySecret', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 `client.workers.scripts.secrets.update(stringscriptName, SecretUpdateParamsparams, RequestOptionsoptions?): SecretUpdateResponse` **put** `/accounts/{account_id}/workers/scripts/{script_name}/secrets` Add a secret to a script. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `SecretUpdateParams = WorkersBindingKindSecretText | WorkersBindingKindSecretKey` - `SecretUpdateParamsBase` - `WorkersBindingKindSecretText extends SecretUpdateParamsBase` - `WorkersBindingKindSecretKey extends SecretUpdateParamsBase` ### Returns - `SecretUpdateResponse = WorkersBindingKindSecretText | WorkersBindingKindSecretKey` A secret value accessible through a binding. - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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 ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const secret = await client.workers.scripts.secrets.update('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', name: 'myBinding', text: 'My secret.', type: 'secret_text', }); console.log(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 `client.workers.scripts.secrets.delete(stringscriptName, stringsecretName, SecretDeleteParamsparams, RequestOptionsoptions?): SecretDeleteResponse | null` **delete** `/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}` Remove a secret from a script. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `secretName: string` A JavaScript variable name for the secret binding. - `params: SecretDeleteParams` - `account_id: string` Path param: Identifier. - `url_encoded?: boolean` Query param: Flag that indicates whether the secret name is URL encoded. ### Returns - `SecretDeleteResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const secret = await client.workers.scripts.secrets.delete('this-is_my_script-01', 'mySecret', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 = WorkersBindingKindSecretText | WorkersBindingKindSecretKey` A secret value accessible through a binding. - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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 = WorkersBindingKindSecretText | WorkersBindingKindSecretKey` A secret value accessible through a binding. - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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 = WorkersBindingKindSecretText | WorkersBindingKindSecretKey` A secret value accessible through a binding. - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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 Delete Response - `SecretDeleteResponse = unknown` # Script And Version Settings ## Get Settings `client.workers.scripts.scriptAndVersionSettings.get(stringscriptName, ScriptAndVersionSettingGetParamsparams, RequestOptionsoptions?): ScriptAndVersionSettingGetResponse` **get** `/accounts/{account_id}/workers/scripts/{script_name}/settings` Get metadata and config, such as bindings or usage model. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: ScriptAndVersionSettingGetParams` - `account_id: string` Identifier. ### Returns - `ScriptAndVersionSettingGetResponse` - `annotations?: 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"?: string` Human-readable message about the version. - `"workers/tag"?: string` User-provided identifier for the version. - `"workers/triggered_by"?: string` Operation that triggered the creation of the version. This is read-only and set by the server. - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: Limits` Limits to apply for this Worker. - `cpu_ms?: number` The amount of CPU time this Worker can use in milliseconds. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `migrations?: SingleStepMigration | WorkersMultipleStepMigrations` Migrations to apply for Durable Objects associated with this Worker. - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `WorkersMultipleStepMigrations` - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `steps?: Array` Migrations to apply in order. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: Mode | Region | Hostname | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `Mode` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `Region` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host and port for targeted placement. - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const scriptAndVersionSetting = await client.workers.scripts.scriptAndVersionSettings.get( 'this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(scriptAndVersionSetting.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 }, "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 `client.workers.scripts.scriptAndVersionSettings.edit(stringscriptName, ScriptAndVersionSettingEditParamsparams, RequestOptionsoptions?): ScriptAndVersionSettingEditResponse` **patch** `/accounts/{account_id}/workers/scripts/{script_name}/settings` Patch metadata or config, such as bindings or usage model. ### Parameters - `scriptName: string` Name of the script, used in URLs and route configuration. - `params: ScriptAndVersionSettingEditParams` - `account_id: string` Path param: Identifier. - `settings?: Settings` Body param - `annotations?: 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"?: string` Human-readable message about the version. - `"workers/tag"?: string` User-provided identifier for the version. - `"workers/triggered_by"?: string` Operation that triggered the creation of the version. This is read-only and set by the server. - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: Limits` Limits to apply for this Worker. - `cpu_ms?: number` The amount of CPU time this Worker can use in milliseconds. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `migrations?: SingleStepMigration | WorkersMultipleStepMigrations` Migrations to apply for Durable Objects associated with this Worker. - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `WorkersMultipleStepMigrations` - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `steps?: Array` Migrations to apply in order. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: Mode | Region | Hostname | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `Mode` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `Region` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host and port for targeted placement. - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` ### Returns - `ScriptAndVersionSettingEditResponse` - `annotations?: 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"?: string` Human-readable message about the version. - `"workers/tag"?: string` User-provided identifier for the version. - `"workers/triggered_by"?: string` Operation that triggered the creation of the version. This is read-only and set by the server. - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: Limits` Limits to apply for this Worker. - `cpu_ms?: number` The amount of CPU time this Worker can use in milliseconds. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `migrations?: SingleStepMigration | WorkersMultipleStepMigrations` Migrations to apply for Durable Objects associated with this Worker. - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `WorkersMultipleStepMigrations` - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `steps?: Array` Migrations to apply in order. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: Mode | Region | Hostname | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `Mode` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `Region` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host and port for targeted placement. - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.workers.scripts.scriptAndVersionSettings.edit( 'this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(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 }, "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 - `ScriptAndVersionSettingGetResponse` - `annotations?: 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"?: string` Human-readable message about the version. - `"workers/tag"?: string` User-provided identifier for the version. - `"workers/triggered_by"?: string` Operation that triggered the creation of the version. This is read-only and set by the server. - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: Limits` Limits to apply for this Worker. - `cpu_ms?: number` The amount of CPU time this Worker can use in milliseconds. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `migrations?: SingleStepMigration | WorkersMultipleStepMigrations` Migrations to apply for Durable Objects associated with this Worker. - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `WorkersMultipleStepMigrations` - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `steps?: Array` Migrations to apply in order. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: Mode | Region | Hostname | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `Mode` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `Region` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host and port for targeted placement. - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` ### Script And Version Setting Edit Response - `ScriptAndVersionSettingEditResponse` - `annotations?: 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"?: string` Human-readable message about the version. - `"workers/tag"?: string` User-provided identifier for the version. - `"workers/triggered_by"?: string` Operation that triggered the creation of the version. This is read-only and set by the server. - `bindings?: Array` 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. - `WorkersBindingKindAI` - `name: string` A JavaScript variable name for the binding. - `type: "ai"` The kind of resource that the binding provides. - `"ai"` - `WorkersBindingKindAISearch` - `instance_name: string` The user-chosen instance name. Must exist at deploy time. The worker can search, chat, update, and manage items/jobs on this instance. - `name: string` A JavaScript variable name for the binding. - `type: "ai_search"` The kind of resource that the binding provides. - `"ai_search"` - `namespace?: string` The namespace the instance belongs to. Defaults to "default" if omitted. Customers who don't use namespaces can simply omit this field. - `WorkersBindingKindAISearchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` 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: "ai_search_namespace"` The kind of resource that the binding provides. - `"ai_search_namespace"` - `WorkersBindingKindAnalyticsEngine` - `dataset: string` The name of the dataset to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "analytics_engine"` The kind of resource that the binding provides. - `"analytics_engine"` - `WorkersBindingKindAssets` - `name: string` A JavaScript variable name for the binding. - `type: "assets"` The kind of resource that the binding provides. - `"assets"` - `WorkersBindingKindBrowser` - `name: string` A JavaScript variable name for the binding. - `type: "browser"` The kind of resource that the binding provides. - `"browser"` - `WorkersBindingKindD1` - `id: string` Identifier of the D1 database to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "d1"` The kind of resource that the binding provides. - `"d1"` - `WorkersBindingKindDataBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the data content. Only accepted for `service worker syntax` Workers. - `type: "data_blob"` The kind of resource that the binding provides. - `"data_blob"` - `WorkersBindingKindDispatchNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace: string` The name of the dispatch namespace. - `type: "dispatch_namespace"` The kind of resource that the binding provides. - `"dispatch_namespace"` - `outbound?: Outbound` Outbound worker. - `params?: Array` Pass information from the Dispatch Worker to the Outbound Worker through the parameters. - `name: string` Name of the parameter. - `worker?: Worker` Outbound worker. - `entrypoint?: string` Entrypoint to invoke on the outbound worker. - `environment?: string` Environment of the outbound worker. - `service?: string` Name of the outbound worker. - `WorkersBindingKindDurableObjectNamespace` - `name: string` A JavaScript variable name for the binding. - `type: "durable_object_namespace"` The kind of resource that the binding provides. - `"durable_object_namespace"` - `class_name?: string` The exported class name of the Durable Object. - `dispatch_namespace?: string` The dispatch namespace the Durable Object script belongs to. - `environment?: string` The environment of the script_name to bind to. - `namespace_id?: string` Namespace identifier tag. - `script_name?: string` The script where the Durable Object is defined, if it is external to this Worker. - `WorkersBindingKindHyperdrive` - `id: string` Identifier of the Hyperdrive connection to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "hyperdrive"` The kind of resource that the binding provides. - `"hyperdrive"` - `WorkersBindingKindInherit` - `name: string` The name of the inherited binding. - `type: "inherit"` The kind of resource that the binding provides. - `"inherit"` - `old_name?: string` 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?: string` 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. - `WorkersBindingKindImages` - `name: string` A JavaScript variable name for the binding. - `type: "images"` The kind of resource that the binding provides. - `"images"` - `WorkersBindingKindJson` - `json: unknown` JSON data to use. - `name: string` A JavaScript variable name for the binding. - `type: "json"` The kind of resource that the binding provides. - `"json"` - `WorkersBindingKindKVNamespace` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Namespace identifier tag. - `type: "kv_namespace"` The kind of resource that the binding provides. - `"kv_namespace"` - `WorkersBindingKindMedia` - `name: string` A JavaScript variable name for the binding. - `type: "media"` The kind of resource that the binding provides. - `"media"` - `WorkersBindingKindMTLSCertificate` - `certificate_id: string` Identifier of the certificate to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "mtls_certificate"` The kind of resource that the binding provides. - `"mtls_certificate"` - `WorkersBindingKindPlainText` - `name: string` A JavaScript variable name for the binding. - `text: string` The text value to use. - `type: "plain_text"` The kind of resource that the binding provides. - `"plain_text"` - `WorkersBindingKindPipelines` - `name: string` A JavaScript variable name for the binding. - `pipeline: string` Name of the Pipeline to bind to. - `type: "pipelines"` The kind of resource that the binding provides. - `"pipelines"` - `WorkersBindingKindQueue` - `name: string` A JavaScript variable name for the binding. - `queue_name: string` Name of the Queue to bind to. - `type: "queue"` The kind of resource that the binding provides. - `"queue"` - `WorkersBindingKindRatelimit` - `name: string` A JavaScript variable name for the binding. - `namespace_id: string` Identifier of the rate limit namespace to bind to. - `simple: Simple` The rate limit configuration. - `limit: number` The limit (requests per period). - `period: number` The period in seconds. - `type: "ratelimit"` The kind of resource that the binding provides. - `"ratelimit"` - `WorkersBindingKindR2Bucket` - `bucket_name: string` R2 bucket to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "r2_bucket"` The kind of resource that the binding provides. - `"r2_bucket"` - `jurisdiction?: "eu" | "fedramp" | "fedramp-high"` The [jurisdiction](https://developers.cloudflare.com/r2/reference/data-location/#jurisdictional-restrictions) of the R2 bucket. - `"eu"` - `"fedramp"` - `"fedramp-high"` - `WorkersBindingKindSecretText` - `name: string` A JavaScript variable name for the binding. - `text: string` The secret value to use. - `type: "secret_text"` The kind of resource that the binding provides. - `"secret_text"` - `WorkersBindingKindSendEmail` - `name: string` A JavaScript variable name for the binding. - `type: "send_email"` The kind of resource that the binding provides. - `"send_email"` - `allowed_destination_addresses?: Array` List of allowed destination addresses. - `allowed_sender_addresses?: Array` List of allowed sender addresses. - `destination_address?: string` Destination address for the email. - `WorkersBindingKindService` - `name: string` A JavaScript variable name for the binding. - `service: string` Name of Worker to bind to. - `type: "service"` The kind of resource that the binding provides. - `"service"` - `entrypoint?: string` Entrypoint to invoke on the target Worker. - `environment?: string` Optional environment if the Worker utilizes one. - `WorkersBindingKindTextBlob` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the text content. Only accepted for `service worker syntax` Workers. - `type: "text_blob"` The kind of resource that the binding provides. - `"text_blob"` - `WorkersBindingKindVectorize` - `index_name: string` Name of the Vectorize index to bind to. - `name: string` A JavaScript variable name for the binding. - `type: "vectorize"` The kind of resource that the binding provides. - `"vectorize"` - `WorkersBindingKindVersionMetadata` - `name: string` A JavaScript variable name for the binding. - `type: "version_metadata"` The kind of resource that the binding provides. - `"version_metadata"` - `WorkersBindingKindSecretsStoreSecret` - `name: string` A JavaScript variable name for the binding. - `secret_name: string` Name of the secret in the store. - `store_id: string` ID of the store containing the secret. - `type: "secrets_store_secret"` The kind of resource that the binding provides. - `"secrets_store_secret"` - `WorkersBindingKindSecretKey` - `algorithm: unknown` Algorithm-specific key parameters. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#algorithm). - `format: "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: string` A JavaScript variable name for the binding. - `type: "secret_key"` The kind of resource that the binding provides. - `"secret_key"` - `usages: Array<"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?: string` Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki". - `key_jwk?: unknown` 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". - `WorkersBindingKindWorkflow` - `name: string` A JavaScript variable name for the binding. - `type: "workflow"` The kind of resource that the binding provides. - `"workflow"` - `workflow_name: string` Name of the Workflow to bind to. - `class_name?: string` Class name of the Workflow. Should only be provided if the Workflow belongs to this script. - `script_name?: string` Script name that contains the Workflow. If not provided, defaults to this script name. - `WorkersBindingKindWasmModule` - `name: string` A JavaScript variable name for the binding. - `part: string` The name of the file containing the WebAssembly module content. Only accepted for `service worker syntax` Workers. - `type: "wasm_module"` The kind of resource that the binding provides. - `"wasm_module"` - `WorkersBindingKindVPCService` - `name: string` A JavaScript variable name for the binding. - `service_id: string` Identifier of the VPC service to bind to. - `type: "vpc_service"` The kind of resource that the binding provides. - `"vpc_service"` - `WorkersBindingKindVPCNetwork` - `name: string` A JavaScript variable name for the binding. - `type: "vpc_network"` The kind of resource that the binding provides. - `"vpc_network"` - `network_id?: string` Identifier of the network to bind to. Only "cf1:network" is currently supported. Mutually exclusive with tunnel_id. - `tunnel_id?: string` UUID of the Cloudflare Tunnel to bind to. Mutually exclusive with network_id. - `compatibility_date?: string` Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. - `compatibility_flags?: Array` 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?: Limits` Limits to apply for this Worker. - `cpu_ms?: number` The amount of CPU time this Worker can use in milliseconds. - `logpush?: boolean` Whether Logpush is turned on for the Worker. - `migrations?: SingleStepMigration | WorkersMultipleStepMigrations` Migrations to apply for Durable Objects associated with this Worker. - `SingleStepMigration` A single set of migrations to apply. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `WorkersMultipleStepMigrations` - `new_tag?: string` Tag to set as the latest migration tag. - `old_tag?: string` Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected. - `steps?: Array` Migrations to apply in order. - `deleted_classes?: Array` A list of classes to delete Durable Object namespaces from. - `new_classes?: Array` A list of classes to create Durable Object namespaces from. - `new_sqlite_classes?: Array` A list of classes to create Durable Object namespaces with SQLite from. - `renamed_classes?: Array` A list of classes with Durable Object namespaces that were renamed. - `from?: string` - `to?: string` - `transferred_classes?: Array` A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker. - `from?: string` - `from_script?: string` - `to?: string` - `observability?: Observability` Observability settings for the Worker. - `enabled: boolean` Whether observability is enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `logs?: Logs | null` Log settings for the Worker. - `enabled: boolean` Whether logs are enabled for the Worker. - `invocation_logs: boolean` Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker. - `destinations?: Array` A list of destinations where logs will be exported to. - `head_sampling_rate?: number | null` The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether log persistence is enabled for the Worker. - `traces?: Traces | null` Trace settings for the Worker. - `destinations?: Array` A list of destinations where traces will be exported to. - `enabled?: boolean` Whether traces are enabled for the Worker. - `head_sampling_rate?: number | null` The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1. - `persist?: boolean` Whether trace persistence is enabled for the Worker. - `placement?: Mode | Region | Hostname | 5 more` Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). Specify mode='smart' for Smart Placement, or one of region/hostname/host. - `Mode` - `mode: "smart"` Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - `"smart"` - `Region` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host and port for targeted placement. - `UnionMember4` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `region: string` Cloud region for targeted placement in format 'provider:region'. - `UnionMember5` - `hostname: string` HTTP hostname for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember6` - `host: string` TCP host and port for targeted placement. - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `UnionMember7` - `mode: "targeted"` Targeted placement mode. - `"targeted"` - `target: Array` Array of placement targets (currently limited to single target). - `Region` - `region: string` Cloud region in format 'provider:region'. - `Hostname` - `hostname: string` HTTP hostname for targeted placement. - `Host` - `host: string` TCP host:port for targeted placement. - `tags?: Array | null` Tags associated with the Worker. - `tail_consumers?: Array | null` List of Workers that will consume logs from the attached Worker. - `service: string` Name of Worker that is to be the consumer. - `environment?: string` Optional environment if the Worker utilizes one. - `namespace?: string` Optional dispatch namespace the script belongs to. - `usage_model?: "standard" | "bundled" | "unbound"` Usage model for the Worker invocations. - `"standard"` - `"bundled"` - `"unbound"` # Account Settings ## Fetch Worker Account Settings `client.workers.accountSettings.get(AccountSettingGetParamsparams, RequestOptionsoptions?): AccountSettingGetResponse` **get** `/accounts/{account_id}/workers/account-settings` Fetches Worker account settings for an account. ### Parameters - `params: AccountSettingGetParams` - `account_id: string` Identifier. ### Returns - `AccountSettingGetResponse` - `default_usage_model?: string` - `green_compute?: boolean` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const accountSetting = await client.workers.accountSettings.get({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(accountSetting.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 `client.workers.accountSettings.update(AccountSettingUpdateParamsparams, RequestOptionsoptions?): AccountSettingUpdateResponse` **put** `/accounts/{account_id}/workers/account-settings` Creates Worker account settings for an account. ### Parameters - `params: AccountSettingUpdateParams` - `account_id: string` Path param: Identifier. - `default_usage_model?: string` Body param - `green_compute?: boolean` Body param ### Returns - `AccountSettingUpdateResponse` - `default_usage_model?: string` - `green_compute?: boolean` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const accountSetting = await client.workers.accountSettings.update({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(accountSetting.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 - `AccountSettingGetResponse` - `default_usage_model?: string` - `green_compute?: boolean` ### Account Setting Update Response - `AccountSettingUpdateResponse` - `default_usage_model?: string` - `green_compute?: boolean` # Domains ## List Domains `client.workers.domains.list(DomainListParamsparams, RequestOptionsoptions?): SinglePage` **get** `/accounts/{account_id}/workers/domains` Lists all domains for an account. ### Parameters - `params: DomainListParams` - `account_id: string` Path param: Identifier. - `environment?: string` Query param: Worker environment associated with the domain. - `hostname?: string` Query param: Hostname of the domain. - `service?: string` Query param: Name of the Worker associated with the domain. - `zone_id?: string` Query param: ID of the zone containing the domain hostname. - `zone_name?: string` Query param: Name of the zone containing the domain hostname. ### Returns - `DomainListResponse` - `id: string` Immutable ID of the domain. - `cert_id: string` ID of the TLS certificate issued for the domain. - `environment: string` Worker environment associated with the domain. - `hostname: string` 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: string` Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker. - `zone_id: string` ID of the zone containing the domain hostname. - `zone_name: string` Name of the zone containing the domain hostname. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const domainListResponse of client.workers.domains.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', })) { console.log(domainListResponse.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 `client.workers.domains.get(stringdomainId, DomainGetParamsparams, RequestOptionsoptions?): DomainGetResponse` **get** `/accounts/{account_id}/workers/domains/{domain_id}` Gets information about a domain. ### Parameters - `domainId: string` ID of the domain. - `params: DomainGetParams` - `account_id: string` Identifier. ### Returns - `DomainGetResponse` - `id: string` Immutable ID of the domain. - `cert_id: string` ID of the TLS certificate issued for the domain. - `environment: string` Worker environment associated with the domain. - `hostname: string` 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: string` Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker. - `zone_id: string` ID of the zone containing the domain hostname. - `zone_name: string` Name of the zone containing the domain hostname. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const domain = await client.workers.domains.get('dbe10b4bc17c295377eabd600e1787fd', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 `client.workers.domains.update(DomainUpdateParamsparams, RequestOptionsoptions?): DomainUpdateResponse` **put** `/accounts/{account_id}/workers/domains` Attaches a domain that routes traffic to a Worker. ### Parameters - `params: DomainUpdateParams` - `account_id: string` Path param: Identifier. - `hostname: string` Body param: 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: string` Body param: Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker. - `environment?: string` Body param: Worker environment associated with the domain. - `zone_id?: string` Body param: ID of the zone containing the domain hostname. - `zone_name?: string` Body param: Name of the zone containing the domain hostname. ### Returns - `DomainUpdateResponse` - `id: string` Immutable ID of the domain. - `cert_id: string` ID of the TLS certificate issued for the domain. - `environment: string` Worker environment associated with the domain. - `hostname: string` 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: string` Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker. - `zone_id: string` ID of the zone containing the domain hostname. - `zone_name: string` Name of the zone containing the domain hostname. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const domain = await client.workers.domains.update({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', hostname: 'app.example.com', service: 'my-worker', }); console.log(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 `client.workers.domains.delete(stringdomainId, DomainDeleteParamsparams, RequestOptionsoptions?): 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 - `domainId: string` ID of the domain. - `params: DomainDeleteParams` - `account_id: string` Identifier. ### Returns - `DomainDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const domain = await client.workers.domains.delete('dbe10b4bc17c295377eabd600e1787fd', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 - `DomainListResponse` - `id: string` Immutable ID of the domain. - `cert_id: string` ID of the TLS certificate issued for the domain. - `environment: string` Worker environment associated with the domain. - `hostname: string` 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: string` Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker. - `zone_id: string` ID of the zone containing the domain hostname. - `zone_name: string` Name of the zone containing the domain hostname. ### Domain Get Response - `DomainGetResponse` - `id: string` Immutable ID of the domain. - `cert_id: string` ID of the TLS certificate issued for the domain. - `environment: string` Worker environment associated with the domain. - `hostname: string` 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: string` Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker. - `zone_id: string` ID of the zone containing the domain hostname. - `zone_name: string` Name of the zone containing the domain hostname. ### Domain Update Response - `DomainUpdateResponse` - `id: string` Immutable ID of the domain. - `cert_id: string` ID of the TLS certificate issued for the domain. - `environment: string` Worker environment associated with the domain. - `hostname: string` 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: string` Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker. - `zone_id: string` ID of the zone containing the domain hostname. - `zone_name: string` Name of the zone containing the domain hostname. ### Domain Delete Response - `DomainDeleteResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` # Subdomains ## Get Subdomain `client.workers.subdomains.get(SubdomainGetParamsparams, RequestOptionsoptions?): SubdomainGetResponse` **get** `/accounts/{account_id}/workers/subdomain` Returns a Workers subdomain for an account. ### Parameters - `params: SubdomainGetParams` - `account_id: string` Identifier. ### Returns - `SubdomainGetResponse` - `subdomain: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const subdomain = await client.workers.subdomains.get({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 `client.workers.subdomains.update(SubdomainUpdateParamsparams, RequestOptionsoptions?): SubdomainUpdateResponse` **put** `/accounts/{account_id}/workers/subdomain` Creates a Workers subdomain for an account. ### Parameters - `params: SubdomainUpdateParams` - `account_id: string` Path param: Identifier. - `subdomain: string` Body param ### Returns - `SubdomainUpdateResponse` - `subdomain: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const subdomain = await client.workers.subdomains.update({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', subdomain: 'my-subdomain', }); console.log(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 `client.workers.subdomains.delete(SubdomainDeleteParamsparams, RequestOptionsoptions?): void` **delete** `/accounts/{account_id}/workers/subdomain` Deletes a Workers subdomain for an account. ### Parameters - `params: SubdomainDeleteParams` - `account_id: string` Identifier. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); await client.workers.subdomains.delete({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' }); ``` ## Domain Types ### Subdomain Get Response - `SubdomainGetResponse` - `subdomain: string` ### Subdomain Update Response - `SubdomainUpdateResponse` - `subdomain: string` # Observability # Telemetry ## List keys `client.workers.observability.telemetry.keys(TelemetryKeysParamsparams, RequestOptionsoptions?): SinglePage` **post** `/accounts/{account_id}/workers/observability/telemetry/keys` List all the keys in your telemetry events. ### Parameters - `params: TelemetryKeysParams` - `account_id: string` Path param: Your Cloudflare account ID. - `datasets?: Array` Body param: Leave this empty to use the default datasets - `filters?: Array` Body param: Apply filters to narrow key discovery. Supports nested groups via kind: 'group'. Maximum nesting depth is 4. - `UnionMember0` - `filterCombination: "and" | "or" | "AND" | "OR"` - `"and"` - `"or"` - `"AND"` - `"OR"` - `filters: Array` - `kind: "group"` - `"group"` - `WorkersObservabilityFilterLeaf` Filtering best practices: use observability_keys and observability_values to confirm available fields and values. If searching for errors, filter for $metadata.error exists. - `key: string` Filter field name. IMPORTANT: do not guess keys. Always use verified keys from previous query results or the observability_keys response. Preferred keys: $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, $metadata.error. - `operation: "includes" | "not_includes" | "starts_with" | 25 more` - `"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: "string" | "number" | "boolean"` - `"string"` - `"number"` - `"boolean"` - `kind?: "filter"` - `"filter"` - `value?: string | number | boolean` Filter comparison value. IMPORTANT: must match actual values in your logs. Verify using previous query results or the /values endpoint. Ensure value type matches the field type. String comparisons are case-sensitive unless using specific operations. Regex uses ClickHouse RE2 syntax (no lookaheads/lookbehinds); examples: ^5\d{2}$ for HTTP 5xx, \bERROR\b for word boundary. - `string` - `number` - `boolean` - `from?: number` Body param - `keyNeedle?: KeyNeedle` Body param: 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: string | number | boolean` - `string` - `number` - `boolean` - `isRegex?: boolean` - `matchCase?: boolean` - `limit?: number` Body param: Advanced usage: set limit=1000+ to retrieve comprehensive key options without needing additional filtering. - `needle?: Needle` Body param: Search for a specific substring in any of the events - `value: string | number | boolean` - `string` - `number` - `boolean` - `isRegex?: boolean` - `matchCase?: boolean` - `to?: number` Body param ### Returns - `TelemetryKeysResponse` - `key: string` - `lastSeenAt: number` - `type: "string" | "boolean" | "number"` - `"string"` - `"boolean"` - `"number"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const telemetryKeysResponse of client.workers.observability.telemetry.keys({ account_id: 'account_id', })) { console.log(telemetryKeysResponse.key); } ``` #### Response ```json { "errors": [ { "message": "message" } ], "messages": [ { "message": "Successful request" } ], "result": [ { "key": "key", "lastSeenAt": 0, "type": "string" } ], "success": true } ``` ## Run a query `client.workers.observability.telemetry.query(TelemetryQueryParamsparams, RequestOptionsoptions?): TelemetryQueryResponse` **post** `/accounts/{account_id}/workers/observability/telemetry/query` Run a temporary or saved query. ### Parameters - `params: TelemetryQueryParams` - `account_id: string` Path param: Your Cloudflare account ID. - `queryId: string` Body param: Unique identifier for the query to execute - `timeframe: Timeframe` Body param: Timeframe for your query using Unix timestamps in milliseconds. Provide from/to epoch ms; narrower timeframes provide faster responses and more specific results. - `from: number` Start timestamp for the query timeframe (Unix timestamp in milliseconds) - `to: number` End timestamp for the query timeframe (Unix timestamp in milliseconds) - `chart?: boolean` Body param: Whether to include timeseties data in the response - `compare?: boolean` Body param: Whether to include comparison data with previous time periods - `dry?: boolean` Body param: Whether to perform a dry run without saving the results of the query. Useful for validation - `granularity?: number` Body param: This is only used when the view is calculations. Leaving it empty lets Workers Observability detect the correct granularity. - `ignoreSeries?: boolean` Body param: Whether to ignore time-series data in the results and return only aggregated values - `limit?: number` Body param: Use this limit to cap the number of events returned when the view is events. - `offset?: string` Body param: Cursor pagination for event/trace/invocation views. Pass the last item's $metadata.id as the next offset. - `offsetBy?: number` Body param: Numeric offset for pattern results (top-N list). Use with limit to page pattern groups; not used by cursor pagination. - `offsetDirection?: string` Body param: Direction for offset-based pagination (e.g., 'next', 'prev') - `parameters?: Parameters` Body param: Optional parameters to pass to the query execution - `calculations?: Array` Create Calculations to compute as part of the query. - `operator: "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?: string` - `key?: string` The key to use for the calculation. This key must exist in the logs. Use the observability_keys response to confirm. Do not guess keys. - `keyType?: "string" | "number" | "boolean"` - `"string"` - `"number"` - `"boolean"` - `datasets?: Array` Set the Datasets to query. Leave it empty to query all the datasets. - `filterCombination?: "and" | "or" | "AND" | "OR"` Set a Flag to describe how to combine the filters on the query. - `"and"` - `"or"` - `"AND"` - `"OR"` - `filters?: Array` Configure the Filters to apply to the query. Supports nested groups via kind: 'group'. Maximum nesting depth is 4. - `UnionMember0` - `filterCombination: "and" | "or" | "AND" | "OR"` - `"and"` - `"or"` - `"AND"` - `"OR"` - `filters: Array` - `kind: "group"` - `"group"` - `WorkersObservabilityFilterLeaf` Filtering best practices: use observability_keys and observability_values to confirm available fields and values. If searching for errors, filter for $metadata.error exists. - `key: string` Filter field name. IMPORTANT: do not guess keys. Always use verified keys from previous query results or the observability_keys response. Preferred keys: $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, $metadata.error. - `operation: "includes" | "not_includes" | "starts_with" | 25 more` - `"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: "string" | "number" | "boolean"` - `"string"` - `"number"` - `"boolean"` - `kind?: "filter"` - `"filter"` - `value?: string | number | boolean` Filter comparison value. IMPORTANT: must match actual values in your logs. Verify using previous query results or the /values endpoint. Ensure value type matches the field type. String comparisons are case-sensitive unless using specific operations. Regex uses ClickHouse RE2 syntax (no lookaheads/lookbehinds); examples: ^5\d{2}$ for HTTP 5xx, \bERROR\b for word boundary. - `string` - `number` - `boolean` - `groupBys?: Array` Define how to group the results of the query. - `type: "string" | "number" | "boolean"` - `"string"` - `"number"` - `"boolean"` - `value: string` - `havings?: Array` Configure the Having clauses that filter on calculations in the query result. - `key: string` - `operation: "eq" | "neq" | "gt" | 3 more` - `"eq"` - `"neq"` - `"gt"` - `"gte"` - `"lt"` - `"lte"` - `value: number` - `limit?: number` Set a limit on the number of results / records returned by the query - `needle?: Needle` Define an expression to search using full-text search. - `value: string | number | boolean` - `string` - `number` - `boolean` - `isRegex?: boolean` - `matchCase?: boolean` - `orderBy?: OrderBy` Configure the order of the results returned by the query. - `value: string` Configure which Calculation to order the results by. - `order?: "asc" | "desc"` Set the order of the results - `"asc"` - `"desc"` - `view?: "traces" | "events" | "calculations" | 3 more` Body param: Examples by view type. Events: show errors for a worker in the last 30 minutes. Calculations: p99 of wall time or count by status code. Invocations: find a specific request that resulted in a 500. - `"traces"` - `"events"` - `"calculations"` - `"invocations"` - `"requests"` - `"agents"` ### Returns - `TelemetryQueryResponse` - `run: Run` A Workers Observability Query Object - `id: string` - `accountId: string` - `dry: boolean` - `granularity: number` - `query: Query` - `id: string` - `adhoc: boolean` If the query wasn't explcitly saved - `created: string` - `createdBy: string` - `description: string | null` - `name: string` Query name - `parameters: Parameters` - `calculations?: Array` Create Calculations to compute as part of the query. - `operator: "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?: string` - `key?: string` - `keyType?: "string" | "number" | "boolean"` - `"string"` - `"number"` - `"boolean"` - `datasets?: Array` Set the Datasets to query. Leave it empty to query all the datasets. - `filterCombination?: "and" | "or" | "AND" | "OR"` Set a Flag to describe how to combine the filters on the query. - `"and"` - `"or"` - `"AND"` - `"OR"` - `filters?: Array` Configure the Filters to apply to the query. Supports nested groups via kind: 'group'. - `UnionMember0` - `filterCombination: "and" | "or" | "AND" | "OR"` - `"and"` - `"or"` - `"AND"` - `"OR"` - `filters: Array` - `kind: "group"` - `"group"` - `WorkersObservabilityFilterLeaf` Filtering best practices: use observability_keys and observability_values to confirm available fields and values. If searching for errors, filter for $metadata.error exists. - `key: string` Filter field name. IMPORTANT: do not guess keys. Always use verified keys from previous query results or the observability_keys response. Preferred keys: $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, $metadata.error. - `operation: "includes" | "not_includes" | "starts_with" | 25 more` - `"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: "string" | "number" | "boolean"` - `"string"` - `"number"` - `"boolean"` - `kind?: "filter"` - `"filter"` - `value?: string | number | boolean` Filter comparison value. IMPORTANT: must match actual values in your logs. Verify using previous query results or the /values endpoint. Ensure value type matches the field type. String comparisons are case-sensitive unless using specific operations. Regex uses ClickHouse RE2 syntax (no lookaheads/lookbehinds); examples: ^5\d{2}$ for HTTP 5xx, \bERROR\b for word boundary. - `string` - `number` - `boolean` - `groupBys?: Array` Define how to group the results of the query. - `type: "string" | "number" | "boolean"` - `"string"` - `"number"` - `"boolean"` - `value: string` - `havings?: Array` Configure the Having clauses that filter on calculations in the query result. - `key: string` - `operation: "eq" | "neq" | "gt" | 3 more` - `"eq"` - `"neq"` - `"gt"` - `"gte"` - `"lt"` - `"lte"` - `value: number` - `limit?: number` Set a limit on the number of results / records returned by the query - `needle?: Needle` Define an expression to search using full-text search. - `value: Value` - `isRegex?: boolean` - `matchCase?: boolean` - `orderBy?: OrderBy` Configure the order of the results returned by the query. - `value: string` Configure which Calculation to order the results by. - `order?: "asc" | "desc"` Set the order of the results - `"asc"` - `"desc"` - `updated: string` - `updatedBy: string` - `status: "STARTED" | "COMPLETED"` - `"STARTED"` - `"COMPLETED"` - `timeframe: Timeframe` Time range for the query execution - `from: number` Start timestamp for the query timeframe (Unix timestamp in milliseconds) - `to: number` End timestamp for the query timeframe (Unix timestamp in milliseconds) - `userId: string` - `created?: string` - `statistics?: Statistics` - `bytes_read: number` Number of uncompressed bytes read from the table. - `elapsed: number` Time in seconds for the query to run. - `rows_read: number` Number of rows scanned from the table. - `abr_level?: number` The level of Adaptive Bit Rate (ABR) sampling used for the query. If empty the ABR level is 1 - `updated?: string` - `statistics: Statistics` The statistics object contains information about query performance from the database, it does not include any network latency - `bytes_read: number` Number of uncompressed bytes read from the table. - `elapsed: number` Time in seconds for the query to run. - `rows_read: number` Number of rows scanned from the table. - `abr_level?: number` The level of Adaptive Bit Rate (ABR) sampling used for the query. If empty the ABR level is 1 - `agents?: Array` - `agentClass: string` - `eventTypeCounts: Record` - `firstEventMs: number` - `hasErrors: boolean` - `lastEventMs: number` - `namespace: string` - `service: string` - `totalEvents: number` - `calculations?: Array` - `aggregates: Array` - `count: number` - `interval: number` - `sampleInterval: number` - `value: number` - `groups?: Array` - `key: string` - `value: string | number | boolean` - `string` - `number` - `boolean` - `calculation: string` - `series: Array` - `data: Array` - `count: number` - `interval: number` - `sampleInterval: number` - `value: number` - `firstSeen?: string` - `groups?: Array` - `key: string` - `value: string | number | boolean` - `string` - `number` - `boolean` - `lastSeen?: string` - `time: string` - `alias?: string` - `compare?: Array` - `aggregates: Array` - `count: number` - `interval: number` - `sampleInterval: number` - `value: number` - `groups?: Array` - `key: string` - `value: string | number | boolean` - `string` - `number` - `boolean` - `calculation: string` - `series: Array` - `data: Array` - `count: number` - `interval: number` - `sampleInterval: number` - `value: number` - `firstSeen?: string` - `groups?: Array` - `key: string` - `value: string | number | boolean` - `string` - `number` - `boolean` - `lastSeen?: string` - `time: string` - `alias?: string` - `events?: Events` - `count?: number` - `events?: Array` - `"$metadata": Metadata` - `id: string` Unique event ID. Use as the cursor for offset-based pagination. - `account?: string` - `cloudService?: string` - `coldStart?: number` - `cost?: number` - `duration?: number` - `endTime?: number` - `error?: string` - `errorTemplate?: string` - `fingerprint?: string` - `level?: string` - `message?: string` - `messageTemplate?: string` - `metricName?: string` - `origin?: string` - `parentSpanId?: string` - `provider?: string` - `region?: string` - `requestId?: string` - `service?: string` - `spanId?: string` - `spanName?: string` - `stackId?: string` - `startTime?: number` - `statusCode?: number` - `traceDuration?: number` - `traceId?: string` - `transactionName?: string` - `trigger?: string` - `type?: string` - `url?: string` - `dataset: string` - `source: string | unknown` - `string` - `unknown` - `timestamp: number` - `"$containers"?: unknown` Cloudflare Containers event information enriches your logs so you can easily identify and debug issues. - `"$workers"?: UnionMember0 | UnionMember1` Cloudflare Workers event information enriches your logs so you can easily identify and debug issues. - `UnionMember0` - `eventType: "fetch" | "scheduled" | "alarm" | 8 more` - `"fetch"` - `"scheduled"` - `"alarm"` - `"cron"` - `"queue"` - `"email"` - `"tail"` - `"rpc"` - `"websocket"` - `"workflow"` - `"unknown"` - `requestId: string` - `scriptName: string` - `durableObjectId?: string` - `entrypoint?: string` - `event?: Record` - `executionModel?: "durableObject" | "stateless"` - `"durableObject"` - `"stateless"` - `outcome?: string` - `scriptVersion?: ScriptVersion` - `id?: string` - `message?: string` - `tag?: string` - `truncated?: boolean` - `UnionMember1` - `cpuTimeMs: number` - `eventType: "fetch" | "scheduled" | "alarm" | 8 more` - `"fetch"` - `"scheduled"` - `"alarm"` - `"cron"` - `"queue"` - `"email"` - `"tail"` - `"rpc"` - `"websocket"` - `"workflow"` - `"unknown"` - `outcome: string` - `requestId: string` - `scriptName: string` - `wallTimeMs: number` - `diagnosticsChannelEvents?: Array` - `channel: string` - `message: string` - `timestamp: number` - `dispatchNamespace?: string` - `durableObjectId?: string` - `entrypoint?: string` - `event?: Record` - `executionModel?: "durableObject" | "stateless"` - `"durableObject"` - `"stateless"` - `scriptVersion?: ScriptVersion` - `id?: string` - `message?: string` - `tag?: string` - `truncated?: boolean` - `fields?: Array` - `key: string` - `type: string` - `series?: Array` - `data: Array` - `aggregates: Aggregates` - `_count: number` - `_interval: number` - `_firstSeen?: string` - `_lastSeen?: string` - `bin?: unknown` - `count: number` - `interval: number` - `sampleInterval: number` - `errors?: number` - `groups?: Record` Groups in the query results. - `string` - `number` - `boolean` - `time: string` - `invocations?: Record>` - `"$metadata": Metadata` - `id: string` Unique event ID. Use as the cursor for offset-based pagination. - `account?: string` - `cloudService?: string` - `coldStart?: number` - `cost?: number` - `duration?: number` - `endTime?: number` - `error?: string` - `errorTemplate?: string` - `fingerprint?: string` - `level?: string` - `message?: string` - `messageTemplate?: string` - `metricName?: string` - `origin?: string` - `parentSpanId?: string` - `provider?: string` - `region?: string` - `requestId?: string` - `service?: string` - `spanId?: string` - `spanName?: string` - `stackId?: string` - `startTime?: number` - `statusCode?: number` - `traceDuration?: number` - `traceId?: string` - `transactionName?: string` - `trigger?: string` - `type?: string` - `url?: string` - `dataset: string` - `source: string | unknown` - `string` - `unknown` - `timestamp: number` - `"$containers"?: unknown` Cloudflare Containers event information enriches your logs so you can easily identify and debug issues. - `"$workers"?: UnionMember0 | UnionMember1` Cloudflare Workers event information enriches your logs so you can easily identify and debug issues. - `UnionMember0` - `eventType: "fetch" | "scheduled" | "alarm" | 8 more` - `"fetch"` - `"scheduled"` - `"alarm"` - `"cron"` - `"queue"` - `"email"` - `"tail"` - `"rpc"` - `"websocket"` - `"workflow"` - `"unknown"` - `requestId: string` - `scriptName: string` - `durableObjectId?: string` - `entrypoint?: string` - `event?: Record` - `executionModel?: "durableObject" | "stateless"` - `"durableObject"` - `"stateless"` - `outcome?: string` - `scriptVersion?: ScriptVersion` - `id?: string` - `message?: string` - `tag?: string` - `truncated?: boolean` - `UnionMember1` - `cpuTimeMs: number` - `eventType: "fetch" | "scheduled" | "alarm" | 8 more` - `"fetch"` - `"scheduled"` - `"alarm"` - `"cron"` - `"queue"` - `"email"` - `"tail"` - `"rpc"` - `"websocket"` - `"workflow"` - `"unknown"` - `outcome: string` - `requestId: string` - `scriptName: string` - `wallTimeMs: number` - `diagnosticsChannelEvents?: Array` - `channel: string` - `message: string` - `timestamp: number` - `dispatchNamespace?: string` - `durableObjectId?: string` - `entrypoint?: string` - `event?: Record` - `executionModel?: "durableObject" | "stateless"` - `"durableObject"` - `"stateless"` - `scriptVersion?: ScriptVersion` - `id?: string` - `message?: string` - `tag?: string` - `truncated?: boolean` - `traces?: Array` - `rootSpanName: string` - `rootTransactionName: string` - `service: Array` - `spans: number` - `traceDurationMs: number` - `traceEndMs: number` - `traceId: string` - `traceStartMs: number` - `errors?: Array` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted }); const response = await client.workers.observability.telemetry.query({ account_id: 'account_id', queryId: 'queryId', timeframe: { from: 0, to: 0 }, }); console.log(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" }, "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" }, "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 `client.workers.observability.telemetry.values(TelemetryValuesParamsparams, RequestOptionsoptions?): SinglePage` **post** `/accounts/{account_id}/workers/observability/telemetry/values` List unique values found in your events. ### Parameters - `params: TelemetryValuesParams` - `account_id: string` Path param: Your Cloudflare account ID. - `datasets: Array` Body param: Leave this empty to use the default datasets - `key: string` Body param - `timeframe: Timeframe` Body param - `from: number` - `to: number` - `type: "string" | "boolean" | "number"` Body param - `"string"` - `"boolean"` - `"number"` - `filters?: Array` Body param: Apply filters before listing values. Supports nested groups via kind: 'group'. Maximum nesting depth is 4. - `UnionMember0` - `filterCombination: "and" | "or" | "AND" | "OR"` - `"and"` - `"or"` - `"AND"` - `"OR"` - `filters: Array` - `kind: "group"` - `"group"` - `WorkersObservabilityFilterLeaf` Filtering best practices: use observability_keys and observability_values to confirm available fields and values. If searching for errors, filter for $metadata.error exists. - `key: string` Filter field name. IMPORTANT: do not guess keys. Always use verified keys from previous query results or the observability_keys response. Preferred keys: $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, $metadata.error. - `operation: "includes" | "not_includes" | "starts_with" | 25 more` - `"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: "string" | "number" | "boolean"` - `"string"` - `"number"` - `"boolean"` - `kind?: "filter"` - `"filter"` - `value?: string | number | boolean` Filter comparison value. IMPORTANT: must match actual values in your logs. Verify using previous query results or the /values endpoint. Ensure value type matches the field type. String comparisons are case-sensitive unless using specific operations. Regex uses ClickHouse RE2 syntax (no lookaheads/lookbehinds); examples: ^5\d{2}$ for HTTP 5xx, \bERROR\b for word boundary. - `string` - `number` - `boolean` - `limit?: number` Body param - `needle?: Needle` Body param: Search for a specific substring in the event. - `value: string | number | boolean` - `string` - `number` - `boolean` - `isRegex?: boolean` - `matchCase?: boolean` ### Returns - `TelemetryValuesResponse` - `dataset: string` - `key: string` - `type: "string" | "boolean" | "number"` - `"string"` - `"boolean"` - `"number"` - `value: string | number | boolean` - `string` - `number` - `boolean` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const telemetryValuesResponse of client.workers.observability.telemetry.values({ account_id: 'account_id', datasets: ['string'], key: 'key', timeframe: { from: 0, to: 0 }, type: 'string', })) { console.log(telemetryValuesResponse.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 - `TelemetryKeysResponse` - `key: string` - `lastSeenAt: number` - `type: "string" | "boolean" | "number"` - `"string"` - `"boolean"` - `"number"` ### Telemetry Query Response - `TelemetryQueryResponse` - `run: Run` A Workers Observability Query Object - `id: string` - `accountId: string` - `dry: boolean` - `granularity: number` - `query: Query` - `id: string` - `adhoc: boolean` If the query wasn't explcitly saved - `created: string` - `createdBy: string` - `description: string | null` - `name: string` Query name - `parameters: Parameters` - `calculations?: Array` Create Calculations to compute as part of the query. - `operator: "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?: string` - `key?: string` - `keyType?: "string" | "number" | "boolean"` - `"string"` - `"number"` - `"boolean"` - `datasets?: Array` Set the Datasets to query. Leave it empty to query all the datasets. - `filterCombination?: "and" | "or" | "AND" | "OR"` Set a Flag to describe how to combine the filters on the query. - `"and"` - `"or"` - `"AND"` - `"OR"` - `filters?: Array` Configure the Filters to apply to the query. Supports nested groups via kind: 'group'. - `UnionMember0` - `filterCombination: "and" | "or" | "AND" | "OR"` - `"and"` - `"or"` - `"AND"` - `"OR"` - `filters: Array` - `kind: "group"` - `"group"` - `WorkersObservabilityFilterLeaf` Filtering best practices: use observability_keys and observability_values to confirm available fields and values. If searching for errors, filter for $metadata.error exists. - `key: string` Filter field name. IMPORTANT: do not guess keys. Always use verified keys from previous query results or the observability_keys response. Preferred keys: $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, $metadata.error. - `operation: "includes" | "not_includes" | "starts_with" | 25 more` - `"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: "string" | "number" | "boolean"` - `"string"` - `"number"` - `"boolean"` - `kind?: "filter"` - `"filter"` - `value?: string | number | boolean` Filter comparison value. IMPORTANT: must match actual values in your logs. Verify using previous query results or the /values endpoint. Ensure value type matches the field type. String comparisons are case-sensitive unless using specific operations. Regex uses ClickHouse RE2 syntax (no lookaheads/lookbehinds); examples: ^5\d{2}$ for HTTP 5xx, \bERROR\b for word boundary. - `string` - `number` - `boolean` - `groupBys?: Array` Define how to group the results of the query. - `type: "string" | "number" | "boolean"` - `"string"` - `"number"` - `"boolean"` - `value: string` - `havings?: Array` Configure the Having clauses that filter on calculations in the query result. - `key: string` - `operation: "eq" | "neq" | "gt" | 3 more` - `"eq"` - `"neq"` - `"gt"` - `"gte"` - `"lt"` - `"lte"` - `value: number` - `limit?: number` Set a limit on the number of results / records returned by the query - `needle?: Needle` Define an expression to search using full-text search. - `value: Value` - `isRegex?: boolean` - `matchCase?: boolean` - `orderBy?: OrderBy` Configure the order of the results returned by the query. - `value: string` Configure which Calculation to order the results by. - `order?: "asc" | "desc"` Set the order of the results - `"asc"` - `"desc"` - `updated: string` - `updatedBy: string` - `status: "STARTED" | "COMPLETED"` - `"STARTED"` - `"COMPLETED"` - `timeframe: Timeframe` Time range for the query execution - `from: number` Start timestamp for the query timeframe (Unix timestamp in milliseconds) - `to: number` End timestamp for the query timeframe (Unix timestamp in milliseconds) - `userId: string` - `created?: string` - `statistics?: Statistics` - `bytes_read: number` Number of uncompressed bytes read from the table. - `elapsed: number` Time in seconds for the query to run. - `rows_read: number` Number of rows scanned from the table. - `abr_level?: number` The level of Adaptive Bit Rate (ABR) sampling used for the query. If empty the ABR level is 1 - `updated?: string` - `statistics: Statistics` The statistics object contains information about query performance from the database, it does not include any network latency - `bytes_read: number` Number of uncompressed bytes read from the table. - `elapsed: number` Time in seconds for the query to run. - `rows_read: number` Number of rows scanned from the table. - `abr_level?: number` The level of Adaptive Bit Rate (ABR) sampling used for the query. If empty the ABR level is 1 - `agents?: Array` - `agentClass: string` - `eventTypeCounts: Record` - `firstEventMs: number` - `hasErrors: boolean` - `lastEventMs: number` - `namespace: string` - `service: string` - `totalEvents: number` - `calculations?: Array` - `aggregates: Array` - `count: number` - `interval: number` - `sampleInterval: number` - `value: number` - `groups?: Array` - `key: string` - `value: string | number | boolean` - `string` - `number` - `boolean` - `calculation: string` - `series: Array` - `data: Array` - `count: number` - `interval: number` - `sampleInterval: number` - `value: number` - `firstSeen?: string` - `groups?: Array` - `key: string` - `value: string | number | boolean` - `string` - `number` - `boolean` - `lastSeen?: string` - `time: string` - `alias?: string` - `compare?: Array` - `aggregates: Array` - `count: number` - `interval: number` - `sampleInterval: number` - `value: number` - `groups?: Array` - `key: string` - `value: string | number | boolean` - `string` - `number` - `boolean` - `calculation: string` - `series: Array` - `data: Array` - `count: number` - `interval: number` - `sampleInterval: number` - `value: number` - `firstSeen?: string` - `groups?: Array` - `key: string` - `value: string | number | boolean` - `string` - `number` - `boolean` - `lastSeen?: string` - `time: string` - `alias?: string` - `events?: Events` - `count?: number` - `events?: Array` - `"$metadata": Metadata` - `id: string` Unique event ID. Use as the cursor for offset-based pagination. - `account?: string` - `cloudService?: string` - `coldStart?: number` - `cost?: number` - `duration?: number` - `endTime?: number` - `error?: string` - `errorTemplate?: string` - `fingerprint?: string` - `level?: string` - `message?: string` - `messageTemplate?: string` - `metricName?: string` - `origin?: string` - `parentSpanId?: string` - `provider?: string` - `region?: string` - `requestId?: string` - `service?: string` - `spanId?: string` - `spanName?: string` - `stackId?: string` - `startTime?: number` - `statusCode?: number` - `traceDuration?: number` - `traceId?: string` - `transactionName?: string` - `trigger?: string` - `type?: string` - `url?: string` - `dataset: string` - `source: string | unknown` - `string` - `unknown` - `timestamp: number` - `"$containers"?: unknown` Cloudflare Containers event information enriches your logs so you can easily identify and debug issues. - `"$workers"?: UnionMember0 | UnionMember1` Cloudflare Workers event information enriches your logs so you can easily identify and debug issues. - `UnionMember0` - `eventType: "fetch" | "scheduled" | "alarm" | 8 more` - `"fetch"` - `"scheduled"` - `"alarm"` - `"cron"` - `"queue"` - `"email"` - `"tail"` - `"rpc"` - `"websocket"` - `"workflow"` - `"unknown"` - `requestId: string` - `scriptName: string` - `durableObjectId?: string` - `entrypoint?: string` - `event?: Record` - `executionModel?: "durableObject" | "stateless"` - `"durableObject"` - `"stateless"` - `outcome?: string` - `scriptVersion?: ScriptVersion` - `id?: string` - `message?: string` - `tag?: string` - `truncated?: boolean` - `UnionMember1` - `cpuTimeMs: number` - `eventType: "fetch" | "scheduled" | "alarm" | 8 more` - `"fetch"` - `"scheduled"` - `"alarm"` - `"cron"` - `"queue"` - `"email"` - `"tail"` - `"rpc"` - `"websocket"` - `"workflow"` - `"unknown"` - `outcome: string` - `requestId: string` - `scriptName: string` - `wallTimeMs: number` - `diagnosticsChannelEvents?: Array` - `channel: string` - `message: string` - `timestamp: number` - `dispatchNamespace?: string` - `durableObjectId?: string` - `entrypoint?: string` - `event?: Record` - `executionModel?: "durableObject" | "stateless"` - `"durableObject"` - `"stateless"` - `scriptVersion?: ScriptVersion` - `id?: string` - `message?: string` - `tag?: string` - `truncated?: boolean` - `fields?: Array` - `key: string` - `type: string` - `series?: Array` - `data: Array` - `aggregates: Aggregates` - `_count: number` - `_interval: number` - `_firstSeen?: string` - `_lastSeen?: string` - `bin?: unknown` - `count: number` - `interval: number` - `sampleInterval: number` - `errors?: number` - `groups?: Record` Groups in the query results. - `string` - `number` - `boolean` - `time: string` - `invocations?: Record>` - `"$metadata": Metadata` - `id: string` Unique event ID. Use as the cursor for offset-based pagination. - `account?: string` - `cloudService?: string` - `coldStart?: number` - `cost?: number` - `duration?: number` - `endTime?: number` - `error?: string` - `errorTemplate?: string` - `fingerprint?: string` - `level?: string` - `message?: string` - `messageTemplate?: string` - `metricName?: string` - `origin?: string` - `parentSpanId?: string` - `provider?: string` - `region?: string` - `requestId?: string` - `service?: string` - `spanId?: string` - `spanName?: string` - `stackId?: string` - `startTime?: number` - `statusCode?: number` - `traceDuration?: number` - `traceId?: string` - `transactionName?: string` - `trigger?: string` - `type?: string` - `url?: string` - `dataset: string` - `source: string | unknown` - `string` - `unknown` - `timestamp: number` - `"$containers"?: unknown` Cloudflare Containers event information enriches your logs so you can easily identify and debug issues. - `"$workers"?: UnionMember0 | UnionMember1` Cloudflare Workers event information enriches your logs so you can easily identify and debug issues. - `UnionMember0` - `eventType: "fetch" | "scheduled" | "alarm" | 8 more` - `"fetch"` - `"scheduled"` - `"alarm"` - `"cron"` - `"queue"` - `"email"` - `"tail"` - `"rpc"` - `"websocket"` - `"workflow"` - `"unknown"` - `requestId: string` - `scriptName: string` - `durableObjectId?: string` - `entrypoint?: string` - `event?: Record` - `executionModel?: "durableObject" | "stateless"` - `"durableObject"` - `"stateless"` - `outcome?: string` - `scriptVersion?: ScriptVersion` - `id?: string` - `message?: string` - `tag?: string` - `truncated?: boolean` - `UnionMember1` - `cpuTimeMs: number` - `eventType: "fetch" | "scheduled" | "alarm" | 8 more` - `"fetch"` - `"scheduled"` - `"alarm"` - `"cron"` - `"queue"` - `"email"` - `"tail"` - `"rpc"` - `"websocket"` - `"workflow"` - `"unknown"` - `outcome: string` - `requestId: string` - `scriptName: string` - `wallTimeMs: number` - `diagnosticsChannelEvents?: Array` - `channel: string` - `message: string` - `timestamp: number` - `dispatchNamespace?: string` - `durableObjectId?: string` - `entrypoint?: string` - `event?: Record` - `executionModel?: "durableObject" | "stateless"` - `"durableObject"` - `"stateless"` - `scriptVersion?: ScriptVersion` - `id?: string` - `message?: string` - `tag?: string` - `truncated?: boolean` - `traces?: Array` - `rootSpanName: string` - `rootTransactionName: string` - `service: Array` - `spans: number` - `traceDurationMs: number` - `traceEndMs: number` - `traceId: string` - `traceStartMs: number` - `errors?: Array` ### Telemetry Values Response - `TelemetryValuesResponse` - `dataset: string` - `key: string` - `type: "string" | "boolean" | "number"` - `"string"` - `"boolean"` - `"number"` - `value: string | number | boolean` - `string` - `number` - `boolean` # Destinations ## Get Destinations `client.workers.observability.destinations.list(DestinationListParamsparams, RequestOptionsoptions?): SinglePage` **get** `/accounts/{account_id}/workers/observability/destinations` List your Workers Observability Telemetry Destinations. ### Parameters - `params: DestinationListParams` - `account_id: string` Path param: Your Cloudflare account ID. - `order?: "asc" | "desc"` Query param - `"asc"` - `"desc"` - `orderBy?: "created" | "updated"` Query param - `"created"` - `"updated"` - `page?: number` Query param - `perPage?: number` Query param ### Returns - `DestinationListResponse` - `configuration: Configuration` - `destination_conf: string` - `headers: Record` - `jobStatus: JobStatus` - `error_message: string` - `last_complete: string` - `last_error: string` - `logpushDataset: "opentelemetry-traces" | "opentelemetry-logs"` - `"opentelemetry-traces"` - `"opentelemetry-logs"` - `type: "logpush"` - `"logpush"` - `url: string` - `enabled: boolean` - `name: string` - `scripts: Array` - `slug: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const destinationListResponse of client.workers.observability.destinations.list({ account_id: 'account_id', })) { console.log(destinationListResponse.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 `client.workers.observability.destinations.create(DestinationCreateParamsparams, RequestOptionsoptions?): DestinationCreateResponse` **post** `/accounts/{account_id}/workers/observability/destinations` Create a new Workers Observability Telemetry Destination. ### Parameters - `params: DestinationCreateParams` - `account_id: string` Path param: Your Cloudflare account ID. - `configuration: Configuration` Body param - `headers: Record` - `logpushDataset: "opentelemetry-traces" | "opentelemetry-logs"` - `"opentelemetry-traces"` - `"opentelemetry-logs"` - `type: "logpush"` - `"logpush"` - `url: string` - `enabled: boolean` Body param - `name: string` Body param - `skipPreflightCheck?: boolean` Body param ### Returns - `DestinationCreateResponse` - `configuration: Configuration` - `destination_conf: string` - `logpushDataset: "opentelemetry-traces" | "opentelemetry-logs"` - `"opentelemetry-traces"` - `"opentelemetry-logs"` - `logpushJob: number` - `type: "logpush"` - `"logpush"` - `url: string` - `enabled: boolean` - `name: string` - `scripts: Array` - `slug: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted }); const destination = await client.workers.observability.destinations.create({ account_id: 'account_id', configuration: { headers: { foo: 'string' }, logpushDataset: 'opentelemetry-traces', type: 'logpush', url: 'url', }, enabled: true, name: 'name', }); console.log(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 `client.workers.observability.destinations.update(stringslug, DestinationUpdateParamsparams, RequestOptionsoptions?): DestinationUpdateResponse` **patch** `/accounts/{account_id}/workers/observability/destinations/{slug}` Update an existing Workers Observability Telemetry Destination. ### Parameters - `slug: string` - `params: DestinationUpdateParams` - `account_id: string` Path param: Your Cloudflare account ID. - `configuration: Configuration` Body param - `headers: Record` - `type: "logpush"` - `"logpush"` - `url: string` - `enabled: boolean` Body param ### Returns - `DestinationUpdateResponse` - `configuration: Configuration` - `destination_conf: string` - `logpushDataset: "opentelemetry-traces" | "opentelemetry-logs"` - `"opentelemetry-traces"` - `"opentelemetry-logs"` - `logpushJob: number` - `type: "logpush"` - `"logpush"` - `url: string` - `enabled: boolean` - `name: string` - `scripts: Array` - `slug: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted }); const destination = await client.workers.observability.destinations.update('slug', { account_id: 'account_id', configuration: { headers: { foo: 'string' }, type: 'logpush', url: 'url', }, enabled: true, }); console.log(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 `client.workers.observability.destinations.delete(stringslug, DestinationDeleteParamsparams, RequestOptionsoptions?): DestinationDeleteResponse` **delete** `/accounts/{account_id}/workers/observability/destinations/{slug}` Delete a Workers Observability Telemetry Destination. ### Parameters - `slug: string` - `params: DestinationDeleteParams` - `account_id: string` Your Cloudflare account ID. ### Returns - `DestinationDeleteResponse` - `configuration: Configuration` - `destination_conf: string` - `logpushDataset: "opentelemetry-traces" | "opentelemetry-logs"` - `"opentelemetry-traces"` - `"opentelemetry-logs"` - `logpushJob: number` - `type: "logpush"` - `"logpush"` - `url: string` - `enabled: boolean` - `name: string` - `scripts: Array` - `slug: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted }); const destination = await client.workers.observability.destinations.delete('slug', { account_id: 'account_id', }); console.log(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 - `DestinationListResponse` - `configuration: Configuration` - `destination_conf: string` - `headers: Record` - `jobStatus: JobStatus` - `error_message: string` - `last_complete: string` - `last_error: string` - `logpushDataset: "opentelemetry-traces" | "opentelemetry-logs"` - `"opentelemetry-traces"` - `"opentelemetry-logs"` - `type: "logpush"` - `"logpush"` - `url: string` - `enabled: boolean` - `name: string` - `scripts: Array` - `slug: string` ### Destination Create Response - `DestinationCreateResponse` - `configuration: Configuration` - `destination_conf: string` - `logpushDataset: "opentelemetry-traces" | "opentelemetry-logs"` - `"opentelemetry-traces"` - `"opentelemetry-logs"` - `logpushJob: number` - `type: "logpush"` - `"logpush"` - `url: string` - `enabled: boolean` - `name: string` - `scripts: Array` - `slug: string` ### Destination Update Response - `DestinationUpdateResponse` - `configuration: Configuration` - `destination_conf: string` - `logpushDataset: "opentelemetry-traces" | "opentelemetry-logs"` - `"opentelemetry-traces"` - `"opentelemetry-logs"` - `logpushJob: number` - `type: "logpush"` - `"logpush"` - `url: string` - `enabled: boolean` - `name: string` - `scripts: Array` - `slug: string` ### Destination Delete Response - `DestinationDeleteResponse` - `configuration: Configuration` - `destination_conf: string` - `logpushDataset: "opentelemetry-traces" | "opentelemetry-logs"` - `"opentelemetry-traces"` - `"opentelemetry-logs"` - `logpushJob: number` - `type: "logpush"` - `"logpush"` - `url: string` - `enabled: boolean` - `name: string` - `scripts: Array` - `slug: string`