PATCH
/
cdn
/
resources
/
rule_templates
/
{rule_template_id}
Change rule template
curl --request PATCH \
  --url https://api.gcore.com/cdn/resources/rule_templates/{rule_template_id} \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "All images template",
  "rule": "/folder/images/*.png",
  "ruleType": 0,
  "weight": 1,
  "overrideOriginProtocol": null,
  "options": {
    "allowedHttpMethods": {
      "enabled": true,
      "value": [
        "GET",
        "POST"
      ]
    },
    "bot_protection": {
      "enabled": true,
      "bot_challenge": {
        "enabled": true
      }
    },
    "brotli_compression": {
      "enabled": true,
      "value": [
        "text/html",
        "text/plain"
      ]
    },
    "browser_cache_settings": {
      "enabled": true,
      "value": "3600s"
    },
    "cache_http_headers": {
      "enabled": false,
      "value": [
        "vary",
        "content-length",
        "last-modified",
        "connection",
        "accept-ranges",
        "content-type",
        "content-encoding",
        "etag",
        "cache-control",
        "expires",
        "keep-alive",
        "server"
      ]
    },
    "cors": {
      "enabled": true,
      "value": [
        "domain.com",
        "domain2.com"
      ],
      "always": true
    },
    "country_acl": {
      "enabled": true,
      "policy_type": "allow",
      "excepted_values": [
        "GB",
        "DE"
      ]
    },
    "disable_cache": {
      "enabled": true,
      "value": false
    },
    "disable_proxy_force_ranges": {
      "enabled": true,
      "value": true
    },
    "edge_cache_settings": {
      "enabled": true,
      "value": "43200s",
      "custom_values": {
        "100": "43200s"
      }
    },
    "fastedge": {
      "enabled": true,
      "on_request_headers": {
        "enabled": true,
        "app_id": "1001",
        "interrupt_on_error": true
      }
    },
    "fetch_compressed": {
      "enabled": true,
      "value": false
    },
    "follow_origin_redirect": {
      "enabled": true,
      "codes": [
        302,
        308
      ]
    },
    "force_return": {
      "enabled": true,
      "code": 301,
      "body": "http://example.com/redirect_address",
      "time_interval": {
        "start_time": "09:00",
        "end_time": 1200,
        "time_zone": "CET"
      }
    },
    "forward_host_header": {
      "enabled": false,
      "value": false
    },
    "gzipOn": {
      "enabled": true,
      "value": true
    },
    "hostHeader": {
      "enabled": true,
      "value": "host.com"
    },
    "ignore_cookie": {
      "enabled": true,
      "value": true
    },
    "ignoreQueryString": {
      "enabled": true,
      "value": false
    },
    "image_stack": {
      "enabled": true,
      "avif_enabled": true,
      "webp_enabled": false,
      "quality": 80,
      "png_lossless": true
    },
    "ip_address_acl": {
      "enabled": true,
      "policy_type": "deny",
      "excepted_values": [
        "192.168.1.100/32"
      ]
    },
    "limit_bandwidth": {
      "enabled": true,
      "limit_type": "static",
      "speed": 100,
      "buffer": 200
    },
    "proxy_cache_key": {
      "enabled": true,
      "value": "$scheme$uri"
    },
    "proxy_cache_methods_set": {
      "enabled": true,
      "value": false
    },
    "proxy_connect_timeout": {
      "enabled": true,
      "value": "4s"
    },
    "proxy_read_timeout": {
      "enabled": true,
      "value": "10s"
    },
    "query_params_blacklist": {
      "enabled": true,
      "value": [
        "some",
        "blacklisted",
        "query"
      ]
    },
    "query_params_whitelist": {
      "enabled": true,
      "value": [
        "some",
        "whitelisted",
        "query"
      ]
    },
    "query_string_forwarding": {
      "enabled": true,
      "forward_from_file_types": [
        "m3u8",
        "mpd"
      ],
      "forward_to_file_types": [
        "ts",
        "mp4"
      ]
    },
    "redirect_http_to_https": {
      "enabled": true,
      "value": true
    },
    "redirect_https_to_http": {
      "enabled": false,
      "value": true
    },
    "referrer_acl": {
      "enabled": true,
      "policy_type": "deny",
      "excepted_values": [
        "example.com",
        "*.example.net"
      ]
    },
    "request_limiter": {
      "enabled": true,
      "rate_unit": "r/s",
      "rate": 5,
      "burst": 5,
      "delay": 0
    },
    "response_headers_hiding_policy": {
      "enabled": true,
      "mode": "hide",
      "excepted": [
        "my-header"
      ]
    },
    "rewrite": {
      "enabled": true,
      "body": "/(.*) /additional_path/$1",
      "flag": "break"
    },
    "secure_key": {
      "enabled": true,
      "key": "secretkey",
      "type": 2
    },
    "slice": {
      "enabled": true,
      "value": true
    },
    "sni": {
      "enabled": true,
      "sni_type": "custom",
      "custom_hostname": "custom.example.com"
    },
    "stale": {
      "enabled": true,
      "value": [
        "http_404",
        "http_500"
      ]
    },
    "static_response_headers": {
      "enabled": true,
      "value": [
        {
          "name": "X-Example",
          "value": [
            "Value_1"
          ],
          "always": true
        },
        {
          "name": "X-Example-Multiple",
          "value": [
            "Value_1",
            "Value_2",
            "Value_3"
          ],
          "always": false
        }
      ]
    },
    "staticHeaders": {
      "enabled": true,
      "value": {
        "X-Example": "Value_1",
        "X-Example-Multiple": [
          "Value_2",
          "Value_3"
        ]
      }
    },
    "staticRequestHeaders": {
      "enabled": true,
      "value": {
        "Header-One": "Value 1",
        "Header-Two": "Value 2"
      }
    },
    "user_agent_acl": {
      "enabled": true,
      "policy_type": "allow",
      "excepted_values": [
        "UserAgent Value",
        ""
      ]
    },
    "websockets": {
      "enabled": true,
      "value": true
    }
  }
}'
{
  "id": 5,
  "name": "All images template",
  "client": 7,
  "deleted": false,
  "rule": "/folder/images/*.png",
  "ruleType": 0,
  "weight": 1,
  "template": true,
  "default": false,
  "overrideOriginProtocol": null,
  "options": {
    "allowedHttpMethods": {
      "enabled": true,
      "value": [
        "GET",
        "POST"
      ]
    },
    "bot_protection": {
      "enabled": true,
      "bot_challenge": {
        "enabled": true
      }
    },
    "brotli_compression": {
      "enabled": true,
      "value": [
        "text/html",
        "text/plain"
      ]
    },
    "browser_cache_settings": {
      "enabled": true,
      "value": "3600s"
    },
    "cache_http_headers": {
      "enabled": false,
      "value": [
        "vary",
        "content-length",
        "last-modified",
        "connection",
        "accept-ranges",
        "content-type",
        "content-encoding",
        "etag",
        "cache-control",
        "expires",
        "keep-alive",
        "server"
      ]
    },
    "cors": {
      "enabled": true,
      "value": [
        "domain.com",
        "domain2.com"
      ],
      "always": true
    },
    "country_acl": {
      "enabled": true,
      "policy_type": "allow",
      "excepted_values": [
        "GB",
        "DE"
      ]
    },
    "disable_cache": {
      "enabled": true,
      "value": false
    },
    "disable_proxy_force_ranges": {
      "enabled": true,
      "value": true
    },
    "edge_cache_settings": {
      "enabled": true,
      "value": "43200s",
      "custom_values": {
        "100": "43200s"
      }
    },
    "fastedge": {
      "enabled": true,
      "on_request_headers": {
        "enabled": true,
        "app_id": "1001",
        "interrupt_on_error": true
      }
    },
    "fetch_compressed": {
      "enabled": true,
      "value": false
    },
    "follow_origin_redirect": {
      "enabled": true,
      "codes": [
        302,
        308
      ]
    },
    "force_return": {
      "enabled": true,
      "code": 301,
      "body": "http://example.com/redirect_address",
      "time_interval": {
        "start_time": "09:00",
        "end_time": 1200,
        "time_zone": "CET"
      }
    },
    "forward_host_header": {
      "enabled": false,
      "value": false
    },
    "gzipOn": {
      "enabled": true,
      "value": true
    },
    "hostHeader": {
      "enabled": true,
      "value": "host.com"
    },
    "ignore_cookie": {
      "enabled": true,
      "value": true
    },
    "ignoreQueryString": {
      "enabled": true,
      "value": false
    },
    "image_stack": {
      "enabled": true,
      "avif_enabled": true,
      "webp_enabled": false,
      "quality": 80,
      "png_lossless": true
    },
    "ip_address_acl": {
      "enabled": true,
      "policy_type": "deny",
      "excepted_values": [
        "192.168.1.100/32"
      ]
    },
    "limit_bandwidth": {
      "enabled": true,
      "limit_type": "static",
      "speed": 100,
      "buffer": 200
    },
    "proxy_cache_key": {
      "enabled": true,
      "value": "$scheme$uri"
    },
    "proxy_cache_methods_set": {
      "enabled": true,
      "value": false
    },
    "proxy_connect_timeout": {
      "enabled": true,
      "value": "4s"
    },
    "proxy_read_timeout": {
      "enabled": true,
      "value": "10s"
    },
    "query_params_blacklist": {
      "enabled": true,
      "value": [
        "some",
        "blacklisted",
        "query"
      ]
    },
    "query_params_whitelist": {
      "enabled": true,
      "value": [
        "some",
        "whitelisted",
        "query"
      ]
    },
    "query_string_forwarding": {
      "enabled": true,
      "forward_from_file_types": [
        "m3u8",
        "mpd"
      ],
      "forward_to_file_types": [
        "ts",
        "mp4"
      ]
    },
    "redirect_http_to_https": {
      "enabled": true,
      "value": true
    },
    "redirect_https_to_http": {
      "enabled": false,
      "value": true
    },
    "referrer_acl": {
      "enabled": true,
      "policy_type": "deny",
      "excepted_values": [
        "example.com",
        "*.example.net"
      ]
    },
    "request_limiter": {
      "enabled": true,
      "rate_unit": "r/s",
      "rate": 5,
      "burst": 5,
      "delay": 0
    },
    "response_headers_hiding_policy": {
      "enabled": true,
      "mode": "hide",
      "excepted": [
        "my-header"
      ]
    },
    "rewrite": {
      "enabled": true,
      "body": "/(.*) /additional_path/$1",
      "flag": "break"
    },
    "secure_key": {
      "enabled": true,
      "key": "secretkey",
      "type": 2
    },
    "slice": {
      "enabled": true,
      "value": true
    },
    "sni": {
      "enabled": true,
      "sni_type": "custom",
      "custom_hostname": "custom.example.com"
    },
    "stale": {
      "enabled": true,
      "value": [
        "http_404",
        "http_500"
      ]
    },
    "static_response_headers": {
      "enabled": true,
      "value": [
        {
          "name": "X-Example",
          "value": [
            "Value_1"
          ],
          "always": true
        },
        {
          "name": "X-Example-Multiple",
          "value": [
            "Value_1",
            "Value_2",
            "Value_3"
          ],
          "always": false
        }
      ]
    },
    "staticHeaders": {
      "enabled": true,
      "value": {
        "X-Example": "Value_1",
        "X-Example-Multiple": [
          "Value_2",
          "Value_3"
        ]
      }
    },
    "staticRequestHeaders": {
      "enabled": true,
      "value": {
        "Header-One": "Value 1",
        "Header-Two": "Value 2"
      }
    },
    "user_agent_acl": {
      "enabled": true,
      "policy_type": "allow",
      "excepted_values": [
        "UserAgent Value",
        ""
      ]
    },
    "websockets": {
      "enabled": true,
      "value": true
    }
  }
}

