Skip to content
Start here

Get Zone Precursor Config

client.Precursor.Get(ctx, params) (*PrecursorConfig, error)
GET/zones/{zone_id}/precursor

Retrieve a zone’s Precursor configuration: the detection mode, whether to show_interstitial, and the ordered list of rules.

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
ParametersExpand Collapse
params PrecursorGetParams
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
CloudflareVersion param.Field[PrecursorGetParamsCloudflareVersion]Optional

Header param: Selects the split Precursor API schema.

const PrecursorGetParamsCloudflareVersion1_0 PrecursorGetParamsCloudflareVersion = "1.0"
ReturnsExpand Collapse
type PrecursorConfig struct{…}
Mode PrecursorConfigModeOptional

Controls Precursor detection for the zone. off disables detection, monitor records detections without affecting bot scores, and arm allows detections to affect bot scores.

One of the following:
const PrecursorConfigModeOff PrecursorConfigMode = "off"
const PrecursorConfigModeMonitor PrecursorConfigMode = "monitor"
const PrecursorConfigModeArm PrecursorConfigMode = "arm"
Rules []PrecursorConfigRuleOptional

The ordered list of Precursor rules for the zone.

Expression string

The filter expression that determines which requests the rule matches.

maxLength4000
ShowInterstitial bool

Whether Precursor shows an interstitial when it takes action on a request.

ID stringOptional

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

Description stringOptional

An informative description of the rule.

Enabled boolOptional

Whether the rule is active.

ShowInterstitial boolOptional

Whether Precursor shows an interstitial when it takes action on a request.

Get Zone Precursor Config

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  precursorConfig, err := client.Precursor.Get(context.TODO(), precursor.PrecursorGetParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    CloudflareVersion: cloudflare.F(precursor.PrecursorGetParamsCloudflareVersion1_0),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", precursorConfig.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": {
    "mode": "arm",
    "rules": [
      {
        "expression": "http.request.uri.path eq \"/shop\"",
        "show_interstitial": true,
        "id": "3a03d665bac043e3a684e0d385a4b1e2",
        "description": "Show an interstitial on the shop page",
        "enabled": true
      }
    ],
    "show_interstitial": false
  }
}
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": {
    "mode": "arm",
    "rules": [
      {
        "expression": "http.request.uri.path eq \"/shop\"",
        "show_interstitial": true,
        "id": "3a03d665bac043e3a684e0d385a4b1e2",
        "description": "Show an interstitial on the shop page",
        "enabled": true
      }
    ],
    "show_interstitial": false
  }
}