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

  • 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 request will be rate limited at 20 queries per 60 seconds window and 1 query per second for the time being. Ensure that you inspect these HTTP headers, as they provide pertinent data on where your utilization is at for the given rate limit.

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 code 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. This will set the following response header: Content-Disposition: Attachment
cors Enable Cross-Origin Resource Sharing (CORS). This will set the following response header: Access-Control-Allow-Origin: \*
gzip Gzip compression on content larger than 1 KB.
expire Adding or modifying the Expires and Cache-Control response header fields that are sent to the client if the HTTP response status code equals 200, 201, 204, 206, 301, 302, 303, 304, or 307. This setting overwrites the value received from the origin in case of a Pull Zone. The expire value only has an impact on the web browser cache and not on the KeyCDN cache:
-1 Cache-Control: no-cache
0 Push Zone: disabled
Pull Zone: as received from the origin (header honoring)
>0 Cache-Control: max-age=t where t is the time specified in the directive in minutes converted to seconds
blockbadbots Block bad bots.
allowemptyreferrer Allow requests with an empty Referer request header value.
securetoken Restrict access to all content within Zone by Secure Token.
securetokenkey Secret used to check authenticity of request.
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://example-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 need to remove an exising Zone Alias first before enabling the letsencrypt option (or recreate the Zone Alias afterwards).
customsslkey Insert the private certificate key, including the -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- statements.
customsslcert The required format of the SSL/TLS certificate is PEM (Base64 encoded ASCII), which is the most common format that Certificate Authorities issue. Options to insert the 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 (301 Moved Permanently).
originurl URL with protocol (http:// or https://) of the origin server where content is automatically pulled from. Only include the protocol and hostname (e.g. https://www.example.com). Do not include a file path (e.g. https://www.example.com/index.html).
originshield Instead of our edge servers, predefined shield servers will pull content from the origin server. 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 yet been cached.
cachemaxexpire Define the maximum time for which cacheable content will be retained without checking the origin server. Applies only if NOT defined by the origin server, either by X-Accel-Expires, Cache-Control, or Expires.
cacheignorecachecontrol Disables processing of Cache-Control response header fields from the origin server (ignores X-Accel-Expires, Cache-Control, and Expires). cachemaxexpire has precedence if enabled.
cacheignorequerystring Tells the edge server cache to respond with a cached response even if the query string differs (ignores the presence of query strings).
cachehostheader Forwards the Host header (Host: cdn.example.com) to the origin server as received from the client instead of the host from the origin URL.
cachekeyscheme Scheme based caching (http or https) as requested by the client.
cachekeyhost Dynamic caching based on the Host header (Host: cdn.example.com) that matches the Zone Alias.
cachekeycookie Cookie variable based caching as received in the client request header.
cachekeydevice Device-based caching, such as desktop, tablet, and mobile.
cachebr Cache Brotli compressed content from the origin server. This can only be enabled if the origin server supports Brotli.
cachecookies By default, content with cookies are not cacheable. However, enabling this setting will ignore the presence of cookies and therefore force the edge servers to cache the content.
cachestripcookies This feature strips the cookies received from the origin server. The client will not receive the Set-Cookie response header. It is highly recommended to enable this setting when cachecookies is enabled.
cachexpullkey Specify an X-Pull request header key (e.g. X-Pull: {cachexpullkey}). This is a custom request header that can serve multiple purposes, like restricting access to the origin server or allowing all KeyCDN edge server requests through a firewall.
cachecanonical Add a canonical header in order to improve SEO (e.g. Link: <https://example.com/index.html>; rel="canonical"). Reference is the originurl.
cacherobots Block crawlers from indexing content in a Zone. Adding or modifying the robots.txt to the following:
                                        
                                            User-agent: *
                                            Disallow: /
                                        
                                    
cacheerrorpages Generic error pages for 4xx and 5xx errors instead of error page received from the origin server.
dirlist Generates directory indexes automatically, similar to the Unix ls command or the Win32 dir shell command. It is recommended to disable this setting.
dirindex Serving the directory index (index.html) without being specified in the URL. If it exists, a request for https://example.com/docs/ would return https://example.com/docs/index.html.

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,
letsencrypt, or custom
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 for a given 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 specific URLs 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 protocol
By default, use the Zone URL to purge content (e.g. examplepull-1a2b.kxcdn.com). Only use the Zone Alias (e.g. cdnpull.example.com) if cachekeyhost is enabled.

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)."
                    }
                
            
        

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"
                                }
                            ]
                        }
                    }