Skip to content
Start here

Create an account or zone ruleset rule

client.Rulesets.Rules.New(ctx, rulesetID, params) (*RuleNewResponseUnion, error)
POST/{accounts_or_zones}/{account_or_zone_id}/rulesets/{ruleset_id}/rules

Adds a new rule to an account or zone ruleset. The rule will be added to the end of the existing list of rules in the ruleset by default.

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)
Mass URL Redirects WriteMagic Firewall WriteL4 DDoS Managed Ruleset WriteTransform Rules WriteSelect Configuration WriteAccount WAF WriteAccount Rulesets WriteLogs Write
ParametersExpand Collapse
rulesetID string

The unique ID of the ruleset.

params RuleNewParams
AccountID param.Field[string]Optional

Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

ZoneID param.Field[string]Optional

Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

DryRun param.Field[bool]Optional

Query param: Validates the request without persisting changes when set to true. Responses that normally return 200 return result: null; endpoints that normally return 204 continue to return 204.

ID param.Field[string]Optional

Body param: The unique ID of the rule.

Action param.Field[RuleNewParamsBlockRuleAction]Optional

Body param: The action to perform when the rule matches.

const RuleNewParamsBlockRuleActionBlock RuleNewParamsBlockRuleAction = "block"
ActionParameters param.Field[RuleNewParamsBlockRuleActionParameters]Optional

Body param: The parameters configuring the rule’s action.

Response RuleNewParamsBlockRuleActionParametersResponseOptional

The response to show when the block is applied.

Content string

The content to return.

minLength1
ContentType string

The type of the content to return.

minLength1
StatusCode int64

The status code to return.

maximum499
minimum400
Description param.Field[string]Optional

Body param: An informative description of the rule.

Enabled param.Field[bool]Optional

Body param: Whether the rule should be executed.

ExposedCredentialCheck param.Field[RuleNewParamsBlockRuleExposedCredentialCheck]Optional

Body param: Configuration for exposed credential checking.

PasswordExpression string

An expression that selects the password used in the credentials check.

minLength1
UsernameExpression string

An expression that selects the user ID used in the credentials check.

minLength1
Expression param.Field[string]Optional

Body param: The expression defining which traffic will match the rule.

minLength1
Logging param.Field[Logging]Optional

Body param: An object configuring the rule’s logging behavior.

Position param.Field[RuleNewParamsBlockRulePosition]Optional

Body param: An object configuring where the rule will be placed.

RuleNewParamsBlockRulePositionBeforePosition
Before stringOptional

The ID of another rule to place the rule before. An empty value causes the rule to be placed at the top.

RuleNewParamsBlockRulePositionAfterPosition
After stringOptional

The ID of another rule to place the rule after. An empty value causes the rule to be placed at the bottom.

RuleNewParamsBlockRulePositionIndexPosition
Index int64Optional

An index at which to place the rule, where index 1 is the first rule.

minimum1
Ratelimit param.Field[RuleNewParamsBlockRuleRatelimit]Optional

Body param: An object configuring the rule’s rate limit behavior.

Characteristics []string

Characteristics of the request on which the rate limit counter will be incremented.

Period int64

Period in seconds over which the counter is being incremented.

minimum0
CountingExpression stringOptional

An expression that defines when the rate limit counter should be incremented. It defaults to the same as the rule’s expression.

minLength1
MitigationTimeout int64Optional

Period of time in seconds after which the action will be disabled following its first execution.

RequestsPerPeriod int64Optional

The threshold of requests per period after which the action will be executed for the first time.

minimum1
RequestsToOrigin boolOptional

Whether counting is only performed when an origin is reached.

ScorePerPeriod int64Optional

The score threshold per period for which the action will be executed the first time.

ScoreResponseHeaderName stringOptional

A response header name provided by the origin, which contains the score to increment rate limit counter with.

minLength1
Ref param.Field[string]Optional

Body param: The reference of the rule (the rule’s ID by default).

minLength1
ReturnsExpand Collapse
type RuleNewResponseUnion interface{…}

A result.

One of the following:
type RuleNewResponseArray []unknown
UnionString
UnionFloat
UnionBool
type RuleNewResponseRuleset struct{…}

A ruleset object.

ID string

The unique ID of the ruleset.

Kind Kind

The kind of the ruleset.

One of the following:
const KindManaged Kind = "managed"
const KindCustom Kind = "custom"
const KindRoot Kind = "root"
const KindZone Kind = "zone"
LastUpdated Time

The timestamp of when the ruleset was last modified.

