CDN, Cache & Logs
Per-site CDN configuration, cache layers, edge rules, and access logs. All endpoints are nested under a site and backed by Bunny.
OAuth scopes: reads require sites:read, writes require sites:write
(deletes additionally require the can_destroy role). Endpoints that talk
to Bunny return 409 cdn_not_active when the site has no pull zone, and
502 on an upstream Bunny error.
CDN Status
GET /api/sites/:site_id/cdn
Bunny pull-zone status & configuration. Returns 409 cdn_not_active if there
is no pull 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 pull-zone 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. 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 pull-zone
cache. Synchronous.
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":[...]}.
Cache Status
GET /api/sites/:site_id/cache
Returned Params
- bunny: Boolean | Bunny CDN cache enabled
- nginx: Boolean
- redis: Boolean
Enable a Cache Layer
PATCH /api/sites/:site_id/cache/:type
Async — returns 202 with the task to poll.
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_destroy role.
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
Bunny edge rules for the site. Requires CDN active (409 cdn_not_active).
All actions are synchronous and pass through Bunny'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. Omit Guid to create; a retried create is not idempotent
(Bunny creates a duplicate) — 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>- 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
- 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 (Bunny's per-condition maximum)
- ExtraActions:
Array<Object>- ActionType: Integer
- ActionParameter1 / ActionParameter2 / ActionParameter3: String
System-managed rules (Description prefixed CPRESS -) are filtered from the
list and are not customer-editable.
Update an Edge Rule
PATCH /api/sites/:site_id/edge_rules/:id
The Guid is taken from the URL. Returns 200. 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
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 Bunny (optional)