pagerules
Creates, updates, deletes, gets or lists a pagerules resource.
Overview
| Name | pagerules |
| Type | Resource |
| Id | cloudflare.page_rules.pagerules |
Fields
The following fields are returned by SELECT queries:
- get
- list
Get a Page Rule response
| Name | Datatype | Description |
|---|---|---|
id | string | Identifier. (example: 023e105f4ecef8ad9ca31a8372d0c353) |
actions | array | The 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_on | string (date-time) | The timestamp of when the Page Rule was created. (example: 2014-01-01T05:20:00.12345Z) |
modified_on | string (date-time) | The timestamp of when the Page Rule was last modified. (example: 2014-01-01T05:20:00.12345Z) |
priority | integer | The 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. |
status | string | The status of the Page Rule. (active, disabled) (default: disabled, example: active) |
targets | array | The rule targets to evaluate on each request. |
List Page Rules response
| Name | Datatype | Description |
|---|---|---|
id | string | Identifier. (example: 023e105f4ecef8ad9ca31a8372d0c353) |
actions | array | The 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_on | string (date-time) | The timestamp of when the Page Rule was created. (example: 2014-01-01T05:20:00.12345Z) |
modified_on | string (date-time) | The timestamp of when the Page Rule was last modified. (example: 2014-01-01T05:20:00.12345Z) |
priority | integer | The 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. |
status | string | The status of the Page Rule. (active, disabled) (default: disabled, example: active) |
targets | array | The rule targets to evaluate on each request. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | pagerule_id, zone_id | Fetches the details of a Page Rule. | |
list | select | zone_id | order, direction, match, status | Fetches Page Rules in a zone. |
create | insert | zone_id, targets, actions | Creates a new Page Rule. | |
edit | update | pagerule_id, zone_id | Updates one or more fields of an existing Page Rule. | |
update | replace | pagerule_id, zone_id, targets, actions | 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. | |
delete | delete | pagerule_id, zone_id | Deletes 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.
| Name | Datatype | Description |
|---|---|---|
pagerule_id | string | |
zone_id | string | The Cloudflare zone ID. |
direction | string | |
match | string | |
order | string | |
status | string |
SELECT examples
- get
- list
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
;
Fetches Page Rules in a zone.
SELECT
id,
actions,
created_on,
modified_on,
priority,
status,
targets
FROM cloudflare.page_rules.pagerules
WHERE zone_id = '{{ zone_id }}' -- required
AND order = '{{ order }}'
AND direction = '{{ direction }}'
AND match = '{{ match }}'
AND status = '{{ status }}'
;
INSERT examples
- create
- Manifest
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
;
# Description fields are for documentation purposes
- name: pagerules
props:
- name: zone_id
value: "{{ zone_id }}"
description: Required parameter for the pagerules resource.
- name: actions
description: |
The 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.
value:
- id: "{{ id }}"
value: "{{ value }}"
- name: priority
value: {{ priority }}
description: |
The 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.
default: 1
- name: status
value: "{{ status }}"
description: |
The status of the Page Rule.
valid_values: ['active', 'disabled']
default: disabled
- name: targets
description: |
The rule targets to evaluate on each request.
value:
- constraint:
operator: "{{ operator }}"
value: "{{ value }}"
target: "{{ target }}"
UPDATE examples
- edit
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
- update
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
- delete
Deletes an existing Page Rule.
DELETE FROM cloudflare.page_rules.pagerules
WHERE pagerule_id = '{{ pagerule_id }}' --required
AND zone_id = '{{ zone_id }}' --required
;