formatdate-time
Name string

The human-readable name of the ruleset.

minLength1
Phase Phase

The phase of the ruleset.

One of the following:
const PhaseDDoSL4 Phase = "ddos_l4"
const PhaseDDoSL7 Phase = "ddos_l7"
const PhaseHTTPConfigSettings Phase = "http_config_settings"
const PhaseHTTPCustomErrors Phase = "http_custom_errors"
const PhaseHTTPLogCustomFields Phase = "http_log_custom_fields"
const PhaseHTTPRatelimit Phase = "http_ratelimit"
const PhaseHTTPRequestCacheSettings Phase = "http_request_cache_settings"
const PhaseHTTPRequestDynamicRedirect Phase = "http_request_dynamic_redirect"
const PhaseHTTPRequestFirewallCustom Phase = "http_request_firewall_custom"
const PhaseHTTPRequestFirewallManaged Phase = "http_request_firewall_managed"
const PhaseHTTPRequestLateTransform Phase = "http_request_late_transform"
const PhaseHTTPRequestOrigin Phase = "http_request_origin"
const PhaseHTTPRequestRedirect Phase = "http_request_redirect"
const PhaseHTTPRequestSanitize Phase = "http_request_sanitize"
const PhaseHTTPRequestSBFM Phase = "http_request_sbfm"
const PhaseHTTPRequestTransform Phase = "http_request_transform"
const PhaseHTTPResponseCacheSettings Phase = "http_response_cache_settings"
const PhaseHTTPResponseCompression Phase = "http_response_compression"
const PhaseHTTPResponseFirewallCustom Phase = "http_response_firewall_custom"
const PhaseHTTPResponseFirewallManaged Phase = "http_response_firewall_managed"
const PhaseHTTPResponseHeadersTransform Phase = "http_response_headers_transform"
const PhaseMagicTransit Phase = "magic_transit"
const PhaseMagicTransitIDsManaged Phase = "magic_transit_ids_managed"
const PhaseMagicTransitManaged Phase = "magic_transit_managed"
const PhaseMagicTransitRatelimit Phase = "magic_transit_ratelimit"
Rules []RuleNewResponseRulesetRule

The list of rules in the ruleset.

One of the following:
type RuleNewResponseRulesetRulesBlockRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesChallengeRule struct{…}
ID string

The unique ID of the rule.

Action RuleNewResponseRulesetRulesChallengeRuleAction

The action to perform when the rule matches.

Enabled bool

Whether the rule should be executed.

Expression string

The expression defining which traffic will match the rule.

minLength1
LastUpdated Time

The timestamp of when the rule was last modified.

formatdate-time
Ref string

The reference of the rule (the rule’s ID by default).

minLength1
Version string

The version of the rule.

ActionParameters unknownOptional

The parameters configuring the rule’s action.

Categories []stringOptional

The categories of the rule.

Description stringOptional

An informative description of the rule.

ExposedCredentialCheck RuleNewResponseRulesetRulesChallengeRuleExposedCredentialCheckOptional

Configuration for exposed credential checking.

PasswordExpression string

An expression that selects the password used in the credentials check.

minLength1
UsernameExpression string

An expression that selects the user ID used in the credentials check.

minLength1
Logging LoggingOptional

An object configuring the rule’s logging behavior.

Enabled bool

Whether to generate a log when the rule matches.

Ratelimit RuleNewResponseRulesetRulesChallengeRuleRatelimitOptional

An object configuring the rule’s rate limit behavior.

Characteristics []string

Characteristics of the request on which the rate limit counter will be incremented.

Period int64

Period in seconds over which the counter is being incremented.

minimum0
CountingExpression stringOptional

An expression that defines when the rate limit counter should be incremented. It defaults to the same as the rule’s expression.

minLength1
MitigationTimeout int64Optional

Period of time in seconds after which the action will be disabled following its first execution.

RequestsPerPeriod int64Optional

The threshold of requests per period after which the action will be executed for the first time.

minimum1
RequestsToOrigin boolOptional

Whether counting is only performed when an origin is reached.

ScorePerPeriod int64Optional

The score threshold per period for which the action will be executed the first time.

ScoreResponseHeaderName stringOptional

A response header name provided by the origin, which contains the score to increment rate limit counter with.

minLength1
type RuleNewResponseRulesetRulesResponseCompressionRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesDDoSDynamicRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesExecuteRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesForceConnectionCloseRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesJavaScriptChallengeRule struct{…}
ID string

The unique ID of the rule.

