Skip to content
Start here

Patch Script Settings

PATCH/accounts/{account_id}/workers/scripts/{script_name}/script-settings

Patch script-level settings when using Worker Versions. Including but not limited to Logpush and Tail Consumers.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Workers Scripts Write
Path ParametersExpand Collapse
account_id: string

Identifier.

maxLength32
script_name: string

Name of the script, used in URLs and route configuration.

Body ParametersJSONExpand Collapse
logpush: optional boolean

Whether Logpush is turned on for the Worker.

observability: optional { enabled, head_sampling_rate, logs, traces }

Observability settings for the Worker.

enabled: boolean

Whether observability is enabled for the Worker.

head_sampling_rate: optional number

The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

logs: optional { enabled, invocation_logs, destinations, 2 more }

Log settings for the Worker.

enabled: boolean

Whether logs are enabled for the Worker.

invocation_logs: boolean

Whether invocation logs are enabled for the Worker.

destinations: optional array of string

A list of destinations where logs will be exported to.

head_sampling_rate: optional number

The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

persist: optional boolean

Whether log persistence is enabled for the Worker.

traces: optional { destinations, enabled, head_sampling_rate, persist }

Trace settings for the Worker.

destinations: optional array of string

A list of destinations where traces will be exported to.

enabled: optional boolean

Whether traces are enabled for the Worker.

head_sampling_rate: optional number

The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

persist: optional boolean

Whether trace persistence is enabled for the Worker.

tags: optional array of string

Tags associated with the Worker.

tail_consumers: optional array of ConsumerScript { service, environment, namespace }

List of Workers that will consume logs from the attached Worker.

service: string

Name of Worker that is to be the consumer.

environment: optional string

Optional environment if the Worker utilizes one.

namespace: optional string

Optional dispatch namespace the script belongs to.

ReturnsExpand Collapse
errors: array of { code, message, documentation_url, source }
code: number
minimum1000
message: string
documentation_url: optional string
source: optional { pointer }
pointer: optional string
messages: array of { code, message, documentation_url, source }
code: number
minimum1000
message: string
documentation_url: optional string
source: optional { pointer }
pointer: optional string
result: ScriptSetting { logpush, observability, tags, tail_consumers }
logpush: optional boolean

Whether Logpush is turned on for the Worker.

observability: optional { enabled, head_sampling_rate, logs, traces }

Observability settings for the Worker.

enabled: boolean

Whether observability is enabled for the Worker.

head_sampling_rate: optional number

The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

logs: optional { enabled, invocation_logs, destinations, 2 more }

Log settings for the Worker.

enabled: boolean

Whether logs are enabled for the Worker.

invocation_logs: boolean

Whether invocation logs are enabled for the Worker.

destinations: optional array of string

A list of destinations where logs will be exported to.

head_sampling_rate: optional number

The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

persist: optional boolean

Whether log persistence is enabled for the Worker.

traces: optional { destinations, enabled, head_sampling_rate, persist }

Trace settings for the Worker.

destinations: optional array of string

A list of destinations where traces will be exported to.

enabled: optional boolean

Whether traces are enabled for the Worker.

head_sampling_rate: optional number

The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

persist: optional boolean

Whether trace persistence is enabled for the Worker.

tags: optional array of string

Tags associated with the Worker.

tail_consumers: optional array of ConsumerScript { service, environment, namespace }

List of Workers that will consume logs from the attached Worker.

service: string

Name of Worker that is to be the consumer.

environment: optional string

Optional environment if the Worker utilizes one.

namespace: optional string

Optional dispatch namespace the script belongs to.

success: true

Whether the API call was successful.

Patch Script Settings

curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/scripts/$SCRIPT_NAME/script-settings \
    -X PATCH \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    -d '{
          "tags": [
            "my-team",
            "my-public-api"
          ]
        }'
{
  "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
}
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": {
    "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
}