Skip to content
Start here

Get Zone Precursor Config

client.precursor.get(PrecursorGetParams { zone_id } params, RequestOptionsoptions?): PrecursorConfig { default_mode, enforcement_rules }
GET/zones/{zone_id}/precursor

Retrieve a zone’s Precursor configuration: the zone-level default_mode and the ordered list of enforcement_rules.

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
ParametersExpand Collapse
params: PrecursorGetParams { zone_id }
zone_id: string

Identifier.

maxLength32
ReturnsExpand Collapse
PrecursorConfig { default_mode, enforcement_rules }
default_mode?: "off" | "min-friction" | "max-security"

The zone-level Precursor enforcement mode applied to requests that do not match a more specific enforcement rule.

One of the following:
"off"
"min-friction"
"max-security"
enforcement_rules?: Array<EnforcementRule { expression, mode, id, 2 more } >

The ordered list of enforcement rules for the zone.

expression: string

The filter expression that determines which requests the rule matches.

mode: "min-friction" | "max-security"

The override mode Precursor applies to requests matching an enforcement rule. Unlike default_mode, this cannot be off.

One of the following:
"min-friction"
"max-security"
id?: string

The read-only identifier that Cloudflare assigns to the rule.

description?: string

An informative description of the rule.

enabled?: boolean

Whether the rule is active.

Get Zone Precursor Config

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const precursorConfig = await client.precursor.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });

console.log(precursorConfig.default_mode);
{
  "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": {
    "default_mode": "min-friction",
    "enforcement_rules": [
      {
        "expression": "http.request.uri.path eq \"/shop\"",
        "mode": "max-security",
        "id": "3a03d665bac043e3a684e0d385a4b1e2",
        "description": "Enforce max-security on the shop page",
        "enabled": 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"
      }
    }
  ],
  "success": true,
  "result": {
    "default_mode": "min-friction",
    "enforcement_rules": [
      {
        "expression": "http.request.uri.path eq \"/shop\"",
        "mode": "max-security",
        "id": "3a03d665bac043e3a684e0d385a4b1e2",
        "description": "Enforce max-security on the shop page",
        "enabled": true
      }
    ]
  }
}