API

Complete content delivery control from any application in any language.

Overview

The KeyCDN API allows you to manage your Zones, Zone Aliases, Zone Referrers, or generate reports. This documentation provides you the required information to successfully make use of the API. The KeyCDN API is organized around REST.

Our API is designed to have predictable, resource-oriented URLs and to use HTTP response codes to indicate API errors. We use built-in HTTP features, such as HTTP authentication and HTTP terminology, which can be understood by off-the-shelf HTTP clients.

JSON will be returned in all responses from the API, including errors.


Support

  • Check our API Libraries on GitHub. They allow you a quick and simple integration into your current solution.
  • Please open a support request if you have any questions.
  • Please submit a request for enhancement (RFE) if you need more functionality.

Changelog

  • 2019-08-05 Increased API rate limit.
  • 2019-03-30 Added support to purge various cache key combinations.
  • 2017-09-01 Added support for Forward Host Header, Cache Key Scheme, Cache Key Host, Cache Key Cookie, Cache Key Device, Cache Brotli, and Generic Error Pages.
  • 2016-07-22 Changed Edit Zone to not require name field anymore.
  • 2016-03-05 Added Let's Encrypt support to the API.
  • 2015-11-20 Changed the API base URL to api.keycdn.com.
  • 2015-09-22 Purge simplification.
  • 2015-09-22 Change API Key Authentication.
  • 2015-01-26 Added Origin Shield feature.
  • 2014-09-10 Added Force SSL feature.
  • 2014-08-25 Including Zones, Zone Aliases and Zone Referrers into the API.
  • 2014-08-25 Introduction of rate limiting.
  • 2014-07-29 Including reporting into the API.
  • 2013-10-10 Added Purge URL feature.
  • 2013-08-01 Released Beta Version of the KeyCDN API.

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

                    
                        {
                            "status": "success",
                            "description": "Data successfully received.",
                            "data": {
                            ...
                            }
                        }
                    
                

Errors

KeyCDN uses conventional HTTP response codes to indicate success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the provided information (e.g. a required parameter was missing or invalid), and codes in the 5xx range indicate an error with KeyCDN's edge servers.

Not all errors map cleanly onto HTTP response codes.

HTTP Status Code Summary

Status Description
200 OK Everything worked as expected.
400 Bad Request Often missing a required parameter.
403 Forbidden Access denied.
404 Not Found The requested item does not exist.
413 Request Entity Too Large Maximum body size is 64 KB.
429 Too Many Requests Rate limit exceeded.
451 Illegal Illegal or malicious request.
500, 502, 503, 504 Something went wrong on KeyCDN's end.

Rate Limiting

API requests are currently rate limited at 60 queries per 60 seconds window. Purge requests are limited to 2 requests per second. Ensure that you inspect the following HTTP response headers, as they provide pertinent data on where your utilization is at for the given rate limit. The calling IP will be blocked if the X-Rate-Limit-Remaining value reaches 0.

Header Description
X-Rate-Limit-Limit The rate limit ceiling for that given request.
X-Rate-Limit-Remaining The number of requests left for the 60 seconds window.
The KeyCDN API will return an HTTP 429 Too Many Requests response status when you exceed the rate limit.

Zones API

