1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20

Rules Engine

Edit on GitHub

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

  1. Retrieving a list of rules in Rules Engine
  2. Retrieving 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. Retrieving a list of rules in Rules Engine

It returns a list of rules in Rules Engine.

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

Required permission: View Edge Application

Parameter Description Type Type of Data
Authorization
*required
Authentication through the Token, previously created through the endpoint of Token Creation. header string
Accept
*required
Details about the type of return and version. header string;
application/json;version=3
:edge_application_id
*required
The id of the edge application you plan to query. path number
:phase
*required
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. Retrieving details of a rule in Rules Engine

It details 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:

Required permission View Edge Application

Parameter Description Type Type of Data
Authorization
*required
Authentication through the Token, previously created through the endpoint of Token Creation. header string
Accept
*required
Details about the type of return and version. header string;
application/json;version=3
:edge_application_id
*required
The id of the edge application you plan to query. path number
:phase
*required
The processing phase you can manipulate on Rules Engine. path string
:rule_id
*required
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

It 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:

Required permission: Edit Edge Application

Parameter Description Type Type of Data
Authorization
*required
Authentication through the Token, previously created through the endpoint of Token Creation. header string
Accept
*required
Details about the type of return and version. header string;
application/json;version=3
:edge_application_id
*required
The id of the edge application you plan to delete. path number
:phase
*required
The processing phase you can manipulate on Rules Engine. path string
:rule_id
*required
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

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

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

Required permission Edit Security Settings

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

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

Check below the list of behaviors that can be applied:

Name 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

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

It 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:

Required permission: Edit Edge Application

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

Example:
Content-Type: application/json
header string
:edge_application_id
*required
The id of the edge application you plan to overwrite. path number
:phase
*required
The processing phase you can manipulate on Rules Engine. path string
:rule_id *
*required
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

It 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:

Required permission: Edit Edge Application

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

Example:
Content-Type: application/json
header string
:edge_application_id
*required
The id of the edge application you plan to update. path number
:phase
*required
The processing phase you can manipulate on Rules Engine. path string
:rule_id
*required
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? Open a support ticket.