Update Zone Precursor Config
client.precursor.update(PrecursorUpdateParams { zone_id, default_mode, enforcement_rules } params, RequestOptionsoptions?): PrecursorConfig { default_mode, enforcement_rules }
PUT/zones/{zone_id}/precursor
Updates the Precursor configuration for a zone.
default_mode sets the zone-level enforcement mode. enforcement_rules
is the ordered list of rules that override enforcement for matching
requests.
This is a partial update: only the fields present in the request body are changed.
- Sending an empty array (
[]) clears all enforcement rules. - At least one of
default_modeorenforcement_rulesmust be present; an empty body ({}) is rejected with400. - Rule
idis read-only (assigned by Cloudflare) and ignored on input. - Rule
modemust bemin-frictionormax-security(offis not a valid rule mode; usedefault_modeto disable enforcement).
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:
Update 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.update({
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
default_mode: 'min-friction',
});
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
}
]
}
}