Parameter Description
id Zone ID
name Zone name
status Zone status
type Zone type
forcedownload Forces content to download instead of opening. The following response header will be set: Content-Disposition: Attachment
cors Allow unrestricted Cross-Origin Resource Sharing (CORS). The following response header will be set: Access-Control-Allow-Origin: \*
gzip Gzip compression on content 1 KB or larger.
expire Adding or modifying the Cache-Control and Expires response headers that are sent to the client if the HTTP response status code equals 200, 201, 204, 206, 301, 302, 303, 304, or 307:
-1 Cache-Control: no-cache
0 Push Zone: disabled
Pull Zone: as received from the origin server
>0 Cache-Control: max-age=t where t is the time specified in minutes and then converted to seconds
If cacheignorecachecontrol is enabled the expire value will only have an impact on the browser cache and not on the KeyCDN cache.
blockbadbots Block bad bots (returns a 451 Unavailable For Legal Reasons response status).
allowemptyreferrer Allow requests with an empty Referer request header value if one or more Zone Referrer is active.
http2 Use the HTTP/2 network protocol for HTTPS requests.
securetoken Restrict access to all content within Zone by Secure Token.
securetokenkey Secret used to check authenticity of request if securetoken is enabled.
sslcert Add SSL/TLS certificate to be used for HTTPS requests:
shared Enables the shared wildcard certificate to be used with the Zone URL (e.g. https://examplepull-1a2b.kxcdn.com)
custom Enables the custom certificate defined in customsslkey and customsslcert to be used with a Zone Alias (e.g. https://cdn.example.com)
letsencrypt Enables a Let's Encrypt certificate to be used with one Zone Alias (e.g. https://cdn.example.com)
You must remove an exising Zone Alias before enabling the letsencrypt option (or recreate the Zone Alias afterwards).
customsslkey The custom SSL/TLS certificate private key. Include the -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- statements.
customsslcert The custom SSL/TLS certificate. The required format is PEM (Base64 encoded ASCII), which is the most common format that Certificate Authorities issue. Include the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- statements and optionally include the intermediate certificate:
Cert only
                                                        
                                                            -----BEGIN CERTIFICATE-----
                                                            Certificate
                                                            -----END CERTIFICATE-----
                                                        
                                                    
Cert including intermediate cert
                                                        
                                                            -----BEGIN CERTIFICATE-----
                                                            Certificate
                                                            -----END CERTIFICATE-----
                                                            -----BEGIN CERTIFICATE-----
                                                            Intermediate certificate
                                                            -----END CERTIFICATE-----
                                                        
                                                    
forcessl Redirects HTTP requests to HTTPS (returns a 301 Moved Permanently response status).
originurl URL of the origin server where content is pulled from. Include only the scheme and hostname (e.g. https://www.example.com). Do not include a file path (e.g. https://www.example.com/index.html).
originshield Predefined shield servers will pull content from the origin server instead of our edge servers. This will reduce traffic on the origin server but adds an additional request from the edge server to the shield server if the content has not been cached yet. The following response header will be set: X-Shield: active
cachemaxexpire Define the maximum time in minutes that cacheable content will be retained in the KeyCDN cache without checking the origin server. Applies only if NOT defined by the origin server X-Accel-Expires, Cache-Control, or Expires response headers.
cacheignorecachecontrol Ignores processing of X-Accel-Expires, Cache-Control, and Expires response headers received from the origin server. If enabled the cachemaxexpire value has precedence.
cacheignorequerystring Ignores the presence of query strings. The KeyCDN cache will respond with a cached response even if the query string differs.
cachehostheader Forwards the Host request header (e.g. Host: cdn.example.com) to the origin server as received from the client instead of the Host request header defined by the originurl hostname.
cachekeyscheme Scheme based caching (http:// or https://) as requested by the client.
cachekeyhost Host request header based caching that matches the Zone Alias.
cachekeycookie Cookie variable based caching as received in the Cookie request header.
cachekeydevice Device based caching (desktop, tablet, or mobile) as received in the User-Agent request header.
The default device type is desktop.
cachebr Brotli based caching as requested by the client.
The origin server must support the Brotli compression format.
cachecookies Ignore the presence of cookies. By default content with cookies are not cacheable, but when cookies are ignored content becomes cacheable.
cachestripcookies Strip the Set-Cookie response header received from the origin server.
cachexpullkey Set a custom X-Pull request header value (e.g. X-Pull: example). This is a custom request header that can serve multiple purposes, such as restricting access to the origin server or allowing all KeyCDN edge server requests through a firewall.
cachecanonical Add a canonical response header with the originurl as the reference to consolidate duplicate content. The following response header will be set: Link: <https://www.example.com/css/style.css>; rel="canonical"
cacherobots Adding or modifying the robots.txt to prevent content from being indexed:
                                        
                                            User-agent: *
                                            Disallow: /
                                        
                                    
cacheerrorpages Deliver generic error pages for 4xx and 5xx errors instead of the error pages received from the origin server.
dirlist Generates directory indexes automatically (similar to the Unix ls command or the Win32 dir shell command).
dirindex Deliver the directory index without being specified in the request (e.g. https://example.com/docs/ would return https://example.com/docs/index.html if it exists).

List Zones

Returns a list of all Zones on the specified account.

                    
                        GEThttps://api.keycdn.com/zones.json
                    
                

Response Parameters

Returns a list of Zones as defined in View Zone.

Example

            
                
                    $ curl https://api.keycdn.com/zones.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86:
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Data successfully received.",
                        "data": {
                            "zones": [
                                {
                                    "id": "1000",
                                    "name": "examplepull",
                                    "status": "active",
                                    "type": "pull",
                                    "forcedownload": "disabled",
                                    "cors": "disabled",
                                    "gzip": "disabled",
                                    "expire": "0",
                                    "blockbadbots": "enabled",
                                    "allowemptyreferrer": "enabled",
                                    "http2": "enabled",
                                    "securetoken": "disabled",
                                    "securetokenkey": null,
                                    "sslcert": "disabled",
                                    "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",
                                    "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",
                                    "expire": "0",
                                    "blockbadbots": "enabled",
                                    "allowemptyreferrer": "enabled",
                                    "http2": "enabled",
                                    "securetoken": "disabled",
                                    "securetokenkey": null,
                                    "sslcert": "disabled",
                                    "customsslkey": null,
                                    "customsslcert": null,
                                    "forcessl": "disabled",
                                    "dirlist": "disabled",
                                    "dirindex": "disabled"
                                },
                                ...
                            ]
                        }
                    }
                
            
        

View Zone

Returns a Zone specified by the {zone_id} parameter.

                    
                        GEThttps://api.keycdn.com/zones/{zone_id}.json
                    
                

Response Parameters

Parameter Pull Push
id
name
status
type
forcedownload
cors
gzip
expire
blockbadbots
allowemptyreferrer
http2
securetoken
securetokenkey
sslcert
customsslkey
customsslcert
forcessl
originurl
originshield
cachemaxexpire
cacheignorecachecontrol
cacheignorequerystring
cachehostheader
cachekeyscheme
cachekeyhost
cachekeycookie
cachekeydevice
cachebr
cachecookies
cachestripcookies
cachexpullkey
cachecanonical
cacherobots
cacheerrorpages
dirlist
dirindex

Example

            
                
                    $ curl https://api.keycdn.com/zones/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86:
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Data successfully received.",
                        "data": {
                            "zone": {
                                "id": "1000",
                                "name": "examplepull",
                                "status": "active",
                                "type": "pull",
                                "forcedownload": "disabled",
                                "cors": "disabled",
                                "gzip": "disabled",
                                "expire": "0",
                                "blockbadbots": "enabled",
                                "allowemptyreferrer": "enabled",
                                "http2": "enabled",
                                "securetoken": "disabled",
                                "securetokenkey": null,
                                "sslcert": "disabled",
                                "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",
                                "cachebr": "disabled",
                                "cachecookies": "disabled",
                                "cachestripcookies": "disabled",
                                "cachexpullkey": "KeyCDN",
                                "cachecanonical": "disabled",
                                "cacherobots": "disabled",
                                "cacheerrorpages": "enabled"
                            }
                        }
                    }
                
            
        

Add Zone

Add a new Zone with the specified parameters for the accessing user.

                    
                        POSThttps://api.keycdn.com/zones.json
                    
                

Request Parameters

Parameter Value Default Pull Push
name
required
{alphanumeric}
max length: 20
status
optional
active or inactive active
type
required
pull or push push
forcedownload
optional
enabled or disabled disabled
cors
optional
enabled or disabled disabled
gzip
optional
enabled or disabled disabled
expire
optional
{numeric}
range: -1 to 525949
0
blockbadbots
optional
enabled or disabled enabled
allowemptyreferrer
optional
enabled or disabled enabled
securetoken
optional
enabled or disabled disabled
securetokenkey
optional
{alphanumeric}
length: 4-15
sslcert
optional
disabled, shared,
custom, or letsencrypt
disabled
customsslkey
optional
{valid key}
customsslcert
optional
{valid cert}
forcessl
optional
enabled or disabled disabled
originurl
required
{url}
max length: 128
originshield
optional
enabled or disabled disabled
cachemaxexpire
optional
{numeric}
range: 1 to 525949
1440
cacheignorecachecontrol
optional
enabled or disabled enabled
cacheignorequerystring
optional
enabled or disabled enabled
cachehostheader
optional
enabled or disabled disabled
cachekeyscheme
optional
enabled or disabled disabled
cachekeyhost
optional
enabled or disabled disabled
cachekeycookie
optional
{alphanumeric}
max length: 32
cachekeydevice
optional
enabled or disabled disabled
cachebr
optional
enabled or disabled disabled
cachecookies
optional
enabled or disabled disabled
cachestripcookies
optional
enabled or disabled disabled
cachexpullkey
optional
{alphanumeric}
length: 4-15
KeyCDN
cachecanonical
optional
enabled or disabled disabled
cacherobots
optional
enabled or disabled disabled
cacheerrorpages
optional
enabled or disabled enabled
dirlist
optional
enabled or disabled disabled
dirindex
optional
enabled or disabled disabled

Response Parameters

Returns the newly created Zone according to View Zone.

Example

            
                
                    $ curl https://api.keycdn.com/zones.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X POST \
                        -d name=examplepull \
                        -d type=pull \
                        -d originurl=https://example.com
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Zone successfully added.",
                        "data": {
                            "zone": {
                                "id": "1000",
                                "name": "examplepull",
                                "status": "active",
                                "type": "pull",
                                "forcedownload": "disabled",
                                "cors": "disabled",
                                "gzip": "disabled",
                                "expire": "0",
                                "blockbadbots": "enabled",
                                "allowemptyreferrer": "enabled",
                                "http2": "enabled",
                                "securetoken": "disabled",
                                "securetokenkey": null,
                                "sslcert": "disabled",
                                "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",
                                "cachebr": "disabled",
                                "cachecookies": "disabled",
                                "cachestripcookies": "disabled",
                                "cachexpullkey": "KeyCDN",
                                "cachecanonical": "disabled",
                                "cacherobots": "disabled",
                                "cacheerrorpages": "enabled"
                            }
                        }
                    }
                
            
        

Edit Zone

Edit the given Zone specified by the parameter {zone_id} with the specified request parameters.

                    
                        PUThttps://api.keycdn.com/zones/{zone_id}.json
                    
                

Request Parameters

Same request parameters as in Add Zone (but all are optional).

Response Parameters

Returns the edited Zone according to View Zone.

Example

            
                
                    $ curl https://api.keycdn.com/zones/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X PUT \
                        -d expire=43200
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Zone successfully changed.",
                        "data": {
                            "zone": {
                                "id": "1000",
                                "name": "examplepull",
                                "status": "active",
                                "type": "pull",
                                "forcedownload": "disabled",
                                "cors": "disabled",
                                "gzip": "disabled",
                                "expire": "43200",
                                "blockbadbots": "enabled",
                                "allowemptyreferrer": "enabled",
                                "http2": "enabled",
                                "securetoken": "disabled",
                                "securetokenkey": null,
                                "sslcert": "disabled",
                                "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",
                                "cachebr": "disabled",
                                "cachecookies": "disabled",
                                "cachestripcookies": "disabled",
                                "cachexpullkey": "KeyCDN",
                                "cachecanonical": "disabled",
                                "cacherobots": "disabled",
                                "cacheerrorpages": "enabled"
                            }
                        }
                    }
                
            
        

Delete Zone

Delete the given Zone specified by the parameter {zone_id}.

                    
                        DELETEhttps://api.keycdn.com/zones/{zone_id}.json
                    
                

Example

            
                
                    $ curl https://api.keycdn.com/zones/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X DELETE
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Zone successfully deleted.",
                        "data": []
                    }
                
            
        

