---
title: Update Zone Precursor Config
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/python)

[Precursor](https://developers.cloudflare.com/api/python/resources/precursor)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Update Zone Precursor Config

precursor.update(PrecursorUpdateParams\*\*kwargs) -> [PrecursorConfig](<https://developers.cloudflare.com/api/python/resources/precursor#(resource)%20precursor%20%3E%20(model)%20precursor_config%20%3E%20(schema)>)

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_mode` or `enforcement_rules` must be present; an empty body ( `{}`) is rejected with `400`.
- Rule `id` is read-only (assigned by Cloudflare) and ignored on input.
- Rule `mode` must be `min-friction` or `max-security` ( `off` is not a valid rule mode; use `default_mode` to disable enforcement).
- Rule `expression` is limited to 4000 characters. The limit applies to each rule individually, not to the combined size of all rules.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



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

**Example:**<code>X-Auth-Email: user@example.com</code>

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

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### ParametersExpand Collapse

zone\_id: str

Identifier.

maxLength32

[Link to this property](<#(resource)%20precursor%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20zone_id%20%3E%20(schema)>)

<details>

<summary>

Deprecateddefault\_mode: Optional\[Literal\["off", "min-friction", "max-security"]]

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

</summary>

One of the following:

"off"

<a href="#(resource)%20precursor%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20default_mode%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

"min-friction"

<a href="#(resource)%20precursor%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20default_mode%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

"max-security"

<a href="#(resource)%20precursor%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20default_mode%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

</details>

[Link to this property](<#(resource)%20precursor%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20default_mode%20%3E%20(schema)>)

<details>

<summary>

Deprecatedenforcement\_rules: Optional\[Iterable\[<a href="https://developers.cloudflare.com/api/python/resources/precursor#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)">EnforcementRuleParam</a>]]

The ordered list of enforcement rules for the zone.

</summary>

expression: str

The filter expression that determines which requests the rule matches.

maxLength4000

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20expression">Link to this property</a>

<details>

<summary>

mode: Literal\["min-friction", "max-security"]

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

</summary>

One of the following:

"min-friction"

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20mode%20%3E%20(member)%200">Link to this property</a>

"max-security"

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20mode%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20mode">Link to this property</a>

id: Optional\[str]

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

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

description: Optional\[str]

An informative description of the rule.

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20description">Link to this property</a>

enabled: Optional\[bool]

Whether the rule is active.

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20enabled">Link to this property</a>

</details>

[Link to this property](<#(resource)%20precursor%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20enforcement_rules%20%3E%20(schema)>)

##### ReturnsExpand Collapse

<details>

<summary>

class PrecursorConfig: …

</summary>

<details>

<summary>

Deprecateddefault\_mode: Optional\[Literal\["off", "min-friction", "max-security"]]

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

</summary>

One of the following:

"off"

<a href="#(resource)%20precursor%20%3E%20(model)%20precursor_config%20%3E%20(schema)%20%3E%20(property)%20default_mode%20%3E%20(member)%200">Link to this property</a>

"min-friction"

<a href="#(resource)%20precursor%20%3E%20(model)%20precursor_config%20%3E%20(schema)%20%3E%20(property)%20default_mode%20%3E%20(member)%201">Link to this property</a>

"max-security"

<a href="#(resource)%20precursor%20%3E%20(model)%20precursor_config%20%3E%20(schema)%20%3E%20(property)%20default_mode%20%3E%20(member)%202">Link to this property</a>

</details>

<a href="#(resource)%20precursor%20%3E%20(model)%20precursor_config%20%3E%20(schema)%20%3E%20(property)%20default_mode">Link to this property</a>

<details>

<summary>

Deprecatedenforcement\_rules: Optional\[List\[<a href="https://developers.cloudflare.com/api/python/resources/precursor#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)">EnforcementRule</a>]]

The ordered list of enforcement rules for the zone.

</summary>

expression: str

The filter expression that determines which requests the rule matches.

maxLength4000

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20expression">Link to this property</a>

<details>

<summary>

mode: Literal\["min-friction", "max-security"]

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

</summary>

One of the following:

"min-friction"

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20mode%20%3E%20(member)%200">Link to this property</a>

"max-security"

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20mode%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20mode">Link to this property</a>

id: Optional\[str]

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

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

description: Optional\[str]

An informative description of the rule.

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20description">Link to this property</a>

enabled: Optional\[bool]

Whether the rule is active.

<a href="#(resource)%20precursor%20%3E%20(model)%20enforcement_rule%20%3E%20(schema)%20%3E%20(property)%20enabled">Link to this property</a>

</details>

<a href="#(resource)%20precursor%20%3E%20(model)%20precursor_config%20%3E%20(schema)%20%3E%20(property)%20enforcement_rules">Link to this property</a>

</details>

[Link to this property](<#(resource)%20precursor%20%3E%20(model)%20precursor_config%20%3E%20(schema)>)

### Update Zone Precursor Config

Python

HTTPTypeScriptPythonGoTerraform

```
import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
precursor_config = client.precursor.update(
    zone_id="023e105f4ecef8ad9ca31a8372d0c353",
    default_mode="min-friction",
)
print(precursor_config.default_mode)
```

200 example

```
{
  "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

200 example

```
{
  "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
      }
    ]
  }
}
```