Rules Engine

Edit on GitHub

With the API of Rules Engine, you can check, remove or update existing settings, besides creating new ones.

  1. Looking up a list of rules in Rules Engine
  2. Looking up details of a rule in Rules Engine
  3. Deleting a rule in Rules Engine
  4. Creating a new rule in Rules Engine
  5. Overwriting a rule in Rules Engine
  6. Updating the fields of a rule in Rules Engine

1. Looking up a list of rules in Rules Engine

This return results in a list of rules in Rules Engine.

GET /edge_applications/:edge_application_id:/rules_engine/:phase:/rules

Necessary permission: View Edge Application

Mandatory parameters

Parameter Description Type Type of Data
Authorization (mandatory) Authentication through the Token, previously created through the endpoint of Token Creation header string
Accept (mandatory) Details about the type of return and version header string;
application/json;version=3
:edge_application_id (mandatory) The id of the edge application you plan to query path number
:phase
(mandatory)
The processing phase you can manipulate on Rules Engine path string

Request Example

GET /edge_applications/1601406733/rules_engine/request/rules
Accept: application/json; version=3
Authorization: token cf2078926f91a6e638af3f4a6977b505edfe5941

Response Example

{
    "count": 4,
    "total_pages": 1,
    "schema_version": 3,
    "links": {
        "previous": null,
        "next": null
    },
    "results": [
        {
            "id": 9539,
            "name": "Image",
            "phase": "request",
            "behaviors": [
                {
                    "name": "bypass_cache_phase",
                    "target": null
                },
                {
                    "name": "optimize_images",
                    "target": null
                }
            ],
            "criteria": [
                [
                    {
                        "variable": "${request_uri}",
                        "operator": "matches",
                        "conditional": "if",
                        "input_value": "\\.(jpg|jpeg|gif|bmp|png)"
                    }
                ]
            ],
            "is_active": true,
            "order": 1
        },
        {
            "id": 14086,
            "name": "The Rule",
            "phase": "request",
            "behaviors": [
                {
                    "name": "bypass_cache_phase",
                    "target": null
                }
            ],
            "criteria": [
                [
                    {
                        "variable": "${uri}",
                        "operator": "starts_with",
                        "conditional": "if",
                        "input_value": "/"
                    },
                    {
                        "variable": "${uri}",
                        "operator": "does_not_start_with",
                        "conditional": "and",
                        "input_value": "/if"
                    }
                ]
            ],
            "is_active": true,
            "order": 2
        }
    ]
}

2. Looking up details of a rule in Rules Engine

Results in details of a rule in Rules Engine. The information originated by this return refers to the Rules Engine of an Edge Application.

GET /edge_applications/:edge_application_id:/rules_engine/:phase:/rules/:rule_id:

Necessary permission: View Edge Application

Mandatory parameters

Parameter Description Type Type of Data
Authorization (mandatory) Authentication through the Token, previously created through the endpoint of Token Creation header string
Accept
(mandatory)
Details about the type of return and version header string;
application/json;version=3
:edge_application_id (mandatory) The id of the edge application you plan to query path number
:phase
(mandatory)
The processing phase you can manipulate on Rules Engine path string
:rule_id
(mandatory)
The id of the rule you plan to query path number

Request Example

GET /edge_applications/1601406733/rules_engine/request/rules/9539
Accept: application/json; version=3
Authorization: token cf2078926f91a6e638af3f4a6977b505edfe5941

Response Example

{
    "results": {
        "id": 9539,
        "name": "Image",
        "phase": "request",
        "criteria": [
            [
                {
                    "variable": "${request_uri}",
                    "operator": "matches",
                    "conditional": "if",
                    "input_value": "\\.(jpg|jpeg|gif|bmp|png)"
                }
            ]
        ],
        "behaviors": [
            {
                "name": "bypass_cache_phase",
                "target": null
            },
            {
                "name": "optimize_images",
                "target": null
            }
        ],
        "is_active": true,
        "order": 1
    },
    "schema_version": 3
}

3. Deleting a rule in Rules Engine

This return removes a rule in Rules Engine. This operation is final: there is no way to roll back the information after it has been confirmed by the user.

All information associated with this rule will also be removed.

The API does not require confirmation in order to run this instruction.

