Skip to content
Start here

Update Fraud Detection Settings

client.Fraud.Update(ctx, params) (*FraudSettings, error)
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
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
Accepted Permissions (at least one required)
Fraud Detection Write
ParametersExpand Collapse
params FraudUpdateParams
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
FraudSettings param.Field[FraudSettings]

Body param

ReturnsExpand Collapse
type FraudSettings struct{…}
UserProfiles FraudSettingsUserProfilesoptional

Whether Fraud User Profiles is enabled for the zone.

One of the following:
const FraudSettingsUserProfilesEnabled FraudSettingsUserProfiles = "enabled"
const FraudSettingsUserProfilesDisabled FraudSettingsUserProfiles = "disabled"
UsernameExpressions []stringoptional

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.

Update Fraud Detection Settings

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/fraud"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  fraudSettings, err := client.Fraud.Update(context.TODO(), fraud.FraudUpdateParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    FraudSettings: fraud.FraudSettingsParam{

    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", fraudSettings.UserProfiles)
}
{
  "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\")"
    ]
  }
}
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": {
    "user_profiles": "disabled",
    "username_expressions": [
      "http.request.body.form[\"username\"][0]",
      "lookup_json_string(http.request.body.raw, \"username\")"
    ]
  }
}