Purge Zone Cache

Clears the entire cache of a Pull Zone specified by the {zone_id} parameter.

                    
                        GEThttps://api.keycdn.com/zones/purge/{zone_id}.json
                    
                

Example

            
                
                    $ curl https://api.keycdn.com/zones/purge/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86:
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Cache has been cleared for zone examplepull."
                    }
                
            
        

Purge Zone URL

Clears the cache for the defined URL(s) of a Pull Zone specified by the {zone_id} parameter.

                    
                        DELETEhttps://api.keycdn.com/zones/purgeurl/{zone_id}.json
                    
                

Request Parameters

Parameter Value Default Pull Push
urls
required
{array of URLs}
without scheme

Example

            
                
                    $ curl https://api.keycdn.com/zones/purgeurl/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X DELETE \
                        -H "Content-Type: application/json" \
                        --data '{"urls":["examplepull-1a2b.kxcdn.com/css/style.css","examplepull-1a2b.kxcdn.com/js/app.js","examplepull-1a2b.kxcdn.com/img/logo.svg"]}'
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Cache has been cleared for URL(s)."
                    }
                
            
        
If cachekeyscheme is enabled prepend the scheme.

Example

            
                
                    $ curl https://api.keycdn.com/zones/purgeurl/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X DELETE \
                        -H "Content-Type: application/json" \
                        --data '{"urls":["http://examplepull-1a2b.kxcdn.com/css/style.css","https://examplepull-1a2b.kxcdn.com/css/style.css"]}'
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Cache has been cleared for URL(s)."
                    }
                
            
        