DELETE /edge_applications/:edge_application_id:/rules_engine/:phase:/rules/:rule_id:

Necessary permission: Edit Edge Application

Mandatory parameters

Parameter Description Type Type of Data
Authorization (mandatory) Authentication through the Token, previously created through the endpoint of Token Creation header string
Accept
(mandatory)
Details about the type of return and version header string;
application/json;version=3
:edge_application_id (mandatory) The id of the edge application you plan to delete path number
:phase
(mandatory)
The processing phase you can manipulate on Rules Engine path string
:rule_id
(mandatory)
The id of the rule you plan to delete path number

Request Example

DELETE /edge_applications/1601406733/rules_engine/request/rules/14086
Accept: application/json; version=3
Authorization: token 2909f3932069047f4736dc87e72baaddd19c9f75

Response Example

HTTP/2 204

4. Creating a new rule in Rules Engine

This return enables the creation of a new rule in Rules Engine within an Edge Application.

POST /edge_applications/:edge_application_id:/rules_engine/:phase:/rules

Necessary permission: Edit Security Settings

Mandatory parameters

Parameter Description Type Type of Data
Authorization (mandatory) Authentication through the Token, previously created through the endpoint of Token Creation header string
Accept
(mandatory)
Details about the type of return and version header string;
application/json;version=3
Content-Type (mandatory) The type of coding used in the Body (application/json).

e.g.:

Content-Type: application/json
header string
:edge_application_id (mandatory) The id of the edge application you plan to create path number
:phase
(mandatory)
The processing phase you can manipulate on Rules Engine path string
:rule_id
(mandatory)
The id of the rule you plan to create path number

Check below the list of behaviors that can be applied:

Nome Behavior
Add Request Cookie add_request_cookie
Add Request Header add_request_header
Add Response Cookie set_cookie
Add Response Header add_response_header
Bypass Cache bypass_cache_phase
Capture Match Groups capture_match_groups
Deliver deliver
Deny (403 Forbidden) deny
Enable Gzip enable_gzip
Filter Request Cookie filter_request_cookie
Filter Request Header filter_request_header
Filter Response Cookie filter_response_cookie
Filter Response Header filter_response_header
Finish Request Phase finish_request_phase
Forward Cookies forward_cookies
Optimize Images optimize_images
Redirect HTTP to HTTPS redirect_http_to_https
Redirect To (301 Moved Permanently) redirect_to_301
Redirect To (302 Found) redirect_to_302
Rewrite Request rewrite_request
Run Function run_function
Set Cache Policy set_cache_policy
Set Origin set_origin
Set WAF Rule Set filter_request_cookie

Request Example

POST /edge_applications/1601406733/rules_engine/request/rules
Accept: application/json; version=3
Authorization: token cf2078926f91a6e638af3f4a6977b505edfe5941
Content-Type: application/json
{
    "name": "New Rule 1",
    "criteria": [
              		[
                    	{
                    		"conditional": "if",
                    		"variable": "${uri}",
                    		"operator": "starts_with",
                    		"input_value": "/"
                    	},
                    	{
                    		"conditional": "and",
                    		"variable": "${uri}",
                    		"operator": "does_not_start_with",
                    		"input_value": "/if"
                    	}
                	]
            	],
    "behaviors": [
            		{
            			"name": "deliver"
            		}
            	]
}

Response Example

{
    "results": {
        "id": 15116,
        "name": "New Rule",
        "phase": "request",
        "behaviors": [
            {
                "name": "deliver",
                "target": null
            }
        ],
        "criteria": [
            [
                {
                    "variable": "${uri}",
                    "operator": "starts_with",
                    "conditional": "if",
                    "input_value": "/"
                },
                {
                    "variable": "${uri}",
                    "operator": "does_not_start_with",
                    "conditional": "and",
                    "input_value": "/if"
                }
            ]
        ],
        "is_active": true,
        "order": 4
    },
    "schema_version": 3
}

5. Overwriting a rule in Rules Engine

This return overwrites all the fields of a rule in Rules Engine, retaining the id.

If you only want to update some fields without changing the values of the rest, consider using the PATCH method, instead of PUT.

PUT /edge_applications/:edge_application_id:/rules_engine/:phase:/rules/:rule_id:

