CDN, cache & logs
Per-site CDN configuration, cache layers, edge rules, and access logs. All endpoints are nested under a site.
OAuth scopes: reads require sites:read, writes require sites:write.
On top of the scope, every write on this page requires the can_modify
(edit) role on the site, and deletes generally require can_destroy —
disabling or purging a cache
layer is the exception: both are gated on can_modify, despite being a DELETE. Without the required role the request is rejected
with 403. CDN endpoints return
409 cdn_not_active when the site has no CDN zone, and 502 on an
upstream CDN error.
Like all per-site endpoints, these also inherit the site-level guards — a
dunning-suspended site returns 402 service_suspended and a site pending
deletion returns 403 pending_delete. See Sites.
CDN Status
GET /api/sites/:site_id/cdn
CDN zone status & configuration. Returns 409 cdn_not_active if the site has
no CDN zone.
Returned Params
- active: Boolean
- cdn_type: String | "premium" or "volume"
- optimizer_enabled: Boolean
- origin_url: String
- origin_type: Integer
- enable_logging: Boolean
- origin_shield_enabled: Boolean
- auto_ssl: Boolean
- cache_control_max_age_override: Integer
- smart_cache: Boolean
- cache_enabled: Boolean
- hostnames:
Array<Object>- value: String
- force_ssl: Boolean
- has_certificate: Boolean
- is_system_hostname: Boolean
Caching Settings
The CDN zone's caching configuration (smart cache, expirations, vary toggles,
stale-while-*). Distinct from the Cache layer management below (which
enables/disables redis/nginx/bunny). Requires CDN active
(409 cdn_not_active). Synchronous; upstream failures return 502.
Get Caching Settings
GET /api/sites/:site_id/cdn/caching
Scope sites:read.
Returned Params
- smart_cache: Boolean
- cache_expiration: Integer | edge cache TTL seconds;
-1= respect origin,0= cache nothing - browser_cache_expiration: Integer | browser cache TTL seconds
- query_string_ordering: Boolean
- cache_error_responses: Boolean
- vary_avif / vary_webp / vary_mobile / vary_hostname: Boolean
- vary_country_code / vary_country_state_code / vary_cookie: Boolean
- cookie_vary_parameters:
Array<String> - query_string_vary_parameters:
Array<String> - disable_cookies: Boolean
- cache_slice: Boolean
- stale_while_offline / stale_while_updating: Boolean
Update Caching Settings
PATCH /api/sites/:site_id/cdn/caching
Scope sites:write (and the can_modify role). Partial update — only the
keys you send are written. Returns the refreshed settings (same shape as the GET
above).
Params
- Any of the fields returned above. Scalars and booleans are sent as-is;
cookie_vary_parametersandquery_string_vary_parametersareArray<String>.
Purge the Cache
POST /api/sites/:site_id/cdn/caching/purge
Scope sites:write (and the can_modify role). Purges the entire CDN
cache. Synchronous.
To purge from code running inside the site, see Purging the CDN from your site.
Cache
The :type segment is the cache layer: redis, nginx, bunny, or all
(fans out to every layer). An unknown type returns 422
{"error":"unknown_cache_type","allowed":[...]}. A layer the site's plan does
not include (some plans have no Redis, for example) returns 422
{"error":"cache_type_unavailable","cache_type":"redis"}.
Refused while the site's server is unavailable
Reading the status, and enabling, disabling, or purging the redis, nginx, or
all layers, return 409 node_maintenance or node_offline while the
site's server is under maintenance or offline (see
Node status). Requests for
bunny alone are not affected. These errors use the errors / code envelope.
Cache Status
GET /api/sites/:site_id/cache
Returned Params
- bunny: Boolean | CDN cache enabled
- nginx: Boolean
- redis: Boolean
Returns 409 node_maintenance / node_offline as described above.
Enable a Cache Layer
PATCH /api/sites/:site_id/cache/:type
Async — returns 202 with the task to poll. Requires the can_modify
(edit) role.
Returned Params
- task_id: Integer
- status: String |
"PENDING" - cache_type: String
Disable a Cache Layer
DELETE /api/sites/:site_id/cache/:type
Async — returns 202 (same shape as enable). Requires the can_modify (edit)
role, not can_destroy.
Purge a Cache Layer
DELETE /api/sites/:site_id/cache/:type/purge
Async — returns 202 (same shape as enable). Requires the can_modify
(edit) role.
Edge Rules
Edge rules for the site. Requires CDN active (409 cdn_not_active).
All actions are synchronous and pass through the CDN's response. :id is the rule
Guid.
List Edge Rules
GET /api/sites/:site_id/edge_rules
Create an Edge Rule
POST /api/sites/:site_id/edge_rules
Returns 201. Requires the can_modify (edit) role. Omit Guid to create;
a retried create is not idempotent (a duplicate is created) — send a
Guid (or use PATCH) to update in place.
Params (wrapped in edge_rule)
- Guid: String | omit to create
- ActionType: Integer | 0–34 (e.g. 0 = ForceSSL, 1 = Redirect, 2 = OriginUrl, 4 = BlockRequest, 5 = SetResponseHeader, 23 = DisableWAF, 28 = DisableShield)
- ActionParameter1 / ActionParameter2 / ActionParameter3: String
- TriggerMatchingType: Integer | how the rule's triggers combine: 0 = match any, 1 = match all, 2 = match none
- Description: String
- Enabled: Boolean
- OrderIndex: Integer
- Triggers:
Array<Object>| up to 5 conditions per rule (the per-rule maximum)- Type: Integer | 0 = Url, 1 = RequestHeader, 2 = ResponseHeader, 3 = UrlExtension, 4 = CountryCode, 5 = RemoteIP, 6 = UrlQueryString, 7 = RandomChance, 8 = StatusCode, 9 = RequestMethod, 10 = CookieValue, 11 = CountryStateCode, 12 = OriginRetryAttemptCount, 13 = OriginConnectionError
- PatternMatchingType: Integer | how this condition's values combine: 0 = match any, 1 = match all, 2 = match none
- Parameter1: String
- PatternMatches:
Array<String>| up to 5 values per condition (the per-condition maximum)
- ExtraActions:
Array<Object>- ActionType: Integer
- ActionParameter1 / ActionParameter2 / ActionParameter3: String
Two separate limits of 5
A rule is capped at 5 Triggers (conditions) and each condition at
5 PatternMatches (values). The per-rule condition count is validated
first.
System-managed rules (Description prefixed CPRESS -) are filtered from the
list and are not customer-editable.
ActionType accepts the full 0–34 range. Use the action types offered in the
dashboard's rule editor.
Update an Edge Rule
PATCH /api/sites/:site_id/edge_rules/:id
The Guid is taken from the URL. Returns 200. Requires the can_modify
(edit) role. Full replace — fields you omit are cleared, so send the complete
rule.
Toggle an Edge Rule
PATCH /api/sites/:site_id/edge_rules/:id/enabled
Requires the can_modify (edit) role.
Params
- enabled: Boolean
Delete an Edge Rule
DELETE /api/sites/:site_id/edge_rules/:id
Returns 204. Requires the can_destroy role.
Logs
Require CDN active (409 cdn_not_active).
CDN Access Logs
GET /api/sites/:site_id/logs/cdn
Params (all optional)
- from: String | ISO8601 datetime (default: 24 hours ago)
- to: String | ISO8601 datetime (default: now)
- period: String | preset window —
1h,6h,24h,72h. Used only when bothfromandtoare blank. Unknown values → 422. - status: String | HTTP status code filter
- cache_status: String | cache status filter
- country: String | two-letter country code filter
- url_contains: String | filter by URL substring
- limit: Integer | max results (default: 100, max: 1000)
- offset: Integer | pagination offset (default: 0)
- order: String |
ascordesc(default:desc)
Errors
- 422 |
invalid_period,invalid_range, orrange_exceeds_3_days - 502 | upstream error
CDN Log Summary
GET /api/sites/:site_id/logs/cdn/summary
Aggregated statistics over the same filters as the CDN access logs endpoint.
Origin Logs
GET /api/sites/:site_id/logs/origin
Params
- date: String | date accepted by the CDN (optional)