If cachekeyhost is enabled use the Zone Alias instead of the Zone URL.

Example

            
                
                    $ 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"]}'
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Cache has been cleared for URL(s)."
                    }
                
            
        
If cacheignorequerystring is disabled append the query string.

Example

            
                
                    $ curl https://api.keycdn.com/zones/purgeurl/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X DELETE \
                        -H "Content-Type: application/json" \
                        --data '{"urls":["examplepull-1a2b.kxcdn.com/css/style.css","examplepull-1a2b.kxcdn.com/css/style.css?name=value"]}'
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Cache has been cleared for URL(s)."
                    }
                
            
        
If cachekeycookie is enabled append the cookie variable.

Example

            
                
                    $ curl https://api.keycdn.com/zones/purgeurl/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X DELETE \
                        -H "Content-Type: application/json" \
                        --data '{"urls":["examplepull-1a2b.kxcdn.com/css/style.css","examplepull-1a2b.kxcdn.com/css/style.csscookie"]}'
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Cache has been cleared for URL(s)."
                    }
                
            
        
If cachekeydevice is enabled append the device type.

Example

            
                
                    $ curl https://api.keycdn.com/zones/purgeurl/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X DELETE \
                        -H "Content-Type: application/json" \
                        --data '{"urls":["examplepull-1a2b.kxcdn.com/css/style.cssdesktop","examplepull-1a2b.kxcdn.com/css/style.csstablet","examplepull-1a2b.kxcdn.com/css/style.cssmobile"]}'
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Cache has been cleared for URL(s)."
                    }
                
            
        