Necessary Permission: Edit Edge Application

Mandatory parameters

Parameter Description Type Type of Data
Authorization (mandatory) Authentication through the Token, previously created through the endpoint of Token Creation header string
Accept (mandatory) Details about the type of return and version header string;
application/json;version=3
Content-Type (mandatory) The type of coding used in the Body (application/json).

e.g.:

Content-Type: application/json
header string
:edge_application_id (mandatory) The id of the edge application you plan to overwrite path number
:phase (mandatory) The processing phase you can manipulate on Rules Engine path string
:rule_id (mandatory) The id of the rule you plan to overwrite path number

Request Example

PUT /edge_applications/1601406733/rules_engine/request/rules/9539
Accept: application/json; version=3
Authorization: token ec6aabdc0b6bbeed826a36d8731630e36b6e3f24
Content-Type: application/json
{
    "name": "Overwriting The Rule",
    "criteria": [
              		[
                    	{
                    		"conditional": "if",
                    		"variable": "${uri}",
                    		"operator": "starts_with",
                    		"input_value": "/"
                    	},
                    	{
                    		"conditional": "and",
                    		"variable": "${uri}",
                    		"operator": "does_not_start_with",
                    		"input_value": "/if"
                    	}
                	]
            	],
    "behaviors": [
            		{
            			"name": "deliver"
            		}
            	]
}

Response Example

{
    "results": {
        "id": 9539,
        "name": "Overwriting The Rule",
        "phase": "request",
        "behaviors": [
            {
                "name": "deliver",
                "target": null
            }
        ],
        "criteria": [
            [
                {
                    "variable": "${uri}",
                    "operator": "starts_with",
                    "conditional": "if",
                    "input_value": "/"
                },
                {
                    "variable": "${uri}",
                    "operator": "does_not_start_with",
                    "conditional": "and",
                    "input_value": "/if"
                }
            ]
        ],
        "is_active": true,
        "order": 1
    },
    "schema_version": 3
}

6. Updating the fields of a rule in Rules Engine

This return updates one or more fields of a rule in Rules Engine, retaining the value of those fields not included.

PATCH /edge_applications/:edge_application_id:/rules_engine/:phase:/rules/:rule_id:

Necessary permission: Edit Edge Application

Mandatory parameters

Parameter Description Type Type of Data
Authorization (mandatory) Authentication through the Token, previously created through the endpoint of Token Creation header string
Accept (mandatory) Details about the type of return and version header string;
application/json;version=3
Content-Type (mandatory) The type of coding used in the Body (application/json).

e.g.:

Content-Type: application/json
header string
:edge_application_id (mandatory) The id of the edge application you plan to update path number
:phase
(mandatory)
The processing phase you can manipulate on Rules Engine path string
:rule_id
(mandatory)
The id of the rule you plan to update path number

Request Example

PATCH /edge_applications/1601406733/rules_engine/request/rules/9539
Accept: application/json; version=3
Authorization: token ec6aabdc0b6bbeed826a36d8731630e36b6e3f24
Content-Type: application/json
{
    "name": "Updating The Rule",
    "criteria": [
              		[
                    	{
                    		"conditional": "if",
                    		"variable": "${uri}",
                    		"operator": "starts_with",
                    		"input_value": "/"
                    	},
                    	{
                    		"conditional": "and",
                    		"variable": "${uri}",
                    		"operator": "does_not_start_with",
                    		"input_value": "/if"
                    	}
                	]
            	],
    "behaviors": [
            		{
            			"name": "deliver"
            		}
            	]
}

Response Example

{
    "results": {
        "id": 9539,
        "name": "Updating The Rule",
        "phase": "request",
        "behaviors": [
            {
                "name": "deliver",
                "target": null
            }
        ],
        "criteria": [
            [
                {
                    "variable": "${uri}",
                    "operator": "starts_with",
                    "conditional": "if",
                    "input_value": "/"
                },
                {
                    "variable": "${uri}",
                    "operator": "does_not_start_with",
                    "conditional": "and",
                    "input_value": "/if"
                }
            ]
        ],
        "is_active": true,
        "order": 1
    },
    "schema_version": 3
}

Didn’t find what you were looking for? Start a ticket with our support team.