Action RuleNewResponseRulesetRulesJavaScriptChallengeRuleAction

The action to perform when the rule matches.

Enabled bool

Whether the rule should be executed.

Expression string

The expression defining which traffic will match the rule.

minLength1
LastUpdated Time

The timestamp of when the rule was last modified.

formatdate-time
Ref string

The reference of the rule (the rule’s ID by default).

minLength1
Version string

The version of the rule.

ActionParameters unknownOptional

The parameters configuring the rule’s action.

Categories []stringOptional

The categories of the rule.

Description stringOptional

An informative description of the rule.

ExposedCredentialCheck RuleNewResponseRulesetRulesJavaScriptChallengeRuleExposedCredentialCheckOptional

Configuration for exposed credential checking.

PasswordExpression string

An expression that selects the password used in the credentials check.

minLength1
UsernameExpression string

An expression that selects the user ID used in the credentials check.

minLength1
Logging LoggingOptional

An object configuring the rule’s logging behavior.

Enabled bool

Whether to generate a log when the rule matches.

Ratelimit RuleNewResponseRulesetRulesJavaScriptChallengeRuleRatelimitOptional

An object configuring the rule’s rate limit behavior.

Characteristics []string

Characteristics of the request on which the rate limit counter will be incremented.

Period int64

Period in seconds over which the counter is being incremented.

minimum0
CountingExpression stringOptional

An expression that defines when the rate limit counter should be incremented. It defaults to the same as the rule’s expression.

minLength1
MitigationTimeout int64Optional

Period of time in seconds after which the action will be disabled following its first execution.

RequestsPerPeriod int64Optional

The threshold of requests per period after which the action will be executed for the first time.

minimum1
RequestsToOrigin boolOptional

Whether counting is only performed when an origin is reached.

ScorePerPeriod int64Optional

The score threshold per period for which the action will be executed the first time.

ScoreResponseHeaderName stringOptional

A response header name provided by the origin, which contains the score to increment rate limit counter with.

minLength1
type RuleNewResponseRulesetRulesLogRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesLogCustomFieldRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesManagedChallengeRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesRedirectRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesRewriteRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesRouteRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesScoreRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesServeErrorRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesSetCacheControlRule struct{…}
ID string

The unique ID of the rule.

Action RuleNewResponseRulesetRulesSetCacheControlRuleAction

The action to perform when the rule matches.

Enabled bool
Expression string

The expression defining which traffic will match the rule.

minLength1
LastUpdated Time

The timestamp of when the rule was last modified.

formatdate-time
Ref string

The reference of the rule (the rule’s ID by default).

minLength1
Version string

The version of the rule.

ActionParameters RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersOptional

The parameters configuring the rule’s action.

Immutable RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableSetDirective struct{…}

Set the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersImmutableRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

MaxAge RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeOptional

A cache-control directive configuration that accepts a duration value in seconds.

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeSetDirective struct{…}

Set the directive with a duration value in seconds.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeSetDirectiveOperation = "remove"
Value int64

The duration value in seconds for the directive.

minimum0
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

MustRevalidate RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateSetDirective struct{…}

Set the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

MustUnderstand RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandSetDirective struct{…}

Set the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

NoCache RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheOptional

A cache-control directive configuration that accepts optional qualifiers (header names).

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheSetDirective struct{…}

Set the directive with optional qualifiers.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

Qualifiers []stringOptional

Optional list of header names to qualify the directive (e.g., for “private” or “no-cache” directives).

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoCacheRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

NoStore RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreSetDirective struct{…}

Set the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoStoreRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

NoTransform RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformSetDirective struct{…}

Set the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersNoTransformRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

Private RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateOptional

A cache-control directive configuration that accepts optional qualifiers (header names).

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateSetDirective struct{…}

Set the directive with optional qualifiers.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

Qualifiers []stringOptional

Optional list of header names to qualify the directive (e.g., for “private” or “no-cache” directives).

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPrivateRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

ProxyRevalidate RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirective struct{…}

Set the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

Public RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicSetDirective struct{…}

Set the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersPublicRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

SMaxage RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageOptional

A cache-control directive configuration that accepts a duration value in seconds.

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageSetDirective struct{…}

Set the directive with a duration value in seconds.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageSetDirectiveOperation = "remove"
Value int64

The duration value in seconds for the directive.

minimum0
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersSMaxageRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

StaleIfError RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorOptional

A cache-control directive configuration that accepts a duration value in seconds.

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirective struct{…}

