Create a custom response rule
const url = 'https://dashboard.quantcdn.io/api/v2/organizations/example/projects/example/rules/custom-response';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"domain":["test-domain.com","www.test-domain.com"],"name":"Test custom response rule","uuid":"123e4567-e89b-12d3-a456-426614174000","weight":100,"disabled":false,"url":["/maintenance","/down"],"country":"country_is","country_is":["US","CA","GB"],"country_is_not":["CN","RU"],"method":"method_is","method_is":["GET","POST"],"method_is_not":["DELETE","PUT"],"ip":"ip_is","ip_is":["192.168.1.0/24","10.0.0.1"],"ip_is_not":["172.16.0.0/12"],"custom_response_body":"<html><body>Custom maintenance page</body></html>","custom_response_status_code":200,"status_code":503,"body":"<html><body>Maintenance</body></html>"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://dashboard.quantcdn.io/api/v2/organizations/example/projects/example/rules/custom-response \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "domain": [ "test-domain.com", "www.test-domain.com" ], "name": "Test custom response rule", "uuid": "123e4567-e89b-12d3-a456-426614174000", "weight": 100, "disabled": false, "url": [ "/maintenance", "/down" ], "country": "country_is", "country_is": [ "US", "CA", "GB" ], "country_is_not": [ "CN", "RU" ], "method": "method_is", "method_is": [ "GET", "POST" ], "method_is_not": [ "DELETE", "PUT" ], "ip": "ip_is", "ip_is": [ "192.168.1.0/24", "10.0.0.1" ], "ip_is_not": [ "172.16.0.0/12" ], "custom_response_body": "<html><body>Custom maintenance page</body></html>", "custom_response_status_code": 200, "status_code": 503, "body": "<html><body>Maintenance</body></html>" }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Organization identifier
Project identifier
Request Bodyrequired
Section titled “Request Bodyrequired”object
Exact hostnames the rule matches, or ‘any’ (the default). Wildcards such as *.example.com are not supported.
Example
[ "test-domain.com", "www.test-domain.com"]Rule name
Example
Test custom response ruleRule UUID
Example
123e4567-e89b-12d3-a456-426614174000Rule order. Must be 0 or greater; lower weights are processed first. If omitted on create, the rule is placed last.
Example
100Whether rule is disabled
Example
falseURL patterns
Example
[ "/maintenance", "/down"]Country filter type (country_is, country_is_not, any)
Example
country_isAllowed countries
Example
[ "US", "CA", "GB"]Excluded countries
Example
[ "CN", "RU"]Method filter type (method_is, method_is_not, any)
Example
method_isAllowed HTTP methods
Example
[ "GET", "POST"]Excluded HTTP methods
Example
[ "DELETE", "PUT"]IP filter type (ip_is, ip_is_not, any)
Example
ip_isAllowed IP addresses
Example
[ "192.168.1.0/24", "10.0.0.1"]Excluded IP addresses
Example
[ "172.16.0.0/12"]Custom response body content
Example
<html><body>Custom maintenance page</body></html>HTTP status code for custom response
Example
503Legacy field for status code (deprecated)
Example
503Legacy field for response body (deprecated)
Example
<html><body>Maintenance</body></html>Responses
Section titled “Responses”The request has succeeded.
object
Rule name
Rule UUID
Rule ID
Rule order. Must be 0 or greater; lower weights are processed first. If omitted on create, the rule is placed last.
URL patterns
Exact hostnames the rule matches, or ‘any’. Wildcards are not supported.
Whether rule is disabled
Only apply with cookie
HTTP method
Allowed HTTP methods
Excluded HTTP methods
IP address
Allowed IP addresses
Excluded IP addresses
ASN condition type (asn_is, asn_is_not, any). Returned for rules set in the dashboard; this API does not set ASN conditions on create or update.
Allowed AS numbers
Excluded AS numbers
Country code
Allowed countries
Excluded countries
Rule action
object
Custom response body content
HTTP status code for custom response
Example
{ "name": "Test redirect rule", "uuid": "123e4567-e89b-12d3-a456-426614174000", "rule_id": "rule-001", "weight": 100, "url": [ "/old-path/*", "/legacy/*" ], "domain": [ "test-domain.com", "www.test-domain.com" ], "disabled": false, "only_with_cookie": "session_id", "method": "GET", "method_is": [ "GET", "POST" ], "method_is_not": [ "DELETE", "PUT" ], "ip": "192.168.1.1", "ip_is": [ "192.168.1.0/24", "10.0.0.1" ], "ip_is_not": [ "172.16.0.0/12" ], "asn": "any", "asn_is": [ "15169", "8075" ], "asn_is_not": [ "13335" ], "country": "US", "country_is": [ "US", "CA", "GB" ], "country_is_not": [ "CN", "RU" ], "action": "redirect", "action_config": { "custom_response_body": "<html><body>Custom maintenance page</body></html>", "custom_response_status_code": 200 }}The server could not understand the request due to invalid syntax.
object
Error message
Error flag
Example
{ "message": "The requested resource was not found", "error": true}Access is forbidden.
object
Error message
Error flag
Example
{ "message": "The requested resource was not found", "error": true}Another request is changing this project’s rules, or the rule is managed in code. Retry after a short delay; a managed rule changes only through a rules deploy.
object
Error message
Error flag
Example
{ "message": "The requested resource was not found", "error": true}