Update Worker
client.Workers.Beta.Workers.Update(ctx, workerID, params) (*Worker, error)
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.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
Update Worker
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/workers"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
worker, err := client.Workers.Beta.Workers.Update(
context.TODO(),
"worker_id",
workers.BetaWorkerUpdateParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Worker: workers.WorkerParam{
Logpush: cloudflare.F(true),
Name: cloudflare.F("my-worker"),
Observability: cloudflare.F(workers.WorkerObservabilityParam{
}),
Subdomain: cloudflare.F(workers.WorkerSubdomainParam{
}),
Tags: cloudflare.F([]string{"my-team", "my-public-api"}),
TailConsumers: cloudflare.F([]workers.WorkerTailConsumerParam{workers.WorkerTailConsumerParam{
Name: cloudflare.F("my-tail-consumer"),
}}),
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", worker.ID)
}
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"id": "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
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"id": "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
}