Cloudflare\Zone\Pagerules::create PHP Method

create() public method

Create a page rule [BETA] (permission needed: #zone:edit)
public create ( string $zone_identifier, array $targets, array $actions, integer | null $priority = null, string | null $status = 'active' )
$zone_identifier string API item identifier tag
$targets array Targets to evaluate on a request
$actions array The set of actions to perform if the targets of this rule match the request. Actions can redirect the url to another url or override settings (but not both)
$priority integer | null A number that indicates the preference for a page rule over another. In the case where you may have a catch-all page rule (e.g., #1: '/images/') but want a rule that is more specific to take precedence (e.g., #2: '/images/special/'), you'll want to specify a higher priority on the latter (#2) so it will override the first.
$status string | null Status of the page rule
    public function create($zone_identifier, $targets, $actions, $priority = null, $status = 'active')
    {
        $data = ['targets' => $targets, 'actions' => $actions, 'priority' => $priority, 'status' => $status];
        return $this->post('zones/' . $zone_identifier . '/pagerules', $data);
    }