If cachebr is enabled append br.

Example

            
                
                    $ curl https://api.keycdn.com/zones/purgeurl/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X DELETE \
                        -H "Content-Type: application/json" \
                        --data '{"urls":["examplepull-1a2b.kxcdn.com/css/style.css","examplepull-1a2b.kxcdn.com/css/style.cssbr"]}'
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Cache has been cleared for URL(s)."
                    }
                
            
        
Combine two or more cache keys in the following order: scheme, host, querystring, cookie, br, device, webp.

Example

            
                
                    $ curl https://api.keycdn.com/zones/purgeurl/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X DELETE \
                        -H "Content-Type: application/json" \
                        --data '{"urls":["https://cdnpull.example.com/css/style.css?name=valuecookiebrdesktop"]}'
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Cache has been cleared for URL(s)."
                    }
                
            
        

Purge Zone Tag

Clears the cache for specific tags of a Pull Zone specified by the {zone_id} parameter.

                    
                        DELETEhttps://api.keycdn.com/zones/purgetag/{zone_id}.json
                    
                

Request Parameters

Parameter Value Default Pull Push
tags
required
{array of tags}
max length: 256

Example

            
                
                    $ curl https://api.keycdn.com/zones/purgetag/1000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X DELETE \
                        -H "Content-Type: application/json" \
                        --data '{"tags":["tag1","tag2"]}'
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Cache has been cleared by tag(s)."
                    }
                
            
        

Zone Aliases API

Parameter Description
id Zone Alias ID
zone_id Associated Zone ID
name Zone Alias hostname

