### Authentication Example Source: https://www.keycdn.com/api This example demonstrates how to authenticate with the KeyCDN API using HTTP Basic Auth with your API key. ```APIDOC ## Authentication You authenticate to the KeyCDN API by providing your API key in the request. Keep your credentials secret. Authentication to the API occurs via HTTP Basic Auth. All API requests must be made over HTTPS. Calls made over plain HTTP will fail. You must authenticate for all requests. curl uses the -u flag to pass basic auth credentials (adding a colon after your API key will prevent it from asking you for a password). To receive data or make changes to your account, replace the example API key with your actual API key. ### Example Request ``` $ curl https://api.keycdn.com/zones.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ### Response Parameters Parameter| Description ---|--- `status`| Status code of the current API call. `description`| Description of an API call. `data`| The response data of the API call. ### Example Response ```json { "status": "success", "description": "Data successfully received.", "data": { ... } } ``` ``` -------------------------------- ### KeyCDN API Zone Response Example Source: https://www.keycdn.com/api This is an example of a successful JSON response when retrieving zone data from the KeyCDN API. It includes various configuration details for the specified zone. ```json { "status": "success", "description": "Data successfully received.", "data": { "zone": { "id": "1000", "name": "examplepull", "status": "active", "type": "pull", "forcedownload": "disabled", "cors": "disabled", "gzip": "disabled", "imgproc": "disabled", "expire": "0", "blockbadbots": "enabled", "allowemptyreferrer": "enabled", "blockreferrer": "disabled", "securetoken": "disabled", "securetokenkey": null, "securetokenip": "disabled", "sslcert": "shared", "customsslkey": null, "customsslcert": null, "forcessl": "disabled", "originurl": "https://example.com", "originshield": "disabled", "cachemaxexpire": "1440", "cacheignorecachecontrol": "enabled", "cacheignorequerystring": "enabled", "cachehostheader": "disabled", "cachekeyscheme": "disabled", "cachekeyhost": "disabled", "cachekeycookie": null, "cachekeydevice": "disabled", "cachekeywebp": "disabled", "cachekeycountry": "disabled", "cachebr": "disabled", "cachecookies": "disabled", "cachestripcookies": "disabled", "cachexpullkey": "KeyCDN", "cachecanonical": "disabled", "cacherobots": "disabled", "cacheerrorpages": "enabled" } } } ``` -------------------------------- ### Example API Success Response Source: https://www.keycdn.com/api An example of a successful API response, indicating data was retrieved or an action was completed. The response includes a status, description, and the requested data. ```json { "status": "success", "description": "Data successfully received.", "data": { ... } } ``` -------------------------------- ### Get Credit Balance Source: https://www.keycdn.com/api Fetches the current credit balance. This endpoint requires authentication. ```bash $ curl "https://api.keycdn.com/reports/creditbalance.json" \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ```json { "status":"success", "description":"Data successfully received.", "data":{ "amount":"100" } } ``` -------------------------------- ### Authenticate API Request with cURL Source: https://www.keycdn.com/api Demonstrates how to authenticate an API request using cURL with your API key. Replace the example key with your actual key. Authentication is required for all requests. ```bash $ curl https://api.keycdn.com/zones.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` -------------------------------- ### Get Credits Statistics Report Source: https://www.keycdn.com/api Retrieves a list of credit bookings within a specified time frame. Authentication is required. ```bash $ curl "https://api.keycdn.com/reports/credits.json?start=?start=1541030400&end=1541203200" \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ```json { "status":"success", "description":"Data successfully received.", "data":{ "stats":[ { "amount":"-0.01", "type":"storage", "timestamp":"1541030400" }, { "amount":"-0.02", "type":"traffic", "timestamp":"1541030400" }, { "amount":"-0.01", "type":"traffic", "timestamp":"1541116800" }, { "amount":"-0.01", "type":"storage", "timestamp":"1541116800" }, { "amount":"-0.01", "type":"storage", "timestamp":"1541203200" }, { "amount":"-0.02", "type":"traffic", "timestamp":"1541203200" } ] } } ``` -------------------------------- ### Get Storage Statistics Source: https://www.keycdn.com/api Retrieves storage statistics for a specified time range. Requires start and end timestamps. ```bash $ curl "https://api.keycdn.com/reports/storage.json?start=1541030400&end=1541203200" \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ```json { "status":"success", "description":"Data successfully received.", "data":{ "stats":[ { "amount":"538923008", "timestamp":"1541030400" }, { "amount":"538923008", "timestamp":"1541116800" }, { "amount":"538923008", "timestamp":"1541203200" } ] } } ``` -------------------------------- ### Canonical Response Header Example Source: https://www.keycdn.com/api Sets a canonical response header with the origin URL as the reference to consolidate duplicate content. This is useful for SEO purposes. ```http Link: ; rel="canonical" ``` -------------------------------- ### Get Image Processing Statistics Source: https://www.keycdn.com/api Retrieves image processing statistics for a specified time range. Requires start and end timestamps. ```bash GEThttps://api.keycdn.com/reports/ip.json ``` -------------------------------- ### Get Traffic Statistics Source: https://www.keycdn.com/api Retrieves traffic statistics for a specified time range. Requires start and end timestamps. ```bash $ curl "https://api.keycdn.com/reports/traffic.json?start=1541030400&end=1541203200" \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ```json { "status":"success", "description":"Data successfully received.", "data":{ "stats":[ { "amount":"6822186", "timestamp":"1541030400" }, { "amount":"9327251", "timestamp":"1541116800" }, { "amount":"6104220", "timestamp":"1541203200" } ] } } ``` -------------------------------- ### Get State Statistics Report Source: https://www.keycdn.com/api Fetches state statistics for a given time range. This endpoint requires authentication and specifies start and end timestamps. ```bash $ curl "https://api.keycdn.com/reports/statestats.json?start=1541030400&end=1541203200" \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ```json { "status":"success", "description":"Data successfully received.", "data":{ "stats":[ { "totalcachehit":"313", "totalcachemiss":"18", "totalsuccess":"329", "totalerror":"5", "timestamp":"1541030400" }, { "totalcachehit":"219", "totalcachemiss":"4", "totalsuccess":"220", "totalerror":"2", "timestamp":"1541116800" }, { "totalcachehit":"284", "totalcachemiss":"11", "totalsuccess":"302", "totalerror":"4", "timestamp":"1541203200" } ] } } ``` -------------------------------- ### Get IP Statistics Report Source: https://www.keycdn.com/api Retrieves IP-based statistics for a specified time range. Requires authentication. ```bash $ curl "https://api.keycdn.com/reports/ip.json?start=1541030400&end=1541203200" \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ```json { "status":"success", "description":"Data successfully received.", "data":{ "stats":[ { "amount":"1208", "timestamp":"1541030400" }, { "amount":"1234", "timestamp":"1541116800" }, { "amount":"1062", "timestamp":"1541203200" } ] } } ``` -------------------------------- ### Purge URLs with WebP Support Source: https://www.keycdn.com/api If `cachekeywebp` is enabled, `webp` is appended to the URLs for purging, targeting WebP image variants. ```bash $ curl https://api.keycdn.com/zones/purgeurl/1000.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \ -X DELETE \ -H "Content-Type: application/json" \ --data '{"urls":["examplepull-hexid.kxcdn.com/img/logo.png", "examplepull-hexid.kxcdn.com/img/logo.pngwebp"]}' ``` ```json { "status": "success", "description": "Cache has been cleared for URL(s)." } ``` -------------------------------- ### List All Zones Source: https://www.keycdn.com/api Use this endpoint to retrieve a list of all zones associated with your KeyCDN account. Authentication is required. ```HTTP GET https://api.keycdn.com/zones.json ``` ```Shell $ curl https://api.keycdn.com/zones.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ```JSON { "status": "success", "description": "Data successfully received.", "data": { "zones": [ { "id": "1000", "name": "examplepull", "status": "active", "type": "pull", "forcedownload": "disabled", "cors": "disabled", "gzip": "disabled", "imgproc": "disabled", "expire": "0", "blockbadbots": "enabled", "allowemptyreferrer": "enabled", "blockreferrer": "disabled", "securetoken": "disabled", "securetokenkey": null, "securetokenip": "disabled", "sslcert": "shared", "customsslkey": null, "customsslcert": null, "forcessl": "disabled", "originurl": "https://example.com", "cachemaxexpire": "1440", "cacheignorecachecontrol": "enabled", "cacheignorequerystring": "enabled", "cachehostheader": "disabled", "cachekeyscheme": "disabled", "cachekeyhost": "disabled", "cachekeycookie": null, "cachekeydevice": "disabled", "cachekeywebp": "disabled", "cachekeycountry": "disabled", "cachebr": "disabled", "cachecookies": "disabled", "cachestripcookies": "disabled", "cachexpullkey": "KeyCDN", "cachecanonical": "disabled", "cacherobots": "disabled", "cacheerrorpages": "enabled" }, { "id": "1001", "name": "examplepush", "status": "active", "type": "push", "forcedownload": "disabled", "cors": "disabled", "gzip": "disabled", "imgproc": "disabled", "expire": "0", "blockbadbots": "enabled", "allowemptyreferrer": "enabled", "blockreferrer": "disabled", "securetoken": "disabled", "securetokenkey": null, "securetokenip": "disabled", "sslcert": "shared", "customsslkey": null, "customsslcert": null, "forcessl": "disabled", "dirlist": "disabled" }, ... ] } } ``` -------------------------------- ### List Zone Referrers with KeyCDN API Source: https://www.keycdn.com/api Retrieve a list of all zone referrers configured for your KeyCDN zones. This helps in managing access control based on hostnames. ```bash $ curl https://api.keycdn.com/zonereferrers.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ```json { "status": "success", "description": "Data successfully received.", "data": { "zonereferrers": [ { "id": "3000", "zone_id": "1000", "name": "example.com" }, { "id": "3001", "zone_id": "1000", "name": "cdnpull.example.com" }, { "id": "3002", "zone_id": "1000", "name": "examplepull-hexid.kxcdn.com" } ] } } ``` -------------------------------- ### Credits Statistics Source: https://www.keycdn.com/api Returns a list of credit bookings for a given time range. ```APIDOC ## GET /reports/credits.json ### Description Returns a list of credit bookings for a given time range. ### Method GET ### Endpoint https://api.keycdn.com/reports/credits.json ### Parameters #### Query Parameters - **start** (timestamp) - Required - Unix timestamp for the start of the range - **end** (timestamp) - Required - Unix timestamp for the end of the range ### Response #### Success Response (200) - **amount** (string) - The amount of credits - **type** (string) - The type of credit booking (e.g., traffic, storage, zones, initial, payment) - **timestamp** (string) - Unix timestamp for the booking ### Request Example ```bash curl "https://api.keycdn.com/reports/credits.json?start=1541030400&end=1541203200" \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ### Response Example ```json { "status":"success", "description":"Data successfully received.", "data":{ "stats":[ { "amount":"-0.01", "type":"storage", "timestamp":"1541030400" }, { "amount":"-0.02", "type":"traffic", "timestamp":"1541030400" }, { "amount":"-0.01", "type":"traffic", "timestamp":"1541116800" }, { "amount":"-0.01", "type":"storage", "timestamp":"1541116800" }, { "amount":"-0.01", "type":"storage", "timestamp":"1541203200" }, { "amount":"-0.02", "type":"traffic", "timestamp":"1541203200" } ] } } ``` ``` -------------------------------- ### Add Zone Referrer Source: https://www.keycdn.com/api Use this endpoint to add a new Zone Referrer. Requires zone ID and referrer name. ```bash $ curl https://api.keycdn.com/zonereferrers.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \ -X POST \ -d name=example.com \ -d zone_id=1000 ``` ```json { "status": "success", "description": "Zone Referrer successfully added.", "data": { "zonereferrer": { "id": "3000", "name": "example.com", "zone_id": "1000" } } } ``` -------------------------------- ### Robots.txt Modification Example Source: https://www.keycdn.com/api Adds or modifies the robots.txt file to prevent content from being indexed by search engines. This is typically used for staging or private content. ```robots.txt User-agent: * Disallow: / ``` -------------------------------- ### List Zone Aliases with KeyCDN API Source: https://www.keycdn.com/api Retrieve a list of all zone aliases associated with your KeyCDN account. This is useful for managing custom hostnames for your CDN zones. ```bash $ curl https://api.keycdn.com/zonealiases.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ```json { "status": "success", "description": "Data successfully received.", "data": { "zonealiases": [ { "id": "2000", "zone_id": "1000", "name": "cdnpull.example.com" }, { "id": "2001", "zone_id": "1001", "name": "cdnpush.example.com" } ] } } ``` -------------------------------- ### Retrieve Zone Data with cURL Source: https://www.keycdn.com/api Use this cURL command to fetch details of a specific zone from the KeyCDN API. Ensure you replace '1000' with the actual zone ID and use your API credentials. ```bash $ curl https://api.keycdn.com/zones/1000.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` -------------------------------- ### Add a New Zone Source: https://www.keycdn.com/api Use this endpoint to create a new Pull Zone. You must provide a name, type, and origin URL. Authentication is required. ```bash $ curl https://api.keycdn.com/zones.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \ -X POST \ -d name=examplepull \ -d type=pull \ -d originurl=https://example.com ``` ```json { "status": "success", "description": "Zone successfully added.", "data": { "zone": { "id": "1000", "name": "examplepull", "status": "active", "type": "pull", "forcedownload": "disabled", "cors": "disabled", "gzip": "disabled", "imgproc": "disabled", "expire": "0", "blockbadbots": "enabled", "allowemptyreferrer": "enabled", "blockreferrer": "disabled", "securetoken": "disabled", "securetokenkey": null, "securetokenip": "disabled", "sslcert": "shared", "customsslkey": null, "customsslcert": null, "forcessl": "disabled", "originurl": "https://example.com", "originshield": "disabled", "cachemaxexpire": "1440", "cacheignorecachecontrol": "enabled", "cacheignorequerystring": "enabled", "cachehostheader": "disabled", "cachekeyscheme": "disabled", "cachekeyhost": "disabled", "cachekeycookie": null, "cachekeydevice": "disabled", "cachekeywebp": "disabled", "cachekeycountry": "disabled", "cachebr": "disabled", "cachecookies": "disabled", "cachestripcookies": "disabled", "cachexpullkey": "KeyCDN", "cachecanonical": "disabled", "cacherobots": "disabled", "cacheerrorpages": "enabled" } } } ``` -------------------------------- ### Purge URLs using Zone Alias Source: https://www.keycdn.com/api If `cachekeyhost` is enabled, use the Zone Alias instead of the Zone URL for purging. This is useful when using custom hostnames. ```bash $ curl https://api.keycdn.com/zones/purgeurl/1000.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \ -X DELETE \ -H "Content-Type: application/json" \ --data '{"urls":["cdnpull.example.com/css/style.css","cdnpull.example.com/js/app.js","cdnpull.example.com/img/logo.svg"]}' ``` ```json { "status": "success", "description": "Cache has been cleared for URL(s)." } ``` -------------------------------- ### List Zones Source: https://www.keycdn.com/api Retrieves a list of all zones associated with the specified KeyCDN account. ```APIDOC ## List Zones ### Description Returns a list of all Zones on the specified account. ### Method GET ### Endpoint https://api.keycdn.com/zones.json ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. - **description** (string) - A message describing the result of the operation. - **data** (object) - Contains the list of zones. - **zones** (array) - An array of zone objects. - **id** (string) - The unique identifier for the zone. - **name** (string) - The name of the zone. - **status** (string) - The current status of the zone (e.g., 'active'). - **type** (string) - The type of the zone (e.g., 'pull', 'push'). - **forcedownload** (string) - Indicates if forced download is enabled. - **cors** (string) - Indicates if CORS is enabled. - **gzip** (string) - Indicates if GZIP compression is enabled. - **imgproc** (string) - Indicates if image processing is enabled. - **expire** (string) - The expiration time for cached content. - **blockbadbots** (string) - Indicates if blocking of bad bots is enabled. - **allowemptyreferrer** (string) - Indicates if empty referrers are allowed. - **blockreferrer** (string) - Indicates if referrers are blocked. - **securetoken** (string) - Indicates if secure token is enabled. - **securetokenkey** (string|null) - The secure token key if enabled. - **securetokenip** (string) - Indicates if secure token IP is enabled. - **sslcert** (string) - The SSL certificate type. - **customsslkey** (string|null) - The custom SSL key if used. - **customsslcert** (string|null) - The custom SSL certificate if used. - **forcessl** (string) - Indicates if SSL is forced. - **originurl** (string) - The origin URL for the zone. - **cachemaxexpire** (string) - The maximum expiration time for cache. - **cacheignorecachecontrol** (string) - Indicates if Cache-Control headers are ignored. - **cacheignorequerystring** (string) - Indicates if query strings are ignored for cache. - **cachehostheader** (string) - Indicates if the Host header is used for cache. - **cachekeyscheme** (string) - Indicates if the scheme is used for cache key. - **cachekeyhost** (string) - Indicates if the host is used for cache key. - **cachekeycookie** (string|null) - Cookie settings for cache key. - **cachekeydevice** (string) - Indicates if device is used for cache key. - **cachekeywebp** (string) - Indicates if WebP is used for cache key. - **cachekeycountry** (string) - Indicates if country is used for cache key. - **cachebr** (string) - Indicates if Brotli compression is enabled. - **cachecookies** (string) - Indicates if cookies are cached. - **cachestripcookies** (string) - Indicates if cookies are stripped from cache. - **cachexpullkey** (string) - The X-Pull-Key header value. - **cachecanonical** (string) - Indicates if canonical URLs are used for cache. - **cacherobots** (string) - Indicates if robots.txt is respected for cache. - **cacheerrorpages** (string) - Indicates if error pages are cached. - **dirlist** (string) - Indicates if directory listing is enabled. ### Request Example ``` $ curl https://api.keycdn.com/zones.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ### Response Example ```json { "status": "success", "description": "Data successfully received.", "data": { "zones": [ { "id": "1000", "name": "examplepull", "status": "active", "type": "pull", "forcedownload": "disabled", "cors": "disabled", "gzip": "disabled", "imgproc": "disabled", "expire": "0", "blockbadbots": "enabled", "allowemptyreferrer": "enabled", "blockreferrer": "disabled", "securetoken": "disabled", "securetokenkey": null, "securetokenip": "disabled", "sslcert": "shared", "customsslkey": null, "customsslcert": null, "forcessl": "disabled", "originurl": "https://example.com", "cachemaxexpire": "1440", "cacheignorecachecontrol": "enabled", "cacheignorequerystring": "enabled", "cachehostheader": "disabled", "cachekeyscheme": "disabled", "cachekeyhost": "disabled", "cachekeycookie": null, "cachekeydevice": "disabled", "cachekeywebp": "disabled", "cachekeycountry": "disabled", "cachebr": "disabled", "cachecookies": "disabled", "cachestripcookies": "disabled", "cachexpullkey": "KeyCDN", "cachecanonical": "disabled", "cacherobots": "disabled", "cacheerrorpages": "enabled" }, { "id": "1001", "name": "examplepush", "status": "active", "type": "push", "forcedownload": "disabled", "cors": "disabled", "gzip": "disabled", "imgproc": "disabled", "expire": "0", "blockbadbots": "enabled", "allowemptyreferrer": "enabled", "blockreferrer": "disabled", "securetoken": "disabled", "securetokenkey": null, "securetokenip": "disabled", "sslcert": "shared", "customsslkey": null, "customsslcert": null, "forcessl": "disabled", "dirlist": "disabled" }, ... ] } } ``` ``` -------------------------------- ### Credit Balance Source: https://www.keycdn.com/api Returns the current credit balance. ```APIDOC ## GET /reports/creditbalance.json ### Description Returns the credit balance. ### Method GET ### Endpoint https://api.keycdn.com/reports/creditbalance.json ### Response #### Success Response (200) - **amount** (string) - The current credit balance ### Request Example ```bash curl "https://api.keycdn.com/reports/creditbalance.json" \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: ``` ### Response Example ```json { "status":"success", "description":"Data successfully received.", "data":{ "amount":"100" } } ``` ``` -------------------------------- ### Add Zone Source: https://www.keycdn.com/api Adds a new Pull Zone to your KeyCDN account. You need to provide a name for the zone, its type (always 'pull'), and the origin URL. ```APIDOC ## POST /zones.json ### Description Adds a new Pull Zone to your KeyCDN account. ### Method POST ### Endpoint https://api.keycdn.com/zones.json ### Parameters #### Request Body - **name** (string) - Required - The name of the zone. - **type** (string) - Required - The type of the zone (e.g., 'pull'). - **originurl** (string) - Required - The origin URL for the zone. ### Request Example ```bash curl https://api.keycdn.com/zones.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \ -X POST \ -d name=examplepull \ -d type=pull \ -d originurl=https://example.com ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. - **description** (string) - A message describing the result of the operation. - **data** (object) - Contains details of the created zone. - **zone** (object) - Details of the zone. - **id** (string) - The unique identifier for the zone. - **name** (string) - The name of the zone. - **status** (string) - The current status of the zone. - **type** (string) - The type of the zone. - **originurl** (string) - The origin URL configured for the zone. #### Response Example ```json { "status": "success", "description": "Zone successfully added.", "data": { "zone": { "id": "1000", "name": "examplepull", "status": "active", "type": "pull", "originurl": "https://example.com" } } } ``` ``` -------------------------------- ### Add Zone Alias with KeyCDN API Source: https://www.keycdn.com/api Add a new zone alias to a specified zone. Requires the zone ID and the desired alias hostname. The hostname has a maximum length of 128 characters. ```bash $ curl https://api.keycdn.com/zonealiases.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \ -X POST \ -d name=cdnpull.example.com \ -d zone_id=1000 ``` ```json { "status": "success", "description": "Zone Alias successfully added.", "data": { "zonealias": { "id": "2000", "name": "cdnpull.example.com", "zone_id": "1000" } } } ``` -------------------------------- ### Add Zone Source: https://www.keycdn.com/api Adds a new zone with the specified parameters for the accessing user. ```APIDOC ## POST /zones.json ### Description Adds a new Zone with the specified parameters for the accessing user. ### Method POST ### Endpoint /zones.json ### Parameters #### Request Body - **name** (string) - Required - Alphanumeric, max length: 20. - **status** (string) - Optional - 'active' or 'inactive', defaults to 'active'. - **type** (string) - Required - 'pull' or 'push'. - **forcedownload** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cors** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **gzip** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **imgproc** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **expire** (string) - Optional - Numeric, range: -1 to 525949, defaults to 0. - **blockbadbots** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **allowemptyreferrer** (string) - Optional - 'enabled' or 'disabled', defaults to 'enabled'. - **blockreferrer** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **securetoken** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **securetokenkey** (string) - Optional - Alphanumeric, length: 4-15. - **securetokenip** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **sslcert** (string) - Optional - 'shared', 'custom', 'letsencrypt', or 'disabled', defaults to 'shared'. - **customsslkey** (string) - Optional - Valid key. - **customsslcert** (string) - Optional - Valid certificate. - **forcessl** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **originurl** (string) - Required - URL, max length: 128. - **originshield** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cachemaxexpire** (string) - Optional - Numeric, range: 1 to 525949, defaults to 1440. - **cacheignorecachecontrol** (string) - Optional - 'enabled' or 'disabled', defaults to 'enabled'. - **cacheignorequerystring** (string) - Optional - 'enabled' or 'disabled', defaults to 'enabled'. - **cachehostheader** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cachekeyscheme** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cachekeyhost** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cachekeycookie** (string) - Optional - Alphanumeric, max length: 32. - **cachekeydevice** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cachekeywebp** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cachekeycountry** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cachebr** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cachecookies** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cachestripcookies** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cachexpullkey** (string) - Optional - Alphanumeric, length: 4-15, defaults to 'KeyCDN'. - **cachecanonical** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cacherobots** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. - **cacheerrorpages** (string) - Optional - 'enabled' or 'disabled', defaults to 'enabled'. - **dirlist** (string) - Optional - 'enabled' or 'disabled', defaults to 'disabled'. #### Response Returns the newly created Zone according to View Zone. ``` -------------------------------- ### Purge Multiple URLs Source: https://www.keycdn.com/api Use this endpoint to purge multiple URLs from the cache. Ensure the URLs are provided without a scheme if `cachekeyscheme` is not enabled. ```bash $ curl https://api.keycdn.com/zones/purgeurl/1000.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \ -X DELETE \ -H "Content-Type: application/json" \ --data '{"urls":["examplepull-hexid.kxcdn.com/css/style.css","examplepull-hexid.kxcdn.com/js/app.js","examplepull-hexid.kxcdn.com/img/logo.svg"]}' ``` ```json { "status": "success", "description": "Cache has been cleared for URL(s)." } ``` -------------------------------- ### Purge URLs with Query String Source: https://www.keycdn.com/api When `cacheignorequerystring` is disabled, the query string is appended to the URLs for purging. ```bash $ curl https://api.keycdn.com/zones/purgeurl/1000.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \ -X DELETE \ -H "Content-Type: application/json" \ --data '{"urls":["examplepull-hexid.kxcdn.com/css/style.css","examplepull-hexid.kxcdn.com/css/style.css?name=value"]}' ``` ```json { "status": "success", "description": "Cache has been cleared for URL(s)." } ``` -------------------------------- ### List Zone Referrers Source: https://www.keycdn.com/api Retrieves a list of all Zone Referrers for a specified account. ```APIDOC ## GET /zonereferrers.json ### Description Returns a list of all Zone Referrers on the specified account. ### Method GET ### Endpoint https://api.keycdn.com/zonereferrers.json ### Response #### Success Response (200) - **id** (string) - The unique identifier for the Zone Referrer. - **zone_id** (string) - The ID of the associated Zone. - **name** (string) - The hostname of the Zone Referrer. #### Response Example ```json { "status": "success", "description": "Data successfully received.", "data": { "zonereferrers": [ { "id": "3000", "zone_id": "1000", "name": "example.com" }, { "id": "3001", "zone_id": "1000", "name": "cdnpull.example.com" }, { "id": "3002", "zone_id": "1000", "name": "examplepull-hexid.kxcdn.com" } ] } } ``` ``` -------------------------------- ### List Zone Aliases Source: https://www.keycdn.com/api Retrieves a list of all Zone Aliases associated with a specified account. ```APIDOC ## GET /zonealiases.json ### Description Returns a list of all Zone Aliases on the specified account. ### Method GET ### Endpoint https://api.keycdn.com/zonealiases.json ### Response #### Success Response (200) - **id** (string) - The unique identifier for the Zone Alias. - **zone_id** (string) - The ID of the associated Zone. - **name** (string) - The hostname of the Zone Alias. #### Response Example ```json { "status": "success", "description": "Data successfully received.", "data": { "zonealiases": [ { "id": "2000", "zone_id": "1000", "name": "cdnpull.example.com" }, { "id": "2001", "zone_id": "1001", "name": "cdnpush.example.com" } ] } } ``` ``` -------------------------------- ### Add Zone Referrer Source: https://www.keycdn.com/api Adds a new Zone Referrer for a given Zone. ```APIDOC ## POST /zonereferrers.json ### Description Adds a Zone Referrer for a given Zone. ### Method POST ### Endpoint https://api.keycdn.com/zonereferrers.json ### Parameters #### Request Body - **zone_id** (numeric) - Required - The ID of the Zone to associate the referrer with. - **name** (hostname) - Required - The hostname for the Zone Referrer. Maximum length is 46 characters. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the newly added Zone Referrer. - **zone_id** (string) - The ID of the associated Zone. - **name** (string) - The hostname of the Zone Referrer. #### Response Example ```json { "status": "success", "description": "Zone Referrer successfully added.", "data": { "zonereferrer": { "id": "3003", "zone_id": "1000", "name": "newreferrer.example.com" } } } ``` ``` -------------------------------- ### Purge URLs with Device Type Source: https://www.keycdn.com/api When `cachekeydevice` is enabled, the device type (desktop, tablet, mobile) is appended to the URLs for purging. ```bash $ curl https://api.keycdn.com/zones/purgeurl/1000.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \ -X DELETE \ -H "Content-Type: application/json" \ --data '{"urls":["examplepull-hexid.kxcdn.com/css/style.cssdesktop","examplepull-hexid.kxcdn.com/css/style.csstablet","examplepull-hexid.kxcdn.com/css/style.cssmobile"]}' ``` ```json { "status": "success", "description": "Cache has been cleared for URL(s)." } ``` -------------------------------- ### Storage Statistics Source: https://www.keycdn.com/api Retrieves storage statistics for a specified time range. This report helps in monitoring disk usage. ```APIDOC ## GET /reports/storage.json ### Description Returns a list of storage statistics for a given time range. ### Method GET ### Endpoint https://api.keycdn.com/reports/storage.json ### Parameters #### Query Parameters - **zone_id** (numeric) - Optional - The ID of the zone to retrieve statistics for. - **start** (timestamp) - Required - The start of the time range (Unix timestamp). - **end** (timestamp) - Required - The end of the time range (Unix timestamp). ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. - **description** (string) - A message describing the result of the operation. - **data** (object) - Contains the storage statistics. - **stats** (array) - An array of storage data points. - **amount** (bytes) - The amount of storage in bytes. - **timestamp** (unix) - The Unix timestamp for the data point. #### Response Example ```json { "status":"success", "description":"Data successfully received.", "data":{ "stats":[ { "amount":"538923008", "timestamp":"1541030400" }, { "amount":"538923008", "timestamp":"1541116800" }, { "amount":"538923008", "timestamp":"1541203200" } ] } } ``` ``` -------------------------------- ### Purge URLs with Brotli Compression Source: https://www.keycdn.com/api If `cachebr` is enabled, `br` is appended to the URLs for purging, targeting Brotli compressed variants. ```bash $ curl https://api.keycdn.com/zones/purgeurl/1000.json \ -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \ -X DELETE \ -H "Content-Type: application/json" \ --data '{"urls":["examplepull-hexid.kxcdn.com/css/style.css","examplepull-hexid.kxcdn.com/css/style.cssbr"]}' ``` ```json { "status": "success", "description": "Cache has been cleared for URL(s)." } ```