Set the directive with a duration value in seconds.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirectiveOperation = "remove"
Value int64

The duration value in seconds for the directive.

minimum0
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

StaleWhileRevalidate RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateOptional

A cache-control directive configuration that accepts a duration value in seconds.

One of the following:
type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective struct{…}

Set the directive with a duration value in seconds.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirectiveOperation = "remove"
Value int64

The duration value in seconds for the directive.

minimum0
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

type RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirectiveOperationSet RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirectiveOperation = "set"
const RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirectiveOperationRemove RuleNewResponseRulesetRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

Whether the directive should only be applied to the Cloudflare CDN cache.

Categories []stringOptional

The categories of the rule.

Description stringOptional

An informative description of the rule.

ExposedCredentialCheck RuleNewResponseRulesetRulesSetCacheControlRuleExposedCredentialCheckOptional

Configuration for exposed credential checking.

PasswordExpression string

An expression that selects the password used in the credentials check.

minLength1
UsernameExpression string

An expression that selects the user ID used in the credentials check.

minLength1
Logging LoggingOptional

An object configuring the rule’s logging behavior.

Enabled bool

Whether to generate a log when the rule matches.

Ratelimit RuleNewResponseRulesetRulesSetCacheControlRuleRatelimitOptional

An object configuring the rule’s rate limit behavior.

Characteristics []string

Characteristics of the request on which the rate limit counter will be incremented.

Period int64

Period in seconds over which the counter is being incremented.

minimum0
CountingExpression stringOptional

An expression that defines when the rate limit counter should be incremented. It defaults to the same as the rule’s expression.

minLength1
MitigationTimeout int64Optional

Period of time in seconds after which the action will be disabled following its first execution.

RequestsPerPeriod int64Optional

The threshold of requests per period after which the action will be executed for the first time.

minimum1
RequestsToOrigin boolOptional

Whether counting is only performed when an origin is reached.

ScorePerPeriod int64Optional

The score threshold per period for which the action will be executed the first time.

ScoreResponseHeaderName stringOptional

A response header name provided by the origin, which contains the score to increment rate limit counter with.

minLength1
type RuleNewResponseRulesetRulesSetCacheSettingsRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesSetCacheTagsRule struct{…}
ID string

The unique ID of the rule.

Action RuleNewResponseRulesetRulesSetCacheTagsRuleAction

The action to perform when the rule matches.

Enabled bool
Expression string

The expression defining which traffic will match the rule.

minLength1
LastUpdated Time

The timestamp of when the rule was last modified.

formatdate-time
Ref string

The reference of the rule (the rule’s ID by default).

minLength1
Version string

The version of the rule.

ActionParameters RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersOptional

The parameters configuring the rule’s action.

One of the following:
type RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsValues struct{…}

Add cache tags using a list of values.

Operation RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperationAdd RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperation = "add"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperationRemove RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperation = "remove"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperationSet RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperation = "set"
Values []string

A list of cache tag values.

type RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsExpression struct{…}

Add cache tags using an expression.

Expression string

An expression that evaluates to an array of cache tag values.

minLength1
Operation RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperationAdd RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperation = "add"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperationRemove RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperation = "remove"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperationSet RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperation = "set"
type RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValues struct{…}

Remove cache tags using a list of values.

Operation RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperationAdd RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperation = "add"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperationRemove RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperation = "remove"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperationSet RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperation = "set"
Values []string

A list of cache tag values.

type RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpression struct{…}

Remove cache tags using an expression.

Expression string

An expression that evaluates to an array of cache tag values.

minLength1
Operation RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperationAdd RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperation = "add"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperationRemove RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperation = "remove"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperationSet RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperation = "set"
type RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsValues struct{…}

Set cache tags using a list of values.

Operation RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperationAdd RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperation = "add"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperationRemove RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperation = "remove"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperationSet RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperation = "set"
Values []string

A list of cache tag values.

type RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsExpression struct{…}

Set cache tags using an expression.

Expression string

An expression that evaluates to an array of cache tag values.

minLength1
Operation RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperationAdd RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperation = "add"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperationRemove RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperation = "remove"
const RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperationSet RuleNewResponseRulesetRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperation = "set"
Categories []stringOptional

The categories of the rule.

Description stringOptional

An informative description of the rule.

ExposedCredentialCheck RuleNewResponseRulesetRulesSetCacheTagsRuleExposedCredentialCheckOptional

Configuration for exposed credential checking.

PasswordExpression string

An expression that selects the password used in the credentials check.

minLength1
UsernameExpression string