List Zone Aliases

Returns a list of all Zone Aliases on the specified account.

                    
                        GEThttps://api.keycdn.com/zonealiases.json
                    
                

Response Parameters

Parameter Pull Push
id
zone_id
name

Example

            
                
                    $ curl https://api.keycdn.com/zonealiases.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86:
                
            
        
            
                
                    {
                        "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 Alias

Adds a Zone Aliases for a given Zone.

                    
                        POSThttps://api.keycdn.com/zonealiases.json
                    
                

Request Parameters

Parameter Value Default Pull Push
zone_id
required
{numeric}
name
required
{hostname}
max length: 128

Response Parameters

Returns the added Zone Alias with the same parameters as in List Zone Aliases.

Example

            
                
                    $ curl https://api.keycdn.com/zonealiases.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X POST \
                        -d name=cdnpull.example.com \
                        -d zone_id=1000
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Zone Alias successfully added.",
                        "data": {
                            "zonealias": {
                                "id": "2000",
                                "name": "cdnpull.example.com",
                                "zone_id": "1000"
                            }
                        }
                    }
                
            
        

Edit Zone Alias

Edit the given Zone Alias specified by the parameter {zonealias_id} with the speciefied request parameters.

                    
                        PUThttps://api.keycdn.com/zonealiases/{zonealias_id}.json
                    
                

Request Parameters

Same request parameters as in Add Zone Alias.

Response Parameters

Returns the changed Zone Alias with the same parameters as in List Zone Aliases.

Example

            
                
                    $ curl https://api.keycdn.com/zonealiases/2000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X PUT \
                        -d name=cdn-pull.example.com \
                        -d zone_id=1000
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Zone Alias successfully changed.",
                        "data": {
                            "zonealias": {
                                "id": "2000",
                                "name": "cdn-pull.example.com",
                                "zone_id": "1000"
                            }
                        }
                    }
                
            
        

Delete Zone Alias

Delete the given Zone Alias specified by the parameter {zonealias_id}.

                    
                        DELETEhttps://api.keycdn.com/zonealiases/{zonealias_id}.json
                    
                

Example

            
                
                    $ curl https://api.keycdn.com/zonealiases/2000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X DELETE
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Zone Alias successfully deleted.",
                        "data": []
                    }
                
            
        

Zone Referrers API

Parameter Description
id Zone Referrer ID
zone_id Associated Zone ID
name Zone Referrer hostname

List Zone Referrers

Returns a list of all Zone Referrers on the specified account.

                    
                        GEThttps://api.keycdn.com/zonereferrers.json
                    
                

Response Parameters

Parameter Pull Push
id
zone_id
name

Example

            
                
                    $ curl https://api.keycdn.com/zonereferrers.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86:
                
            
        
            
                
                    {
                        "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-1a2b.kxcdn.com"
                                }
                            ]
                        }
                    }
                
            
        

Add Zone Referrer

Adds a Zone Referrers for a given Zone.

                    
                        POSThttps://api.keycdn.com/zonereferrers.json
                    
                

Request Parameters

Parameter Value Default Pull Push
zone_id
required
{numeric}
name
required
{hostname}
max length: 46

Response Parameters

Returns the added Zone Referrer with the same parameters as in List Zone Referrers.

Example

            
                
                    $ curl https://api.keycdn.com/zonereferrers.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X POST \
                        -d name=example.com \
                        -d zone_id=1000
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Zone Referrer successfully added.",
                        "data": {
                            "zonereferrer": {
                                "id": "3000",
                                "name": "example.com",
                                "zone_id": "1000"
                            }
                        }
                    }
                
            
        

Edit Zone Referrer

Edit the given Zone Referrer specified by the parameter {zonereferrer_id} with the speciefied request parameters.

                    
                        PUThttps://api.keycdn.com/zonereferrers/{zonereferrer_id}.json
                    
                

Request Parameters

Same request parameters as in Add Zone Referrer.

Response Parameters

Returns the changed Zone Referrer with the same parameters as in List Zone Referrers.

