---
title: Update Fraud Detection Settings
---

[Skip to content](#_top)

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

[Fraud](https://developers.cloudflare.com/api/python/resources/fraud)

Copy Markdown

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

---

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

# Update Fraud Detection Settings

fraud.update(FraudUpdateParams\*\*kwargs) -> [FraudSettings](<https://developers.cloudflare.com/api/python/resources/fraud#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)>)

PUT/zones/{zone\_id}/fraud\_detection/settings

Update Fraud Detection settings for a zone.

Notes on `username_expressions` behavior:

- If omitted or set to null, expressions are not modified.
- If provided as an empty array `[]`, all expressions will be cleared.

##### 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>

##### Accepted Permissions (at least one required)

`Fraud Detection Write`

##### ParametersExpand Collapse

zone\_id: str

Identifier.

maxLength32

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

<details>

<summary>

authentication\_settings: Optional\[<a href="https://developers.cloudflare.com/api/python/resources/fraud/methods/update#(resource)%20fraud%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20authentication_settings%20%3E%20(schema)">AuthenticationSettings</a>]

Configuration for classifying login authentication outcomes based on the origin response. Requires <code>user_profiles</code> to be enabled.

- Success and failure criteria are independently updatable — sending only <code>success_criteria</code> leaves failure codes untouched, and vice versa.
- Omit <code>authentication_settings</code> entirely to leave both unchanged.
- Status codes must not overlap between success and failure criteria.

</summary>

<details>

<summary>

failure\_criteria: Optional\[AuthenticationSettingsFailureCriteria]

Criterion for identifying failed login responses.

</summary>

kind: Literal\["status\_code"]

The type of criterion. Currently only <code>status_code</code> is supported.

<a href="#(resource)%20fraud%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20authentication_settings%20%3E%20(schema)%20%3E%20(property)%20failure_criteria%20%3E%20(property)%20kind">Link to this property</a>

status\_codes: Optional\[Iterable\[int]]

HTTP status codes to match against the origin response.

- Maximum of 10 codes per criterion.
- Each code must be a valid HTTP status code (100-599).
- Codes are deduplicated and sorted on save.
- Omit to leave unchanged on update.
- Provide an empty array <code>[]</code> to clear codes on update.

<a href="#(resource)%20fraud%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20authentication_settings%20%3E%20(schema)%20%3E%20(property)%20failure_criteria%20%3E%20(property)%20status_codes">Link to this property</a>

</details>

<a href="#(resource)%20fraud%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20authentication_settings%20%3E%20(schema)%20%3E%20(property)%20failure_criteria">Link to this property</a>

<details>

<summary>

success\_criteria: Optional\[AuthenticationSettingsSuccessCriteria]

Criterion for identifying successful login responses.

</summary>

kind: Literal\["status\_code"]

The type of criterion. Currently only <code>status_code</code> is supported.

<a href="#(resource)%20fraud%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20authentication_settings%20%3E%20(schema)%20%3E%20(property)%20success_criteria%20%3E%20(property)%20kind">Link to this property</a>

status\_codes: Optional\[Iterable\[int]]

HTTP status codes to match against the origin response.

- Maximum of 10 codes per criterion.
- Each code must be a valid HTTP status code (100-599).
- Codes are deduplicated and sorted on save.
- Omit to leave unchanged on update.
- Provide an empty array <code>[]</code> to clear codes on update.

<a href="#(resource)%20fraud%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20authentication_settings%20%3E%20(schema)%20%3E%20(property)%20success_criteria%20%3E%20(property)%20status_codes">Link to this property</a>

</details>

<a href="#(resource)%20fraud%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20authentication_settings%20%3E%20(schema)%20%3E%20(property)%20success_criteria">Link to this property</a>

</details>

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

<details>

<summary>

user\_profiles: Optional\[Literal\["enabled", "disabled"]]

Whether Fraud User Profiles is enabled for the zone.

</summary>

One of the following:

"enabled"

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

"disabled"

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

</details>

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

username\_expressions: Optional\[Sequence\[str]]

List of expressions to detect usernames in write HTTP requests.

- Maximum of 10 expressions.
- Omit or set to null to leave unchanged on update.
- Provide an empty array `[]` to clear all expressions on update.
- Invalid expressions will result in a 10400 Bad Request with details in the `messages` array.

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

##### ReturnsExpand Collapse

<details>

<summary>

class FraudSettings: …

</summary>

<details>

<summary>

authentication\_settings: Optional\[AuthenticationSettings]

Configuration for classifying login authentication outcomes based on the origin response. Requires <code>user_profiles</code> to be enabled.

- Success and failure criteria are independently updatable — sending only <code>success_criteria</code> leaves failure codes untouched, and vice versa.
- Omit <code>authentication_settings</code> entirely to leave both unchanged.
- Status codes must not overlap between success and failure criteria.

</summary>

<details>

<summary>

failure\_criteria: Optional\[AuthenticationSettingsFailureCriteria]

Criterion for identifying failed login responses.

</summary>

kind: Literal\["status\_code"]

The type of criterion. Currently only <code>status_code</code> is supported.

<a href="#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)%20%3E%20(property)%20authentication_settings%20%3E%20(property)%20failure_criteria%20%3E%20(property)%20kind">Link to this property</a>

status\_codes: Optional\[List\[int]]

HTTP status codes to match against the origin response.

- Maximum of 10 codes per criterion.
- Each code must be a valid HTTP status code (100-599).
- Codes are deduplicated and sorted on save.
- Omit to leave unchanged on update.
- Provide an empty array <code>[]</code> to clear codes on update.

<a href="#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)%20%3E%20(property)%20authentication_settings%20%3E%20(property)%20failure_criteria%20%3E%20(property)%20status_codes">Link to this property</a>

</details>

<a href="#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)%20%3E%20(property)%20authentication_settings%20%3E%20(property)%20failure_criteria">Link to this property</a>

<details>

<summary>

success\_criteria: Optional\[AuthenticationSettingsSuccessCriteria]

Criterion for identifying successful login responses.

</summary>

kind: Literal\["status\_code"]

The type of criterion. Currently only <code>status_code</code> is supported.

<a href="#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)%20%3E%20(property)%20authentication_settings%20%3E%20(property)%20success_criteria%20%3E%20(property)%20kind">Link to this property</a>

status\_codes: Optional\[List\[int]]

HTTP status codes to match against the origin response.

- Maximum of 10 codes per criterion.
- Each code must be a valid HTTP status code (100-599).
- Codes are deduplicated and sorted on save.
- Omit to leave unchanged on update.
- Provide an empty array <code>[]</code> to clear codes on update.

<a href="#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)%20%3E%20(property)%20authentication_settings%20%3E%20(property)%20success_criteria%20%3E%20(property)%20status_codes">Link to this property</a>

</details>

<a href="#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)%20%3E%20(property)%20authentication_settings%20%3E%20(property)%20success_criteria">Link to this property</a>

</details>

<a href="#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)%20%3E%20(property)%20authentication_settings">Link to this property</a>

<details>

<summary>

user\_profiles: Optional\[Literal\["enabled", "disabled"]]

Whether Fraud User Profiles is enabled for the zone.

</summary>

One of the following:

"enabled"

<a href="#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)%20%3E%20(property)%20user_profiles%20%3E%20(member)%200">Link to this property</a>

"disabled"

<a href="#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)%20%3E%20(property)%20user_profiles%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)%20%3E%20(property)%20user_profiles">Link to this property</a>

username\_expressions: Optional\[List\[str]]

List of expressions to detect usernames in write HTTP requests.

- Maximum of 10 expressions.
- Omit or set to null to leave unchanged on update.
- Provide an empty array <code>[]</code> to clear all expressions on update.
- Invalid expressions will result in a 10400 Bad Request with details in the <code>messages</code> array.

<a href="#(resource)%20fraud%20%3E%20(model)%20fraud_settings%20%3E%20(schema)%20%3E%20(property)%20username_expressions">Link to this property</a>

</details>

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

### Update Fraud Detection Settings

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
)
fraud_settings = client.fraud.update(
    zone_id="023e105f4ecef8ad9ca31a8372d0c353",
    username_expressions=[],
)
print(fraud_settings.authentication_settings)
```

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": {
    "authentication_settings": {
      "failure_criteria": {
        "kind": "status_code",
        "status_codes": [
          200,
          201
        ]
      },
      "success_criteria": {
        "kind": "status_code",
        "status_codes": [
          200,
          201
        ]
      }
    },
    "user_profiles": "disabled",
    "username_expressions": [
      "http.request.body.form[\"username\"][0]",
      "lookup_json_string(http.request.body.raw, \"username\")"
    ]
  }
}
```

##### 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": {
    "authentication_settings": {
      "failure_criteria": {
        "kind": "status_code",
        "status_codes": [
          200,
          201
        ]
      },
      "success_criteria": {
        "kind": "status_code",
        "status_codes": [
          200,
          201
        ]
      }
    },
    "user_profiles": "disabled",
    "username_expressions": [
      "http.request.body.form[\"username\"][0]",
      "lookup_json_string(http.request.body.raw, \"username\")"
    ]
  }
}
```