Update Zone Precursor Config
client.Precursor.Update(ctx, params) (*PrecursorConfig, error)
PUT/zones/{zone_id}/precursor
Updates the Precursor configuration for a zone.
mode controls whether Precursor detection is off, monitoring, or
armed. show_interstitial controls the zone-level response when armed.
rules is the ordered list of overrides for matching requests.
This is a partial update: only the fields present in the request body are changed.
- Sending an empty array (
[]) clears all rules. - At least one of
mode,show_interstitial, orrulesmust be present; an empty body ({}) is rejected with400. - Rule
idis read-only (assigned by Cloudflare) and ignored on input. - Rule
show_interstitialis required and controls the response for requests that match that rule. - Rule
expressionis limited to 4000 characters. The limit applies to each rule individually, not to the combined size of all rules.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Update 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.Update(context.TODO(), precursor.PrecursorUpdateParams{
ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
PrecursorConfig: precursor.PrecursorConfigParam{
},
CloudflareVersion: cloudflare.F(precursor.PrecursorUpdateParamsCloudflareVersion1_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
}
}