Authorizations

Authorization
string
header
required

API key for authentication. Make sure to include the word apikey, followed by a single space and then your token. Example: apikey 1234$abcdef

Path Parameters

rule_template_id
integer
required

Rule template ID.

Body

application/json
name
string

Rule template name.

Example:

"All images template"

rule
string

Path to the file or folder for which the rule will be applied. The rule is applied if the requested URI matches the rule path. We add a leading forward slash to any rule path. Specify a path without a forward slash.

Maximum length: 300
Example:

"/folder/images/*.png"

ruleType
integer

Rule type. Possible values:

  • Type 0 - Regular expression. Must start with '^/' or '/'.
  • Type 1 - Regular expression. Note that for this rule type we automatically add / to each rule pattern before your regular expression. This type is legacy, please use Type 0.
Required range: 0 <= x <= 1
Example:

0

weight
integer

Rule execution order: from lowest (1) to highest. If requested URI matches multiple rules, the one higher in the order of the rules will be applied.

Required range: 1 <= x <= 2147483647
Example:

1

overrideOriginProtocol
enum<string> | null

Sets a protocol other than the one specified in the CDN resource settings to connect to the origin. Possible values:

  • HTTPS - CDN servers connect to origin via HTTPS protocol.
  • HTTP - CDN servers connect to origin via HTTP protocol.
  • MATCH - Connection protocol is chosen automatically; in this case, content on origin source should be available for the CDN both through HTTP and HTTPS protocols.
  • null - originProtocol setting is inherited from the CDN resource settings.