An expression that selects the user ID used in the credentials check.

minLength1
Logging LoggingOptional

An object configuring the rule’s logging behavior.

Enabled bool

Whether to generate a log when the rule matches.

Ratelimit RuleNewResponseRulesetRulesSetCacheTagsRuleRatelimitOptional

An object configuring the rule’s rate limit behavior.

Characteristics []string

Characteristics of the request on which the rate limit counter will be incremented.

Period int64

Period in seconds over which the counter is being incremented.

minimum0
CountingExpression stringOptional

An expression that defines when the rate limit counter should be incremented. It defaults to the same as the rule’s expression.

minLength1
MitigationTimeout int64Optional

Period of time in seconds after which the action will be disabled following its first execution.

RequestsPerPeriod int64Optional

The threshold of requests per period after which the action will be executed for the first time.

minimum1
RequestsToOrigin boolOptional

Whether counting is only performed when an origin is reached.

ScorePerPeriod int64Optional

The score threshold per period for which the action will be executed the first time.

ScoreResponseHeaderName stringOptional

A response header name provided by the origin, which contains the score to increment rate limit counter with.

minLength1
type RuleNewResponseRulesetRulesSetConfigurationRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesSkipRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseRulesetRulesTransformResponseHTMLRule struct{…}
ID string

The unique ID of the rule.

Action RuleNewResponseRulesetRulesTransformResponseHTMLRuleAction

The action to perform when the rule matches.

Enabled bool
Expression string

The expression defining which traffic will match the rule.

minLength1
LastUpdated Time

The timestamp of when the rule was last modified.

formatdate-time
Ref string

The reference of the rule (the rule’s ID by default).

minLength1
Version string

The version of the rule.

ActionParameters RuleNewResponseRulesetRulesTransformResponseHTMLRuleActionParametersOptional

The parameters configuring the rule’s action.

Categories []stringOptional

The categories of the rule.

Description stringOptional

An informative description of the rule.

ExposedCredentialCheck RuleNewResponseRulesetRulesTransformResponseHTMLRuleExposedCredentialCheckOptional

Configuration for exposed credential checking.

PasswordExpression string

An expression that selects the password used in the credentials check.

minLength1
UsernameExpression string

An expression that selects the user ID used in the credentials check.

minLength1
Logging LoggingOptional

An object configuring the rule’s logging behavior.

Enabled bool

Whether to generate a log when the rule matches.

Ratelimit RuleNewResponseRulesetRulesTransformResponseHTMLRuleRatelimitOptional

An object configuring the rule’s rate limit behavior.

Characteristics []string

Characteristics of the request on which the rate limit counter will be incremented.

Period int64

Period in seconds over which the counter is being incremented.

minimum0
CountingExpression stringOptional

An expression that defines when the rate limit counter should be incremented. It defaults to the same as the rule’s expression.

minLength1
MitigationTimeout int64Optional

Period of time in seconds after which the action will be disabled following its first execution.

RequestsPerPeriod int64Optional

The threshold of requests per period after which the action will be executed for the first time.

minimum1
RequestsToOrigin boolOptional

Whether counting is only performed when an origin is reached.

ScorePerPeriod int64Optional

The score threshold per period for which the action will be executed the first time.

ScoreResponseHeaderName stringOptional

A response header name provided by the origin, which contains the score to increment rate limit counter with.

minLength1
Version string

The version of the ruleset.

Description stringOptional

An informative description of the ruleset.

Create an account or zone ruleset rule

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  rule, err := client.Rulesets.Rules.New(
    context.TODO(),
    "2f2feab2026849078ba485f918791bdc",
    rulesets.RuleNewParams{
      Body: rulesets.RuleNewParamsBodyBlockRule(rulesets.RuleNewParamsBodyBlockRule{
        BlockRuleParam: rulesets.BlockRuleParam{

        },
      }),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", rule)
}
{
  "errors": [
    {
      "message": "something bad happened",
      "code": 10000,
      "source": {
        "pointer": "/rules/0/action"
      }
    }
  ],
  "messages": [
    {
      "message": "something bad happened",
      "code": 10000,
      "source": {
        "pointer": "/rules/0/action"
      }
    }
  ],
  "result": {},
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "message": "something bad happened",
      "code": 10000,
      "source": {
        "pointer": "/rules/0/action"
      }
    }
  ],
  "messages": [
    {
      "message": "something bad happened",
      "code": 10000,
      "source": {
        "pointer": "/rules/0/action"
      }
    }
  ],
  "result": {},
  "success": true
}