# Fraud ## Get Fraud Detection Settings **get** `/zones/{zone_id}/fraud_detection/settings` Retrieve Fraud Detection settings for a zone. ### Path Parameters - `zone_id: string` Identifier. ### Returns - `errors: array of { code, message, documentation_url, source }` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `pointer: optional string` - `messages: array of { code, message, documentation_url, source }` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `pointer: optional string` - `success: true` Whether the API call was successful. - `true` - `result: optional FraudSettings` - `user_profiles: optional "enabled" or "disabled"` Whether Fraud User Profiles is enabled for the zone. - `"enabled"` - `"disabled"` - `username_expressions: optional array of string` 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. ### Example ```http curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/fraud_detection/settings \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` #### Response ```json { "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": { "user_profiles": "disabled", "username_expressions": [ "http.request.body.form[\"username\"][0]", "lookup_json_string(http.request.body.raw, \"username\")" ] } } ``` ## Update Fraud Detection Settings **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. ### Path Parameters - `zone_id: string` Identifier. ### Body Parameters - `user_profiles: optional "enabled" or "disabled"` Whether Fraud User Profiles is enabled for the zone. - `"enabled"` - `"disabled"` - `username_expressions: optional array of string` 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. ### Returns - `errors: array of { code, message, documentation_url, source }` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `pointer: optional string` - `messages: array of { code, message, documentation_url, source }` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `pointer: optional string` - `success: true` Whether the API call was successful. - `true` - `result: optional FraudSettings` - `user_profiles: optional "enabled" or "disabled"` Whether Fraud User Profiles is enabled for the zone. - `"enabled"` - `"disabled"` - `username_expressions: optional array of string` 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. ### Example ```http curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/fraud_detection/settings \ -X PUT \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -d '{ "user_profiles": "disabled", "username_expressions": [ "string" ] }' ``` #### Response ```json { "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": { "user_profiles": "disabled", "username_expressions": [ "http.request.body.form[\"username\"][0]", "lookup_json_string(http.request.body.raw, \"username\")" ] } } ``` ## Domain Types ### Fraud Settings - `FraudSettings { user_profiles, username_expressions }` - `user_profiles: optional "enabled" or "disabled"` Whether Fraud User Profiles is enabled for the zone. - `"enabled"` - `"disabled"` - `username_expressions: optional array of string` 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.