Skip to content
Start here

Get Script Settings

client.workers.scripts.settings.get(stringscriptName, SettingGetParams { account_id } params, RequestOptionsoptions?): ScriptSetting { logpush, observability, tags, tail_consumers }
GET/accounts/{account_id}/workers/scripts/{script_name}/script-settings

Get script-level settings when using Worker Versions. Includes 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 Tail ReadWorkers Scripts WriteWorkers Scripts Read
ParametersExpand Collapse
scriptName: string

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

params: SettingGetParams { account_id }
account_id: string

Identifier.

maxLength32
ReturnsExpand Collapse
ScriptSetting { logpush, observability, tags, tail_consumers }
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 are enabled for the Worker.

destinations?: Array<string>

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.

redact_query_string?: boolean

Whether query strings are removed from request URLs in logs and traces.

traces?: Traces | null

Trace settings for the Worker.

destinations?: Array<string>

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.

propagation_policy?: "authenticated" | "accept" | null

Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. “authenticated” honors inbound trace context only when accompanied by a valid trace auth token. “accept” unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled. Returns null when the trace propagation feature is not enabled for the account.

One of the following:
"authenticated"
"accept"
tags?: Array<string> | null

Tags associated with the Worker.

tail_consumers?: Array<ConsumerScript { service, environment, namespace } > | 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.

Get Script Settings

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);
{
  "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
      },
      "redact_query_string": false,
      "traces": {
        "destinations": [
          "cloudflare"
        ],
        "enabled": true,
        "head_sampling_rate": 0.1,
        "persist": true,
        "propagation_policy": "authenticated"
      }
    },
    "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
      },
      "redact_query_string": false,
      "traces": {
        "destinations": [
          "cloudflare"
        ],
        "enabled": true,
        "head_sampling_rate": 0.1,
        "persist": true,
        "propagation_policy": "authenticated"
      }
    },
    "tags": [
      "my-team",
      "my-public-api"
    ],
    "tail_consumers": [
      {
        "service": "my-log-consumer",
        "environment": "production",
        "namespace": "my-namespace"
      }
    ]
  },
  "success": true
}