Skip to main content

pagerules

Creates, updates, deletes, gets or lists a pagerules resource.

Overview

Namepagerules
TypeResource
Idcloudflare.page_rules.pagerules

Fields

The following fields are returned by SELECT queries:

Get a Page Rule response

NameDatatypeDescription
idstringIdentifier. (example: 023e105f4ecef8ad9ca31a8372d0c353)
actionsarrayThe set of actions to perform if the targets of this rule match the request. Actions can redirect to another URL or override settings, but not both.
created_onstring (date-time)The timestamp of when the Page Rule was created. (example: 2014-01-01T05:20:00.12345Z)
modified_onstring (date-time)The timestamp of when the Page Rule was last modified. (example: 2014-01-01T05:20:00.12345Z)
priorityintegerThe priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: /images/*) but want a more specific Page Rule to take precedence (rule B: /images/special/*), specify a higher priority for rule B so it overrides rule A.
statusstringThe status of the Page Rule. (active, disabled) (default: disabled, example: active)
targetsarrayThe rule targets to evaluate on each request.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectpagerule_id, zone_idFetches the details of a Page Rule.
listselectzone_idorder, direction, match, statusFetches Page Rules in a zone.
createinsertzone_id, targets, actionsCreates a new Page Rule.
editupdatepagerule_id, zone_idUpdates one or more fields of an existing Page Rule.
updatereplacepagerule_id, zone_id, targets, actionsReplaces the configuration of an existing Page Rule. The configuration of the updated Page Rule will exactly match the data passed in the API request.
deletedeletepagerule_id, zone_idDeletes an existing Page Rule.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
pagerule_idstring
zone_idstringThe Cloudflare zone ID.
directionstring
matchstring
orderstring
statusstring

SELECT examples

Fetches the details of a Page Rule.

SELECT
id,
actions,
created_on,
modified_on,
priority,
status,
targets
FROM cloudflare.page_rules.pagerules
WHERE pagerule_id = '{{ pagerule_id }}' -- required
AND zone_id = '{{ zone_id }}' -- required
;

INSERT examples

Creates a new Page Rule.

INSERT INTO cloudflare.page_rules.pagerules (
actions,
priority,
status,
targets,
zone_id
)
SELECT
'{{ actions }}' /* required */,
{{ priority }},
'{{ status }}',
'{{ targets }}' /* required */,
'{{ zone_id }}'
RETURNING
errors,
messages,
result,
success
;

UPDATE examples

Updates one or more fields of an existing Page Rule.

UPDATE cloudflare.page_rules.pagerules
SET
actions = '{{ actions }}',
priority = {{ priority }},
status = '{{ status }}',
targets = '{{ targets }}'
WHERE
pagerule_id = '{{ pagerule_id }}' --required
AND zone_id = '{{ zone_id }}' --required
RETURNING
errors,
messages,
result,
success;

REPLACE examples

Replaces the configuration of an existing Page Rule. The configuration of the updated Page Rule will exactly match the data passed in the API request.

REPLACE cloudflare.page_rules.pagerules
SET
actions = '{{ actions }}',
priority = {{ priority }},
status = '{{ status }}',
targets = '{{ targets }}'
WHERE
pagerule_id = '{{ pagerule_id }}' --required
AND zone_id = '{{ zone_id }}' --required
AND targets = '{{ targets }}' --required
AND actions = '{{ actions }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Deletes an existing Page Rule.

DELETE FROM cloudflare.page_rules.pagerules
WHERE pagerule_id = '{{ pagerule_id }}' --required
AND zone_id = '{{ zone_id }}' --required
;