## Edit a Page Rule `page_rules.edit(strpagerule_id, PageRuleEditParams**kwargs) -> PageRule` **patch** `/zones/{zone_id}/pagerules/{pagerule_id}` Updates one or more fields of an existing Page Rule. ### Parameters - `zone_id: str` Identifier. - `pagerule_id: str` Identifier. - `actions: Optional[Iterable[Action]]` 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. - `class AlwaysUseHTTPS: …` - `id: Optional[Literal["always_use_https"]]` If enabled, any `http://`` URL is converted to`https://` through a 301 redirect. - `"always_use_https"` - `class AutomaticHTTPSRewrites: …` - `id: Optional[Literal["automatic_https_rewrites"]]` Turn on or off Automatic HTTPS Rewrites. - `"automatic_https_rewrites"` - `value: Optional[Literal["on", "off"]]` The status of Automatic HTTPS Rewrites. - `"on"` - `"off"` - `class BrowserCacheTTL: …` - `id: Optional[Literal["browser_cache_ttl"]]` Control how long resources cached by client browsers remain valid. - `"browser_cache_ttl"` - `value: Optional[int]` The number of seconds to cache resources for. Setting this to 0 enables "Respect Existing Headers". - `class BrowserCheck: …` - `id: Optional[Literal["browser_check"]]` Inspect the visitor's browser for headers commonly associated with spammers and certain bots. - `"browser_check"` - `value: Optional[Literal["on", "off"]]` The status of Browser Integrity Check. - `"on"` - `"off"` - `class ActionBypassCacheOnCookie: …` - `id: Optional[Literal["bypass_cache_on_cookie"]]` Bypass cache and fetch resources from the origin server if a regular expression matches against a cookie name present in the request. - `"bypass_cache_on_cookie"` - `value: Optional[str]` The regular expression to use for matching cookie names in the request. Refer to [Bypass Cache on Cookie setting](https://developers.cloudflare.com/rules/page-rules/reference/additional-reference/#bypass-cache-on-cookie-setting) to learn about limited regular expression support. - `class ActionCacheByDeviceType: …` - `id: Optional[Literal["cache_by_device_type"]]` Separate cached content based on the visitor's device type. - `"cache_by_device_type"` - `value: Optional[Literal["on", "off"]]` The status of Cache By Device Type. - `"on"` - `"off"` - `class ActionCacheDeceptionArmor: …` - `id: Optional[Literal["cache_deception_armor"]]` Protect from web cache deception attacks while still allowing static assets to be cached. This setting verifies that the URL's extension matches the returned `Content-Type`. - `"cache_deception_armor"` - `value: Optional[Literal["on", "off"]]` The status of Cache Deception Armor. - `"on"` - `"off"` - `class ActionCacheKeyFields: …` - `id: Optional[Literal["cache_key_fields"]]` Control specifically what variables to include when deciding which resources to cache. This allows customers to determine what to cache based on something other than just the URL. - `"cache_key_fields"` - `value: Optional[ActionCacheKeyFieldsValue]` - `cookie: Optional[ActionCacheKeyFieldsValueCookie]` Controls which cookies appear in the Cache Key. - `check_presence: Optional[SequenceNotStr[str]]` A list of cookies to check for the presence of, without including their actual values. - `include: Optional[SequenceNotStr[str]]` A list of cookies to include. - `header: Optional[ActionCacheKeyFieldsValueHeader]` Controls which headers go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `check_presence: Optional[SequenceNotStr[str]]` A list of headers to check for the presence of, without including their actual values. - `exclude: Optional[SequenceNotStr[str]]` A list of headers to ignore. - `include: Optional[SequenceNotStr[str]]` A list of headers to include. - `host: Optional[ActionCacheKeyFieldsValueHost]` Determines which host header to include in the Cache Key. - `resolved: Optional[bool]` Whether to include the Host header in the HTTP request sent to the origin. - `query_string: Optional[ActionCacheKeyFieldsValueQueryString]` Controls which URL query string parameters go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `exclude: Optional[Union[Literal["*"], SequenceNotStr[str]]]` Ignore all query string parameters. - `Literal["*"]` Ignore all query string parameters. - `"*"` - `SequenceNotStr[str]` A list of query string parameters to ignore. - `include: Optional[Union[Literal["*"], SequenceNotStr[str]]]` Include all query string parameters. - `Literal["*"]` Include all query string parameters. - `"*"` - `SequenceNotStr[str]` A list of query string parameters to include. - `user: Optional[ActionCacheKeyFieldsValueUser]` Feature fields to add features about the end-user (client) into the Cache Key. - `device_type: Optional[bool]` Classifies a request as `mobile`, `desktop`, or `tablet` based on the User Agent. - `geo: Optional[bool]` Includes the client's country, derived from the IP address. - `lang: Optional[bool]` Includes the first language code contained in the `Accept-Language` header sent by the client. - `class CacheLevel: …` - `id: Optional[Literal["cache_level"]]` Apply custom caching based on the option selected. - `"cache_level"` - `value: Optional[Literal["bypass", "basic", "simplified", 2 more]]` * `bypass`: Cloudflare does not cache. * `basic`: Delivers resources from cache when there is no query string. * `simplified`: Delivers the same resource to everyone independent of the query string. * `aggressive`: Caches all static content that has a query string. * `cache_everything`: Treats all content as static and caches all file types beyond the [Cloudflare default cached content](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#default-cached-file-extensions). - `"bypass"` - `"basic"` - `"simplified"` - `"aggressive"` - `"cache_everything"` - `class ActionCacheOnCookie: …` - `id: Optional[Literal["cache_on_cookie"]]` Apply the Cache Everything option (Cache Level setting) based on a regular expression match against a cookie name. - `"cache_on_cookie"` - `value: Optional[str]` The regular expression to use for matching cookie names in the request. - `class ActionCacheTTLByStatus: …` - `id: Optional[Literal["cache_ttl_by_status"]]` Enterprise customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as stale or discarded from cache. Status codes are returned by a resource's origin. Setting cache TTL based on response status overrides the default cache behavior (standard caching) for static files and overrides cache instructions sent by the origin web server. To cache non-static assets, set a Cache Level of Cache Everything using a Page Rule. Setting no-store Cache-Control or a low TTL (using `max-age`/`s-maxage`) increases requests to origin web servers and decreases performance. - `"cache_ttl_by_status"` - `value: Optional[Dict[str, Union[Literal["no-cache", "no-store"], int]]]` A JSON object containing status codes and their corresponding TTLs. Each key-value pair in the cache TTL by status cache rule has the following syntax - `status_code`: An integer value such as 200 or 500. status_code matches the exact status code from the origin web server. Valid status codes are between 100-999. - `status_code_range`: Integer values for from and to. status_code_range matches any status code from the origin web server within the specified range. - `value`: An integer value that defines the duration an asset is valid in seconds or one of the following strings: no-store (equivalent to -1), no-cache (equivalent to 0). - `Literal["no-cache", "no-store"]` `no-store` (equivalent to -1), `no-cache` (equivalent to 0) - `"no-cache"` - `"no-store"` - `int` An integer value that defines the duration an asset is valid in seconds. - `class ActionDisableApps: …` - `id: Optional[Literal["disable_apps"]]` Turn off all active [Cloudflare Apps](https://developers.cloudflare.com/support/more-dashboard-apps/cloudflare-apps/) (deprecated). - `"disable_apps"` - `class ActionDisablePerformance: …` - `id: Optional[Literal["disable_performance"]]` Turn off [Rocket Loader](https://developers.cloudflare.com/speed/optimization/content/rocket-loader/), and [Polish](https://developers.cloudflare.com/images/polish/). - `"disable_performance"` - `class ActionDisableSecurity: …` - `id: Optional[Literal["disable_security"]]` Turn off [Email Obfuscation](https://developers.cloudflare.com/waf/tools/scrape-shield/email-address-obfuscation/), [Rate Limiting (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/), [Scrape Shield](https://developers.cloudflare.com/waf/tools/scrape-shield/), [URL (Zone) Lockdown](https://developers.cloudflare.com/waf/tools/zone-lockdown/), and [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). - `"disable_security"` - `class ActionDisableZaraz: …` - `id: Optional[Literal["disable_zaraz"]]` Turn off [Zaraz](https://developers.cloudflare.com/zaraz/). - `"disable_zaraz"` - `class ActionEdgeCacheTTL: …` - `id: Optional[Literal["edge_cache_ttl"]]` Specify how long to cache a resource in the Cloudflare global network. *Edge Cache TTL* is not visible in response headers. - `"edge_cache_ttl"` - `value: Optional[int]` - `class EmailObfuscation: …` - `id: Optional[Literal["email_obfuscation"]]` Turn on or off **Email Obfuscation**. - `"email_obfuscation"` - `value: Optional[Literal["on", "off"]]` The status of Email Obfuscation. - `"on"` - `"off"` - `class ActionExplicitCacheControl: …` - `id: Optional[Literal["explicit_cache_control"]]` Origin Cache Control is enabled by default for Free, Pro, and Business domains and disabled by default for Enterprise domains. - `"explicit_cache_control"` - `value: Optional[Literal["on", "off"]]` The status of Origin Cache Control. - `"on"` - `"off"` - `class ActionForwardingURL: …` - `id: Optional[Literal["forwarding_url"]]` Redirects one URL to another using an `HTTP 301/302` redirect. Refer to [Wildcard matching and referencing](https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/). - `"forwarding_url"` - `value: Optional[ActionForwardingURLValue]` - `status_code: Optional[Literal[301, 302]]` The status code to use for the URL redirect. 301 is a permanent redirect. 302 is a temporary redirect. - `301` - `302` - `url: Optional[str]` The URL to redirect the request to. Notes: ${num} refers to the position of '*' in the constraint value. - `class ActionHostHeaderOverride: …` - `id: Optional[Literal["host_header_override"]]` Apply a specific host header. - `"host_header_override"` - `value: Optional[str]` The hostname to use in the `Host` header - `class IPGeolocation: …` - `id: Optional[Literal["ip_geolocation"]]` Cloudflare adds a CF-IPCountry HTTP header containing the country code that corresponds to the visitor. - `"ip_geolocation"` - `value: Optional[Literal["on", "off"]]` The status of adding the IP Geolocation Header. - `"on"` - `"off"` - `class Mirage: …` - `id: Optional[Literal["mirage"]]` Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can accelerate loading of image-heavy websites on very slow mobile connections and HTTP/1. - `"mirage"` - `value: Optional[Literal["on", "off"]]` The status of Mirage. - `"on"` - `"off"` - `class OpportunisticEncryption: …` - `id: Optional[Literal["opportunistic_encryption"]]` Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. It's not a substitute for HTTPS, but provides additional security for otherwise vulnerable requests. - `"opportunistic_encryption"` - `value: Optional[Literal["on", "off"]]` The status of Opportunistic Encryption. - `"on"` - `"off"` - `class OriginErrorPagePassThru: …` - `id: Optional[Literal["origin_error_page_pass_thru"]]` Turn on or off Cloudflare error pages generated from issues sent from the origin server. If enabled, this setting triggers error pages issued by the origin. - `"origin_error_page_pass_thru"` - `value: Optional[Literal["on", "off"]]` The status of Origin Error Page Passthru. - `"on"` - `"off"` - `class Polish: …` - `id: Optional[Literal["polish"]]` Apply options from the Polish feature of the Cloudflare Speed app. - `"polish"` - `value: Optional[Literal["off", "lossless", "lossy"]]` The level of Polish you want applied to your origin. - `"off"` - `"lossless"` - `"lossy"` - `class ActionResolveOverride: …` - `id: Optional[Literal["resolve_override"]]` Change the origin address to the value specified in this setting. - `"resolve_override"` - `value: Optional[str]` The origin address you want to override with. - `class ActionRespectStrongEtag: …` - `id: Optional[Literal["respect_strong_etag"]]` Turn on or off byte-for-byte equivalency checks between the Cloudflare cache and the origin server. - `"respect_strong_etag"` - `value: Optional[Literal["on", "off"]]` The status of Respect Strong ETags - `"on"` - `"off"` - `class ResponseBuffering: …` - `id: Optional[Literal["response_buffering"]]` Turn on or off whether Cloudflare should wait for an entire file from the origin server before forwarding it to the site visitor. By default, Cloudflare sends packets to the client as they arrive from the origin server. - `"response_buffering"` - `value: Optional[Literal["on", "off"]]` The status of Response Buffering - `"on"` - `"off"` - `class RocketLoader: …` - `id: Optional[Literal["rocket_loader"]]` Turn on or off Rocket Loader in the Cloudflare Speed app. - `"rocket_loader"` - `value: Optional[Literal["on", "off"]]` The status of Rocket Loader - `"on"` - `"off"` - `class SecurityLevel: …` - `id: Optional[Literal["security_level"]]` Control options for the **Security Level** feature from the **Security** app. - `"security_level"` - `value: Optional[Literal["off", "essentially_off", "low", 3 more]]` - `"off"` - `"essentially_off"` - `"low"` - `"medium"` - `"high"` - `"under_attack"` - `class SortQueryStringForCache: …` - `id: Optional[Literal["sort_query_string_for_cache"]]` Turn on or off the reordering of query strings. When query strings have the same structure, caching improves. - `"sort_query_string_for_cache"` - `value: Optional[Literal["on", "off"]]` The status of Query String Sort - `"on"` - `"off"` - `class SSL: …` - `id: Optional[Literal["ssl"]]` Control options for the SSL feature of the Edge Certificates tab in the Cloudflare SSL/TLS app. - `"ssl"` - `value: Optional[Literal["off", "flexible", "full", 2 more]]` The encryption mode that Cloudflare uses to connect to your origin server. - `"off"` - `"flexible"` - `"full"` - `"strict"` - `"origin_pull"` - `class TrueClientIPHeader: …` - `id: Optional[Literal["true_client_ip_header"]]` Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. - `"true_client_ip_header"` - `value: Optional[Literal["on", "off"]]` The status of True Client IP Header. - `"on"` - `"off"` - `class WAF: …` - `id: Optional[Literal["waf"]]` Turn on or off [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). You cannot enable or disable individual WAF managed rules via Page Rules. - `"waf"` - `value: Optional[Literal["on", "off"]]` The status of WAF managed rules (previous version). - `"on"` - `"off"` - `priority: Optional[int]` 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: Optional[Literal["active", "disabled"]]` The status of the Page Rule. - `"active"` - `"disabled"` - `targets: Optional[Iterable[TargetParam]]` The rule targets to evaluate on each request. - `constraint: Optional[Constraint]` String constraint. - `operator: Literal["matches", "contains", "equals", 2 more]` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `"matches"` - `"contains"` - `"equals"` - `"not_equal"` - `"not_contain"` - `value: str` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `target: Optional[Literal["url"]]` A target based on the URL of the request. - `"url"` ### Returns - `class PageRule: …` - `id: str` Identifier. - `actions: List[Action]` 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. - `class AlwaysUseHTTPS: …` - `id: Optional[Literal["always_use_https"]]` If enabled, any `http://`` URL is converted to`https://` through a 301 redirect. - `"always_use_https"` - `class AutomaticHTTPSRewrites: …` - `id: Optional[Literal["automatic_https_rewrites"]]` Turn on or off Automatic HTTPS Rewrites. - `"automatic_https_rewrites"` - `value: Optional[Literal["on", "off"]]` The status of Automatic HTTPS Rewrites. - `"on"` - `"off"` - `class BrowserCacheTTL: …` - `id: Optional[Literal["browser_cache_ttl"]]` Control how long resources cached by client browsers remain valid. - `"browser_cache_ttl"` - `value: Optional[int]` The number of seconds to cache resources for. Setting this to 0 enables "Respect Existing Headers". - `class BrowserCheck: …` - `id: Optional[Literal["browser_check"]]` Inspect the visitor's browser for headers commonly associated with spammers and certain bots. - `"browser_check"` - `value: Optional[Literal["on", "off"]]` The status of Browser Integrity Check. - `"on"` - `"off"` - `class ActionBypassCacheOnCookie: …` - `id: Optional[Literal["bypass_cache_on_cookie"]]` Bypass cache and fetch resources from the origin server if a regular expression matches against a cookie name present in the request. - `"bypass_cache_on_cookie"` - `value: Optional[str]` The regular expression to use for matching cookie names in the request. Refer to [Bypass Cache on Cookie setting](https://developers.cloudflare.com/rules/page-rules/reference/additional-reference/#bypass-cache-on-cookie-setting) to learn about limited regular expression support. - `class ActionCacheByDeviceType: …` - `id: Optional[Literal["cache_by_device_type"]]` Separate cached content based on the visitor's device type. - `"cache_by_device_type"` - `value: Optional[Literal["on", "off"]]` The status of Cache By Device Type. - `"on"` - `"off"` - `class ActionCacheDeceptionArmor: …` - `id: Optional[Literal["cache_deception_armor"]]` Protect from web cache deception attacks while still allowing static assets to be cached. This setting verifies that the URL's extension matches the returned `Content-Type`. - `"cache_deception_armor"` - `value: Optional[Literal["on", "off"]]` The status of Cache Deception Armor. - `"on"` - `"off"` - `class ActionCacheKeyFields: …` - `id: Optional[Literal["cache_key_fields"]]` Control specifically what variables to include when deciding which resources to cache. This allows customers to determine what to cache based on something other than just the URL. - `"cache_key_fields"` - `value: Optional[ActionCacheKeyFieldsValue]` - `cookie: Optional[ActionCacheKeyFieldsValueCookie]` Controls which cookies appear in the Cache Key. - `check_presence: Optional[List[str]]` A list of cookies to check for the presence of, without including their actual values. - `include: Optional[List[str]]` A list of cookies to include. - `header: Optional[ActionCacheKeyFieldsValueHeader]` Controls which headers go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `check_presence: Optional[List[str]]` A list of headers to check for the presence of, without including their actual values. - `exclude: Optional[List[str]]` A list of headers to ignore. - `include: Optional[List[str]]` A list of headers to include. - `host: Optional[ActionCacheKeyFieldsValueHost]` Determines which host header to include in the Cache Key. - `resolved: Optional[bool]` Whether to include the Host header in the HTTP request sent to the origin. - `query_string: Optional[ActionCacheKeyFieldsValueQueryString]` Controls which URL query string parameters go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `exclude: Optional[Union[Literal["*"], List[str], null]]` Ignore all query string parameters. - `Literal["*"]` Ignore all query string parameters. - `"*"` - `List[str]` A list of query string parameters to ignore. - `include: Optional[Union[Literal["*"], List[str], null]]` Include all query string parameters. - `Literal["*"]` Include all query string parameters. - `"*"` - `List[str]` A list of query string parameters to include. - `user: Optional[ActionCacheKeyFieldsValueUser]` Feature fields to add features about the end-user (client) into the Cache Key. - `device_type: Optional[bool]` Classifies a request as `mobile`, `desktop`, or `tablet` based on the User Agent. - `geo: Optional[bool]` Includes the client's country, derived from the IP address. - `lang: Optional[bool]` Includes the first language code contained in the `Accept-Language` header sent by the client. - `class CacheLevel: …` - `id: Optional[Literal["cache_level"]]` Apply custom caching based on the option selected. - `"cache_level"` - `value: Optional[Literal["bypass", "basic", "simplified", 2 more]]` * `bypass`: Cloudflare does not cache. * `basic`: Delivers resources from cache when there is no query string. * `simplified`: Delivers the same resource to everyone independent of the query string. * `aggressive`: Caches all static content that has a query string. * `cache_everything`: Treats all content as static and caches all file types beyond the [Cloudflare default cached content](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#default-cached-file-extensions). - `"bypass"` - `"basic"` - `"simplified"` - `"aggressive"` - `"cache_everything"` - `class ActionCacheOnCookie: …` - `id: Optional[Literal["cache_on_cookie"]]` Apply the Cache Everything option (Cache Level setting) based on a regular expression match against a cookie name. - `"cache_on_cookie"` - `value: Optional[str]` The regular expression to use for matching cookie names in the request. - `class ActionCacheTTLByStatus: …` - `id: Optional[Literal["cache_ttl_by_status"]]` Enterprise customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as stale or discarded from cache. Status codes are returned by a resource's origin. Setting cache TTL based on response status overrides the default cache behavior (standard caching) for static files and overrides cache instructions sent by the origin web server. To cache non-static assets, set a Cache Level of Cache Everything using a Page Rule. Setting no-store Cache-Control or a low TTL (using `max-age`/`s-maxage`) increases requests to origin web servers and decreases performance. - `"cache_ttl_by_status"` - `value: Optional[Dict[str, Union[Literal["no-cache", "no-store"], int]]]` A JSON object containing status codes and their corresponding TTLs. Each key-value pair in the cache TTL by status cache rule has the following syntax - `status_code`: An integer value such as 200 or 500. status_code matches the exact status code from the origin web server. Valid status codes are between 100-999. - `status_code_range`: Integer values for from and to. status_code_range matches any status code from the origin web server within the specified range. - `value`: An integer value that defines the duration an asset is valid in seconds or one of the following strings: no-store (equivalent to -1), no-cache (equivalent to 0). - `Literal["no-cache", "no-store"]` `no-store` (equivalent to -1), `no-cache` (equivalent to 0) - `"no-cache"` - `"no-store"` - `int` An integer value that defines the duration an asset is valid in seconds. - `class ActionDisableApps: …` - `id: Optional[Literal["disable_apps"]]` Turn off all active [Cloudflare Apps](https://developers.cloudflare.com/support/more-dashboard-apps/cloudflare-apps/) (deprecated). - `"disable_apps"` - `class ActionDisablePerformance: …` - `id: Optional[Literal["disable_performance"]]` Turn off [Rocket Loader](https://developers.cloudflare.com/speed/optimization/content/rocket-loader/), and [Polish](https://developers.cloudflare.com/images/polish/). - `"disable_performance"` - `class ActionDisableSecurity: …` - `id: Optional[Literal["disable_security"]]` Turn off [Email Obfuscation](https://developers.cloudflare.com/waf/tools/scrape-shield/email-address-obfuscation/), [Rate Limiting (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/), [Scrape Shield](https://developers.cloudflare.com/waf/tools/scrape-shield/), [URL (Zone) Lockdown](https://developers.cloudflare.com/waf/tools/zone-lockdown/), and [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). - `"disable_security"` - `class ActionDisableZaraz: …` - `id: Optional[Literal["disable_zaraz"]]` Turn off [Zaraz](https://developers.cloudflare.com/zaraz/). - `"disable_zaraz"` - `class ActionEdgeCacheTTL: …` - `id: Optional[Literal["edge_cache_ttl"]]` Specify how long to cache a resource in the Cloudflare global network. *Edge Cache TTL* is not visible in response headers. - `"edge_cache_ttl"` - `value: Optional[int]` - `class EmailObfuscation: …` - `id: Optional[Literal["email_obfuscation"]]` Turn on or off **Email Obfuscation**. - `"email_obfuscation"` - `value: Optional[Literal["on", "off"]]` The status of Email Obfuscation. - `"on"` - `"off"` - `class ActionExplicitCacheControl: …` - `id: Optional[Literal["explicit_cache_control"]]` Origin Cache Control is enabled by default for Free, Pro, and Business domains and disabled by default for Enterprise domains. - `"explicit_cache_control"` - `value: Optional[Literal["on", "off"]]` The status of Origin Cache Control. - `"on"` - `"off"` - `class ActionForwardingURL: …` - `id: Optional[Literal["forwarding_url"]]` Redirects one URL to another using an `HTTP 301/302` redirect. Refer to [Wildcard matching and referencing](https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/). - `"forwarding_url"` - `value: Optional[ActionForwardingURLValue]` - `status_code: Optional[Literal[301, 302]]` The status code to use for the URL redirect. 301 is a permanent redirect. 302 is a temporary redirect. - `301` - `302` - `url: Optional[str]` The URL to redirect the request to. Notes: ${num} refers to the position of '*' in the constraint value. - `class ActionHostHeaderOverride: …` - `id: Optional[Literal["host_header_override"]]` Apply a specific host header. - `"host_header_override"` - `value: Optional[str]` The hostname to use in the `Host` header - `class IPGeolocation: …` - `id: Optional[Literal["ip_geolocation"]]` Cloudflare adds a CF-IPCountry HTTP header containing the country code that corresponds to the visitor. - `"ip_geolocation"` - `value: Optional[Literal["on", "off"]]` The status of adding the IP Geolocation Header. - `"on"` - `"off"` - `class Mirage: …` - `id: Optional[Literal["mirage"]]` Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can accelerate loading of image-heavy websites on very slow mobile connections and HTTP/1. - `"mirage"` - `value: Optional[Literal["on", "off"]]` The status of Mirage. - `"on"` - `"off"` - `class OpportunisticEncryption: …` - `id: Optional[Literal["opportunistic_encryption"]]` Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. It's not a substitute for HTTPS, but provides additional security for otherwise vulnerable requests. - `"opportunistic_encryption"` - `value: Optional[Literal["on", "off"]]` The status of Opportunistic Encryption. - `"on"` - `"off"` - `class OriginErrorPagePassThru: …` - `id: Optional[Literal["origin_error_page_pass_thru"]]` Turn on or off Cloudflare error pages generated from issues sent from the origin server. If enabled, this setting triggers error pages issued by the origin. - `"origin_error_page_pass_thru"` - `value: Optional[Literal["on", "off"]]` The status of Origin Error Page Passthru. - `"on"` - `"off"` - `class Polish: …` - `id: Optional[Literal["polish"]]` Apply options from the Polish feature of the Cloudflare Speed app. - `"polish"` - `value: Optional[Literal["off", "lossless", "lossy"]]` The level of Polish you want applied to your origin. - `"off"` - `"lossless"` - `"lossy"` - `class ActionResolveOverride: …` - `id: Optional[Literal["resolve_override"]]` Change the origin address to the value specified in this setting. - `"resolve_override"` - `value: Optional[str]` The origin address you want to override with. - `class ActionRespectStrongEtag: …` - `id: Optional[Literal["respect_strong_etag"]]` Turn on or off byte-for-byte equivalency checks between the Cloudflare cache and the origin server. - `"respect_strong_etag"` - `value: Optional[Literal["on", "off"]]` The status of Respect Strong ETags - `"on"` - `"off"` - `class ResponseBuffering: …` - `id: Optional[Literal["response_buffering"]]` Turn on or off whether Cloudflare should wait for an entire file from the origin server before forwarding it to the site visitor. By default, Cloudflare sends packets to the client as they arrive from the origin server. - `"response_buffering"` - `value: Optional[Literal["on", "off"]]` The status of Response Buffering - `"on"` - `"off"` - `class RocketLoader: …` - `id: Optional[Literal["rocket_loader"]]` Turn on or off Rocket Loader in the Cloudflare Speed app. - `"rocket_loader"` - `value: Optional[Literal["on", "off"]]` The status of Rocket Loader - `"on"` - `"off"` - `class SecurityLevel: …` - `id: Optional[Literal["security_level"]]` Control options for the **Security Level** feature from the **Security** app. - `"security_level"` - `value: Optional[Literal["off", "essentially_off", "low", 3 more]]` - `"off"` - `"essentially_off"` - `"low"` - `"medium"` - `"high"` - `"under_attack"` - `class SortQueryStringForCache: …` - `id: Optional[Literal["sort_query_string_for_cache"]]` Turn on or off the reordering of query strings. When query strings have the same structure, caching improves. - `"sort_query_string_for_cache"` - `value: Optional[Literal["on", "off"]]` The status of Query String Sort - `"on"` - `"off"` - `class SSL: …` - `id: Optional[Literal["ssl"]]` Control options for the SSL feature of the Edge Certificates tab in the Cloudflare SSL/TLS app. - `"ssl"` - `value: Optional[Literal["off", "flexible", "full", 2 more]]` The encryption mode that Cloudflare uses to connect to your origin server. - `"off"` - `"flexible"` - `"full"` - `"strict"` - `"origin_pull"` - `class TrueClientIPHeader: …` - `id: Optional[Literal["true_client_ip_header"]]` Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. - `"true_client_ip_header"` - `value: Optional[Literal["on", "off"]]` The status of True Client IP Header. - `"on"` - `"off"` - `class WAF: …` - `id: Optional[Literal["waf"]]` Turn on or off [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). You cannot enable or disable individual WAF managed rules via Page Rules. - `"waf"` - `value: Optional[Literal["on", "off"]]` The status of WAF managed rules (previous version). - `"on"` - `"off"` - `created_on: datetime` The timestamp of when the Page Rule was created. - `modified_on: datetime` The timestamp of when the Page Rule was last modified. - `priority: int` 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: Literal["active", "disabled"]` The status of the Page Rule. - `"active"` - `"disabled"` - `targets: List[Target]` The rule targets to evaluate on each request. - `constraint: Optional[Constraint]` String constraint. - `operator: Literal["matches", "contains", "equals", 2 more]` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `"matches"` - `"contains"` - `"equals"` - `"not_equal"` - `"not_contain"` - `value: str` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `target: Optional[Literal["url"]]` A target based on the URL of the request. - `"url"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page_rule = client.page_rules.edit( pagerule_id="023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(page_rule.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "actions": [ { "id": "browser_check", "value": "on" } ], "created_on": "2014-01-01T05:20:00.12345Z", "modified_on": "2014-01-01T05:20:00.12345Z", "priority": 0, "status": "active", "targets": [ { "constraint": { "operator": "matches", "value": "*example.com/images/*" }, "target": "url" } ] } } ```