Available options:
HTTPS,
HTTP,
MATCH
Example:

null

options
object

List of options that can be configured for the rule. In case of null value the option is not added to the rule. Option inherits its value from the CDN resource settings.

Response

200 - application/json

Successful.

id
integer

Rule template ID.

Example:

5

name
string

Rule template name.

Example:

"All images template"

client
integer

Client ID

Example:

7

deleted
boolean

Defines whether the template has been deleted. Possible values:

  • true - Template has been deleted.
  • false - Template has not been deleted.
Example:

false

rule
string

Path to the file or folder for which the rule will be applied. The rule is applied if the requested URI matches the rule path. We add a leading forward slash to any rule path. Specify a path without a forward slash.

Maximum length: 300
Example:

"/folder/images/*.png"

ruleType
integer

Rule type. Possible values:

  • Type 0 - Regular expression. Must start with '^/' or '/'.
  • Type 1 - Regular expression. Note that for this rule type we automatically add / to each rule pattern before your regular expression. This type is legacy, please use Type 0.
Required range: 0 <= x <= 1
Example:

0

weight
integer

Rule execution order: from lowest (1) to highest. If requested URI matches multiple rules, the one higher in the order of the rules will be applied.

Required range: 1 <= x <= 2147483647
Example:

1

template
boolean

Determines whether the rule is a template.

Example:

true

default
boolean

Defines whether the template is a system template developed for common cases. System templates are available to all customers. Possible values:

  • true - Template is a system template and cannot be changed by a user.
  • false - Template is a custom template and can be changed by a user.
Example:

false

overrideOriginProtocol
enum<string> | null

Sets a protocol other than the one specified in the CDN resource settings to connect to the origin. Possible values:

  • HTTPS - CDN servers connect to origin via HTTPS protocol.
  • HTTP - CDN servers connect to origin via HTTP protocol.
  • MATCH - Connection protocol is chosen automatically; in this case, content on origin source should be available for the CDN both through HTTP and HTTPS protocols.
  • null - originProtocol setting is inherited from the CDN resource settings.
Available options:
HTTPS,
HTTP,
MATCH
Example:

null

options
object

List of options that can be configured for the rule. In case of null value the option is not added to the rule. Option inherits its value from the CDN resource settings.