Behaviors

Both default and children rules include a set of behaviors, represented as an array of objects. This simple example features the two behaviors that are always necessary to activate your property, though, depending on the product, new properties may come with sets of default rules that also include other behaviors. The origin behavior determines how the edge network interacts with your origin servers, and you need the cpCode behavior for billing and reporting on traffic.

{
    "rules": {
        "name": "default",
        "options": {
            "is_secure": false
        },
        "behaviors": [
            {
                "name": "origin",
                "options": {
                    "originType": "CUSTOMER",
                    "hostname": "example.com",
                    "forwardHostHeader": "REQUEST_HOST_HEADER",
                    "cacheKeyHostname": "ORIGIN_HOSTNAME",
                    "compress": true,
                    "tcipEnabled": false,
                    "httpPort": 80
                }
            },
            {
                "name": "cpCode",
                "options": {
                    "value": {
                        "id": 12345,
                        "name": "main site"
                    }
                }
            }
        ]
    }
}

While nominally optional, default rules typically also specify a caching behavior to position the content on the edge, and a report behavior to refine the information you receive in traffic reports.

Each behavior object is identified by a name field. It may also feature a locked member, and most require a nested options object. Some behaviors only feature an enabled option that toggles whether the behavior is activated, while others require more fields once they're activated. The exact set of options you need to specify for each behavior often varies depending on what you're trying to do, and some options are required based on the value of others. The behavior and criteria reference details the requirements for each option.

In the origin example above, the originType is set to CUSTOMER, in which case your own server is the origin and you need to identify it with the hostname field. If the originType were set to any other value, the hostname would be unnecessary and thus ignored. PAPI silently ignores any unexpected values, but it always warns you about any expected values that are missing. For example, setting the originType to NET_STORAGE would require another netStorage option providing details about your NetStorage account.