Skip to content
Start here

Create an account or zone ruleset rule

client.Rulesets.Rules.New(ctx, rulesetID, params) (*RuleNewResponseEnvelopeResult, 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 RuleNewResponseEnvelopeResult interface{…}

A result.

One of the following:
type RuleNewResponseEnvelopeResult 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 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 []RuleNewResponseEnvelopeResultRules

The list of rules in the ruleset.

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

The unique ID of the rule.

Action RuleNewResponseEnvelopeResultRulesChallengeRuleAction

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 RuleNewResponseEnvelopeResultRulesChallengeRuleExposedCredentialCheckOptional

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 RuleNewResponseEnvelopeResultRulesChallengeRuleRatelimitOptional

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 RuleNewResponseEnvelopeResultRulesResponseCompressionRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesDDoSDynamicRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesExecuteRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesForceConnectionCloseRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesJavaScriptChallengeRule struct{…}
ID string

The unique ID of the rule.

Action RuleNewResponseEnvelopeResultRulesJavaScriptChallengeRuleAction

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 RuleNewResponseEnvelopeResultRulesJavaScriptChallengeRuleExposedCredentialCheckOptional

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 RuleNewResponseEnvelopeResultRulesJavaScriptChallengeRuleRatelimitOptional

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 RuleNewResponseEnvelopeResultRulesLogRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesLogCustomFieldRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesManagedChallengeRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesRedirectRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesRewriteRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesRouteRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesScoreRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesServeErrorRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesSetCacheControlRule struct{…}
ID string

The unique ID of the rule.

Action RuleNewResponseEnvelopeResultRulesSetCacheControlRuleAction

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 RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersOptional

The parameters configuring the rule’s action.

Immutable RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableSetDirective struct{…}

Set the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersImmutableRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

MaxAge RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeOptional

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

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeSetDirective struct{…}

Set the directive with a duration value in seconds.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeSetDirectiveOperation = "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 RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMaxAgeRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

MustRevalidate RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateSetDirective struct{…}

Set the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustRevalidateRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

MustUnderstand RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandSetDirective struct{…}

Set the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersMustUnderstandRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

NoCache RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheOptional

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

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheSetDirective struct{…}

Set the directive with optional qualifiers.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheSetDirectiveOperation = "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 RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoCacheRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

NoStore RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreSetDirective struct{…}

Set the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoStoreRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

NoTransform RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformSetDirective struct{…}

Set the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersNoTransformRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

Private RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateOptional

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

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateSetDirective struct{…}

Set the directive with optional qualifiers.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateSetDirectiveOperation = "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 RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPrivateRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

ProxyRevalidate RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirective struct{…}

Set the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersProxyRevalidateRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

Public RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicOptional

A cache-control directive configuration.

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicSetDirective struct{…}

Set the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicSetDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersPublicRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

SMaxage RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageOptional

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

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageSetDirective struct{…}

Set the directive with a duration value in seconds.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageSetDirectiveOperation = "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 RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersSMaxageRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

StaleIfError RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorOptional

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

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirective struct{…}

Set the directive with a duration value in seconds.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorSetDirectiveOperation = "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 RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleIfErrorRemoveDirectiveOperation = "remove"
CloudflareOnly boolOptional

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

StaleWhileRevalidate RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateOptional

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

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective struct{…}

Set the directive with a duration value in seconds.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirectiveOperation = "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 RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective struct{…}

Remove the directive.

Operation RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirectiveOperation

The operation to perform on the cache-control directive.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirectiveOperationSet RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirectiveOperation = "set"
const RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirectiveOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirectiveOperation = "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 RuleNewResponseEnvelopeResultRulesSetCacheControlRuleExposedCredentialCheckOptional

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 RuleNewResponseEnvelopeResultRulesSetCacheControlRuleRatelimitOptional

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 RuleNewResponseEnvelopeResultRulesSetCacheSettingsRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesSetCacheTagsRule struct{…}
ID string

The unique ID of the rule.

Action RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleAction

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 RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersOptional

The parameters configuring the rule’s action.

One of the following:
type RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsValues struct{…}

Add cache tags using a list of values.

Operation RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperationAdd RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperation = "add"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperation = "remove"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperationSet RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsValuesOperation = "set"
Values []string

A list of cache tag values.

type RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsExpression struct{…}

Add cache tags using an expression.

Expression string

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

minLength1
Operation RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperationAdd RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperation = "add"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperation = "remove"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperationSet RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersAddCacheTagsExpressionOperation = "set"
type RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValues struct{…}

Remove cache tags using a list of values.

Operation RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperationAdd RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperation = "add"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperation = "remove"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperationSet RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsValuesOperation = "set"
Values []string

A list of cache tag values.

type RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpression struct{…}

Remove cache tags using an expression.

Expression string

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

minLength1
Operation RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperationAdd RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperation = "add"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperation = "remove"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperationSet RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersRemoveCacheTagsExpressionOperation = "set"
type RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsValues struct{…}

Set cache tags using a list of values.

Operation RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperationAdd RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperation = "add"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperation = "remove"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperationSet RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsValuesOperation = "set"
Values []string

A list of cache tag values.

type RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsExpression struct{…}

Set cache tags using an expression.

Expression string

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

minLength1
Operation RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperation

The operation to perform on the cache tags.

One of the following:
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperationAdd RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperation = "add"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperationRemove RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperation = "remove"
const RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperationSet RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleActionParametersSetCacheTagsExpressionOperation = "set"
Categories []stringOptional

The categories of the rule.

Description stringOptional

An informative description of the rule.

ExposedCredentialCheck RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleExposedCredentialCheckOptional

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 RuleNewResponseEnvelopeResultRulesSetCacheTagsRuleRatelimitOptional

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 RuleNewResponseEnvelopeResultRulesSetConfigurationRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesSkipRule struct{…}
ID string
Action string
Enabled bool
Expression string
Ref string
type RuleNewResponseEnvelopeResultRulesTransformResponseHTMLRule struct{…}
ID string

The unique ID of the rule.

Action RuleNewResponseEnvelopeResultRulesTransformResponseHTMLRuleAction

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 RuleNewResponseEnvelopeResultRulesTransformResponseHTMLRuleActionParametersOptional

The parameters configuring the rule’s action.

Categories []stringOptional

The categories of the rule.

Description stringOptional

An informative description of the rule.

ExposedCredentialCheck RuleNewResponseEnvelopeResultRulesTransformResponseHTMLRuleExposedCredentialCheckOptional

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 RuleNewResponseEnvelopeResultRulesTransformResponseHTMLRuleRatelimitOptional

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": {
    "id": "2f2feab2026849078ba485f918791bdc",
    "kind": "root",
    "last_updated": "2000-01-01T00:00:00Z",
    "name": "My ruleset",
    "phase": "http_request_firewall_custom",
    "rules": [
      {
        "last_updated": "2000-01-01T00:00:00Z",
        "version": "1",
        "id": "id",
        "action": "action",
        "action_parameters": {
          "response": {
            "content": "{\n  \"success\": false,\n  \"error\": \"you have been blocked\"\n}",
            "content_type": "application/json",
            "status_code": 400
          }
        },
        "categories": [
          "directory-traversal"
        ],
        "description": "Block the request.",
        "enabled": true,
        "exposed_credential_check": {
          "password_expression": "url_decode(http.request.body.form[\\\"password\\\"][0])",
          "username_expression": "url_decode(http.request.body.form[\\\"username\\\"][0])"
        },
        "expression": "expression",
        "logging": {
          "enabled": true
        },
        "ratelimit": {
          "characteristics": [
            "cf.colo.id"
          ],
          "period": 60,
          "counting_expression": "http.request.body.raw eq \"abcd\"",
          "mitigation_timeout": 600,
          "requests_per_period": 1000,
          "requests_to_origin": true,
          "score_per_period": 400,
          "score_response_header_name": "my-score"
        },
        "ref": "ref"
      }
    ],
    "version": "1",
    "description": "A description for my ruleset."
  },
  "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": {
    "id": "2f2feab2026849078ba485f918791bdc",
    "kind": "root",
    "last_updated": "2000-01-01T00:00:00Z",
    "name": "My ruleset",
    "phase": "http_request_firewall_custom",
    "rules": [
      {
        "last_updated": "2000-01-01T00:00:00Z",
        "version": "1",
        "id": "id",
        "action": "action",
        "action_parameters": {
          "response": {
            "content": "{\n  \"success\": false,\n  \"error\": \"you have been blocked\"\n}",
            "content_type": "application/json",
            "status_code": 400
          }
        },
        "categories": [
          "directory-traversal"
        ],
        "description": "Block the request.",
        "enabled": true,
        "exposed_credential_check": {
          "password_expression": "url_decode(http.request.body.form[\\\"password\\\"][0])",
          "username_expression": "url_decode(http.request.body.form[\\\"username\\\"][0])"
        },
        "expression": "expression",
        "logging": {
          "enabled": true
        },
        "ratelimit": {
          "characteristics": [
            "cf.colo.id"
          ],
          "period": 60,
          "counting_expression": "http.request.body.raw eq \"abcd\"",
          "mitigation_timeout": 600,
          "requests_per_period": 1000,
          "requests_to_origin": true,
          "score_per_period": 400,
          "score_response_header_name": "my-score"
        },
        "ref": "ref"
      }
    ],
    "version": "1",
    "description": "A description for my ruleset."
  },
  "success": true
}