Skip to main content
InfoThis feature is available in selected plans. For up-to-date information on plan availability, see the billing documentation.
Similarly to WAAP custom rules, you can create, edit, and manage advanced custom rules. These rules also contain “If/Then” statements, but they support more complex conditions created with the Common Expression Language (CEL) syntax.

Create advanced rules

Due to the highly technical aspect of the advanced rules functionality, the ability to create and edit these rules is currently only available through our API. Check out the following guides for details on how to create advanced rules and their key components:
  • API docs: Learn how to construct and manage advanced rules.
  • Advanced rule objects and attributes: Get the list of all available objects you can use in rule expressions along with their respective attributes and types.
  • Source field objects: Check the available source field objects you can use in your expressions along with their respective attributes and types.
An API token is required along with the ID of a WAAP-protected domain. Set these as environment variables before running any of the examples:

Advanced rule properties

The advanced rule object contains the following properties:
InfoEach rule can contain only one action ΓÇö block, allow, captcha, handshake, or tag. If you use multiple actions in a single rule, the API will return an error.

Best practices

You can use our API documentation as a guide when constructing your own advanced rules. The following sections provide examples of advanced rules and the key CEL expressions used in each.
NoteExamples are illustrative. Field values (paths, cookies, IPs, countries) should be adapted to the customer’s environment.

Rate limiting

Rate-limit IPs based on the number of requests they make to your website. This can be useful for mitigating scrapers or automated clients that generate a high volume of requests over a short period of time. The following rule limits the rate of requests an IP can send for 10 minutes when it exceeds 200 requests in 5 seconds, but excludes requests from mobile or web clients that have specific cookies. You can find more examples in our Rate limiting guide.

The penalty tag

The WAAP system appends the penalty tag to the local (domain-related) IP record when an IP address triggers a block rule configured with an action_duration parameter. To continue blocking an IP address after the original rule’s conditions are no longer met, include a penalty tag check in the rule’s source conditions (for example, using tags.exists('penalty')), or define a separate rule that targets requests carrying the penalty tag.

Block all penalty requests

The following rule blocks requests from IP addresses tagged with the penalty tag, allowing block actions applied by other rules to persist.

Other examples

Validate a set of countries

Applies browser validation (JavaScript-based challenge) using the handshake action to requests originating from specific countries, based on the whois.country field, while excluding requests that contain certain cookies.

Add clients to allow list

Allow requests from specific IP addresses or IP ranges by matching IP values in the rule condition.

Tag and allow registered clients

Tag requests based on the presence of a specific cookie and allow requests associated with the assigned tag. When defining tag values in JSON, double quotation marks must be used, while string values inside rule expressions must be enclosed in single quotation marks.

Define login pages

Tag requests that match specific URL patterns using string matching on the request URI.

List rules

Retrieve all advanced rules configured for a domain, including their current enabled state, actions, and CEL source expressions.
The rules are also visible in the Gcore Customer Portal, where they can be enabled, disabled, or deleted:
Advanced rules section in WAAP Customer Portal

Update a rule

Update any combination of a rule’s name, description, enabled state, action, phase, or source expression. Only fields included in the request body are changed. The API returns 204 with no body on success.

Enable and disable a rule

Switch a rule between active and inactive without deleting it. Disabling a rule stops it from matching requests while preserving its configuration. The API returns 204 with no body for both operations.

Delete a rule

Delete a rule by ID. The operation is irreversible and returns 204 with no body on success.