Example

            
                
                    $ curl https://api.keycdn.com/zonereferrers/3000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X PUT \
                        -d name=example.net \
                        -d zone_id=1000
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Zone Referrer successfully changed.",
                        "data": {
                            "zonereferrer": {
                                "id": "3000",
                                "name": "example.net",
                                "zone_id": "1000"
                            }
                        }
                    }
                
            
        

Delete Zone Referrer

Delete the given Zone Referrer specified by the parameter {zonereferrer_id}.

                    
                        DELETEhttps://api.keycdn.com/zonereferrers/{zonereferrer_id}.json
                    
                

Example

            
                
                    $ curl https://api.keycdn.com/zonereferrers/3000.json \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86: \
                        -X DELETE
                
            
        
            
                
                    {
                        "status": "success",
                        "description": "Zone Referrer successfully deleted.",
                        "data": []
                    }
                
            
        

Reports API

Traffic Statistics

Returns a list of traffic statistics for a given time range.

                    
                        GEThttps://api.keycdn.com/reports/traffic.json
                    
                

Request Parameters

Parameter Value Default Pull Push
zone_id
optional
{numeric}
start
required
{timestamp}
unix
end
required
{timestamp}
unix

Response Parameters

Parameter Pull Push
amount
bytes
timestamp
unix

Example

            
                
                    $ curl "https://api.keycdn.com/reports/traffic.json?start=1541030400&end=1541203200" \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86:
                
            
        
            
                
                    {
                        "status":"success",
                        "description":"Data successfully received.",
                        "data":{
                            "stats":[
                                {
                                    "amount":"6822186",
                                    "timestamp":"1541030400"
                                },
                                {
                                    "amount":"9327251",
                                    "timestamp":"1541116800"
                                },
                                {
                                    "amount":"6104220",
                                    "timestamp":"1541203200"
                                }
                            ]
                        }
                    }
                
            
        

Storage Statistics

Returns a list of storage statistics for a given time range.

                    
                        GEThttps://api.keycdn.com/reports/storage.json
                    
                

Request Parameters

Parameter Value Default Pull Push
zone_id
optional
{numeric}
start
required
{timestamp}
unix
end
required
{timestamp}
unix

Response Parameters

Parameter Pull Push
amount
bytes
timestamp
unix

Example

            
                
                    $ curl "https://api.keycdn.com/reports/storage.json?start=1541030400&end=1541203200" \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86:
                
            
        
            
                
                    {
                        "status":"success",
                        "description":"Data successfully received.",
                        "data":{
                            "stats":[
                                {
                                    "amount":"538923008",
                                    "timestamp":"1541030400"
                                },
                                {
                                    "amount":"538923008",
                                    "timestamp":"1541116800"
                                },
                                {
                                    "amount":"538923008",
                                    "timestamp":"1541203200"
                                }
                            ]
                        }
                    }
                
            
        

Status Statistics

Returns a list of state statistics for a given time range.

                    
                        GEThttps://api.keycdn.com/reports/statestats.json
                    
                

Request Parameters

Parameter Value Default Pull Push
zone_id
optional
{numeric}
start
required
{timestamp}
unix
end
required
{timestamp}
unix

Response Parameters

Parameter Pull Push
totalcachehit
totalcachemiss
totalerror
4xx
totalsuccess
2xx
timestamp
unix

Example

            
                
                    $ curl "https://api.keycdn.com/reports/statestats.json?start=1541030400&end=1541203200" \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86:
                
            
        
            
                
                    {
                        "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"
                                }
                            ]
                        }
                    }
                
            
        

Credits Statistics

Returns a list of credit bookings for a given time range.

                    
                        GEThttps://api.keycdn.com/reports/credits.json
                    
                

Request Parameters

Parameter Value Default
start
required
{timestamp}
unix
end
required
{timestamp}
unix

Response Parameters

Parameter
amount
credits
type
traffic, storage, zones, initial, or payment
timestamp
unix

Example

            
                
                    $ curl "https://api.keycdn.com/reports/credits.json?start=?start=1541030400&end=1541203200" \
                        -u sk_prod_zbSVNe8gVUMT4KjYcJWuyC86:
                
            
        
            
                
                    {
                        "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"
                                }
                            ]
                        }
                    }
                
            
        
KeyCDN uses cookies to make its website easier to use. Learn more about cookies.