CDN API

The LeaseWeb CDN API allows you to manage your CDN zones, files and more. JSON will be returned in all responses from the API, unless stated otherwise.

Authentication

<?php
$secret = 'mySecretKey';
$customer_number = '1234567890';
$zone_id = '100';
$path = '/zones/push/' . $customer_number . '/' . $zone_id;
$time = time();
$signature = sha1($secret.$time.$path);
$full_path = 'https://api.leasewebcdn.com'.$path.'/'.$time.'/'.$signature;
curl "https://api.leasewebcdn.com/rules/push/1234567890/1364999235/a964f2ee0b04408df2e6ae561a27ed6ea481e2f7"
import hashlib
import time
secret = 'mySecretKey'
customer_number = '1234567890'
zone_id = '100'
url = '/zones/push/' + customer_number + '/' + zone_id
timestamp = int(time.time())
hashed_signature = hashlib.sha1(secret + str(timestamp) + url).hexdigest()
full_url = 'https://api.leasewebcdn.com{0}/{1}/{2}'.format(url, timestamp, hashed_signature)

To use the LeaseWeb CDN API you must use the secret key provided in LeaseWeb’s CDN Control Panel](https://my.leasewebcdn.com/) and authenticate at each call. The algorithm used for authentication is the following:

  1. Get the URL you want to access
  2. Get the current timestamp (Must be in UTC timezone)
  3. sha1(key + timestamp + URL)
  4. Append timestamp to the URL
  5. Append signature to the URL

All API calls must be made over HTTPS. The base URL is: https://api.leasewebcdn.com


Purge

Purge file(s) from a zone

curl -X POST -d '{"urls":["/path/to/file.jpg"]}' "https://api.leasewebcdn.com/content/purge/1234567890/123/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/content/purge/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$zoneId = '123';

$resource = sprintf($resource, $customerNumber, $zoneId);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$data = array(
  'urls' => array('/path/to/file.jpg'),
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib
import json

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
zoneId = '123'

resource = '/content/purge/{0}/{1}'.format(customerNumber, zoneId)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)
data = {'urls': ['/path/to/file.jpg']}

try:
  response = requests.post(fullUrl, data=json.dumps(data))
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success": 1234
}

To purge a file from a zone, send a POST request to /content/purge/{customer_number}/{zone_id}/.

The payload of the POST request must be an object with a single element urls, which has a list of files that will be purged.

To purge all the cached files provide the wildcard as the first element of the list, e.g., {'urls': ['*']}. Be very careful with this option, because it will instantly purge all cached files! This can have great consequences for the load on your origin servers.

The response will be a JSON object with the key success that contains a jobID e.g.: 1234 for the purge job.

Name Type Description
success integer The job ID

Retrieve the status of a Purgejob

curl -X GET "https://api.leasewebcdn.com/content/purge/1234567890/123/12/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/content/purge/%s/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$zoneId = '123';
$jobId = '12';

$resource = sprintf($resource, $customerNumber, $zoneId, $jobId);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
zoneId = '123'
jobId = '12'

resource = '/content/purge/{0}/{1}'.format(customerNumber, zoneId, jobId)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success":
  [
    {
    "http://thumbs.leaseweb.com/image.jpg": "Queued"
    }
  ]
}

To retrieve the the Purge job information, send a GET request to /content/purge/{customer_number}/{zone_id}/{job_id}.

The response will be a JSON object with the key success that contains the files to be purged for the purge job.

Name Type Description
http://thumbs.leaseweb.com/images.jpg string Queued

Prefetch (warm up)

Prefetch file(s) from a zone

curl -X POST -d '{"urls":["/path/to/file.jpg"]}' "https://api.leasewebcdn.com/content/warmup/1234567890/123/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/content/warmup/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$zoneId = '123';

$resource = sprintf($resource, $customerNumber, $zoneId);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$data = array(
  'urls' => array('/path/to/file.jpg'),
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib
import json

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
zoneId = '123'

resource = '/content/warmup/{0}/{1}'.format(customerNumber, zoneId)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)
data = {'urls': ['/path/to/file.jpg']}

try:
  response = requests.post(fullUrl, data=json.dumps(data))
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success": "f4b57bd0-54f3-11e7-9598-0800200c9a66"
}

To prefetch a file from a zone, send a POST request to /content/warmup/{customer_number}/{zone_id}/.

The payload of the POST request must be an object with a single element urls, which has a list of files that will be prefetched.

The response will be a JSON object with the key success that contains a job GUID e.g.: f4b57bd0-54f3-11e7-9598-0800200c9a66 for the prefetch job.

Name Type Description
success integer The job GUID

Retrieve the status of a prefetch job

curl -X GET "https://api.leasewebcdn.com/content/warmup/1234567890/123/12/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/content/warmup/%s/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$zoneId = '123';
$jobId = 'f4b57bd0-54f3-11e7-9598-0800200c9a66';

$resource = sprintf($resource, $customerNumber, $zoneId, $jobId);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
zoneId = '123'
jobId = 'f4b57bd0-54f3-11e7-9598-0800200c9a66'

resource = '/content/warmup/{0}/{1}'.format(customerNumber, zoneId, jobId)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
    "completed": true
}

To retrieve the the prefetch job information, send a GET request to /content/warmup/{customer_number}/{zone_id}/{job_guid}.

The response will be a JSON object with the key completed that contains the result for prefetch job.

Name Type Description
completed boolean Prefetch job status

Customers

Retrieve Customer information

curl -X GET "https://api.leasewebcdn.com/customers/1234567890/20/0/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/customers/%s/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$limit = '20';
$offset = '0';

$resource = sprintf($resource, $customerNumber, $limit, $offset);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
limit = '20'
offset = '0'

resource = '/customers/{0}/{1}/{2}'.format(customerNumber,limit,offset)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success":
  {
    "ftp_quota":100,
    "reseller":0,
    "parent":"1234567890",
    "companyName":"LeaseWeb",
    "api_secret":"f33f333ff33f33ff3fff333f333f33f3f3f333ff",
    "created_at":1418165896,
    "updated_at":1418165896,
    "customer_number":"12345",
    "active":1,
    "id":123,
    "notes":"This is a test"
  }
}

To retrieve the Customers information, send a GET request to /customers/{customer_number}/{limit}/{offset}.

The response will be a JSON object with the key success that contains the customers information.

Name Type Description
ftp_quota integer The ftp quota assigned to the customer
reseller integer If the customer is a reseller
parent string The parent customer number
companyName string The company name of the customer
api_secret string The api secret of the customer
created_at timestamp When the customer was created
updated_at timestamp When the customer was last updated
customer_number string The customer number
id integer The customer ID
active integer If the customer is active
notes string Notes added to the customer

Retrieve subCustomer information

curl -X GET "https://api.leasewebcdn.com/customers/reseller/1234567890/12345/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/customers/reseller/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$subCustomerNumber = '12345';

$resource = sprintf($resource, $customerNumber, $subCustomerNumber);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
subCustomerNumber = '12345'

resource = '/customers/reseller/{0}/{1}'.format(customerNumber,subCustomerNumber)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success":
  {
    "1407900413":
    {
      "0":
      {
        "active":1,
        "api_secret":"111f111f1f1f1f1fff1f1f1f1f111f1f1f1f1ffff1f",
        "ftp_quota":100,
        "reseller":0,
        "companyName":"LeaseWeb",
        "notes":"This is a test",
        "customer_number":"12345"
      },
      "1":
      {
        "active":1,
        "api_secret":"111f111f1f1f1f1fff1f1f1f1f111f1f1f1f1ffff1f",
        "ftp_quota":100,
        "reseller":0,
        "companyName":"LeaseWeb",
        "notes":"This is a test",
        "customer_number":"12346"
      },
      "2":
      {
        "active":1,
        "api_secret":"111f111f1f1f1f1fff1f1f1f1f111f1f1f1f1ffff1f",
        "ftp_quota":100,
        "reseller":0,
        "companyName":"LeaseWeb",
        "notes":"This is a test",
        "customer_number":"12347"
       }
    }
  }
}

To retrieve the subCustomer information, send a GET request to /customers/reseller/{customerNumber}/{subCustomerNumber}.

The response will be a JSON object with the key success and your customer_number key that contains the subCustomers information.

Name Type Description
reseller integer If the subCustomer is a reseller
companyName string The company name of the subCustomer
notes string Notes added to the subCustomer
active integer If the subCustomer is active
api_secret string The api secret key of the subCustomer
ftp_quota integer The ftp quota set to the subCustomer
customer_number string The customer number of the subCustomer

Update or create a subCustomer

curl -X POST -d '{"active":"1","ftp_quota":"5000"}' "https://api.leasewebcdn.com/customers/reseller/1234567890/12345/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/customers/reseller/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$subCustomerNumber = '12345';

$resource = sprintf($resource, $customerNumber, $subCustomerNumber);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$data = array(
  "active" => 1,
  "ftp_quota" => 5000
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

$output = curl_exec($ch);

echo $output;
import time
import request
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
subCustomerNumber = '12345'

resource = '/customers/reseller/{0}/{1}'.format(customerNumber,subCustomerNumber)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)
data = {'active': '1','ftp_quota': '5000'}

try:
  response = requests.post(fullUrl, data=data)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success":
  {
    "1407900413":
    {
      "0":
      {
        "active":1,
        "api_secret":"111f111f1f1f1f1fff1f1f1f1f111f1f1f1f1ffff1f",
        "ftp_quota":100,
        "reseller":0,
        "companyName":"LeaseWeb",
        "notes":"This is a test",
        "customer_number":"12345"
      }
    }
  }
}

To update or create a subCustomer, send a POST request to /customers/{customer_number}/{subCustomer_number}.

The response will be a JSON object with the key success.

Name Type Description
reseller integer If the subCustomer is a reseller
companyName string The company name of the subCustomer
notes string Notes added to the subCustomer
active integer If the subCustomer is active
api_secret string The api secret key of the subCustomer
ftp_quota integer The ftp quota set to the subCustomer
customer_number string The customer number of the subCustomer

Retrieve a customers Access Control List

curl -X GET "https://api.leasewebcdn.com/customers/acl/1234567890/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/customers/acl/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';

$resource = sprintf($resource, $customerNumber);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'

resource = '/customers/acl/{0}'.format(customerNumber)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success":
  {
    "12345":
    {
      "content":
      {
        "POST":true,
        "GET":true,
        "DELETE":true
      },
      "search":
      {
        "GET":true
      },
      "stats":
      {
        "GET":true
      },
      "logs":
      {
        "GET":true
      },
      "origins":
      {
        "PUT":false,
        "POST":false,
        "GET":false,
        "DELETE":false
      },
      "customers":
      {
        "POST":true,
        "GET":true,
        "DELETE":true
      },
      "zones":
      {
        "POST":true,
        "GET":true,
        "DELETE":true
      },
      "ftplog":
      {
        "POST":false,
        "GET":false,
        "DELETE":false
      }
    }
  }
}

To retrieve the customers Access Control List, send a GET request to /customers/acl/{customer_number}.

The response will be a JSON object with the key success and customer_number key that contains the information. The Access Control List contains settings that can be either true or false

Name Type Description
content array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
search array
> GET boolean GET permissions
——————- ——— ————————————————————–
stats array
> GET boolean GET permissions
——————- ——— ————————————————————–
logs array
> GET boolean GET permissions
——————- ——— ————————————————————–
origins array
> PUT boolean PUT permissions
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
customers array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
zones array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
ftplog array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions

Update a customers Access Control List

curl -X POST -d '{'acl': '{"content":{"POST":true,"GET":true,"DELETE":true},"search":{"GET":true},"stats":{"GET":true},"logs":{"GET":true},"origins":{"PUT":true,"POST":true,"GET":true,"DELETE":true},"customers":{"POST":true,"GET":true,"DELETE":true},"zones":{"POST":true,"GET":true,"DELETE":true},"ftplog":{"POST":true,"GET":true,"DELETE":true}}'}' "https://api.leasewebcdn.com/customers/acl/1234567890/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/customers/acl/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';

$resource = sprintf($resource, $customerNumber);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$data = array("acl" =>
                json_encode(array(
                    "content" =>
                        array("POST"   => true,
                              "GET"    => true,
                              "DELETE" => true),
                    "search" =>
                        array("GET"    => true),
                    "stats" =>
                        array("GET"    => true),
                    "logs" =>
                        array("GET"    => true),
                    "origins" =>
                        array("PUT"    => true,
                              "POST"   => true,
                              "GET"    => true,
                              "DELETE" => true),
                    "customers" =>
                        array("POST"   => true,
                              "GET"    => true,
                              "DELETE" => true),
                    "zones" =>
                        array("POST"   => true,
                              "GET"    => true,
                              "DELETE" => true),
                    "ftplog" =>
                        array("POST"   => true,
                              "GET"    => true,
                              "DELETE" => true),
                    )));

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'

resource = '/customers/acl/{0}'.format(customerNumber)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)
data = {'acl': '{"content":{"POST":true,"GET":true,"DELETE":true},"search":{"GET":true},"stats":{"GET":true},"logs":{"GET":true},"origins":{"PUT":true,"POST":true,"GET":true,"DELETE":true},"customers":{"POST":true,"GET":true,"DELETE":true},"zones":{"POST":true,"GET":true,"DELETE":true},"ftplog":{"POST":true,"GET":true,"DELETE":true}}'}

try:
  response = requests.post(fullUrl, data=data)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success":
  {
    "12345":
    {
      "content":
      {
        "POST":true,
        "GET":true,
        "DELETE":true
      },
      "search":
      {
        "GET":true
      },
      "stats":
      {
        "GET":true
      },
      "logs":
      {
        "GET":true
      },
      "origins":
      {
        "PUT":false,
        "POST":false,
        "GET":false,
        "DELETE":false
      },
      "customers":
      {
        "POST":true,
        "GET":true,
        "DELETE":true
      },
      "zones":
      {
        "POST":true,
        "GET":true,
        "DELETE":true
      },
      "ftplog":
      {
        "POST":false,
        "GET":false,
        "DELETE":false
      }
    }
  }
}

To update the Access Control List, send a POST request to /customers/acl/{customer_number}/.

The response will be a JSON object with the key success and customer_number key that contains the information. The Access Control List contains settings that can be either true or false

Name Type Description
content array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
search array
> GET boolean GET permissions
——————- ——— ————————————————————–
stats array
> GET boolean GET permissions
——————- ——— ————————————————————–
logs array
> GET boolean GET permissions
——————- ——— ————————————————————–
origins array
> PUT boolean PUT permissions
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
customers array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
zones array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
ftplog array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions

Delete a customers Access Control List

curl -X DELETE "https://api.leasewebcdn.com/customers/acl/1234567890/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/customers/acl/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';

$resource = sprintf($resource, $customerNumber);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'

resource = '/customers/acl/{0}'.format(customerNumber)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.delete(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success":
  {
    "12345":
    {
      "content":
      {
        "POST":true,
        "GET":true,
        "DELETE":true
      },
      "search":
      {
        "GET":true
      },
      "stats":
      {
        "GET":true
      },
      "logs":
      {
        "GET":true
      },
      "origins":
      {
        "PUT":false,
        "POST":false,
        "GET":false,
        "DELETE":false
      },
      "customers":
      {
        "POST":true,
        "GET":true,
        "DELETE":true
      },
      "zones":
      {
        "POST":true,
        "GET":true,
        "DELETE":true
      },
      "ftplog":
      {
        "POST":false,
        "GET":false,
        "DELETE":false
      }
    }
  }
}

To delete the Access Control List, send a DELETE request to /customers/acl/{customer_number}/.

The response will be a JSON object with the key success and customer_number key that contains the information. The Access Control List contains settings that can be either true or false

Name Type Description
content array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
search array
> GET boolean GET permissions
——————- ——— ————————————————————–
stats array
> GET boolean GET permissions
——————- ——— ————————————————————–
logs array
> GET boolean GET permissions
——————- ——— ————————————————————–
origins array
> PUT boolean PUT permissions
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
customers array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
zones array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions
——————- ——— ————————————————————–
ftplog array
> POST boolean POST permissions
> GET boolean GET permissions
> DELETE boolean DELETE permissions

Origins

Retrieve all origins

curl -X GET "https://api.leasewebcdn.com/origins/1234567890/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/origins/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';

$resource = sprintf($resource, $customerNumber);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'

resource = '/origins/{0}'.format(customerNumber)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "succes":
    {
      "id": 1,
      "label": "My thumbs Origin",
      "origin": "http://thumbs.leaseweb.com",
      "refresh_every": 86400,
      "ignore_cache_control": 0,
      "basic_auth_user": "Leaseweb",
      "basic_auth_password" : "bewesaeL",
      "headers_origin" : "User-Agent: f222222ff2f2222f2f2ff2ff2ff22222"
    }
}

To retrieve all origins, send a GET request to /origins/{customer_number}.

The response will be a JSON object with the key success that contains the origins.

Name Type Description
id integer The ID of the Origin
origin_type string Type of origin: “simple” or “s3”
label string Custom name for the Origin
origin string The URL (HTTP) of the customer’s source, on domain level
s3_bucket_name string The name of the S3 bucket (if origin type is S3) or empty string otherwise
refresh_every integer Refresh time for the Origin
ignore_cache_control integer Ignore Origin Cache Control values set by the Origin and use the CDN values. (0 = Inactive, 1 = Active)
proxy_header_host string The host sent in the header
cache_key string The key used to define the caching
basic_auth_user string The username (or access key id for s3 origin) that is used to authenticate the Origin
basic_auth_password string The password (or access key secret for s3 origin) that is used to authenticate the Origin
headers_origin string The HTTP headers that are added to the Origin request

Create a new origin

curl -X POST -d '{"label":"Origin","origin":"http://origin.example.com","refresh_every":86400,"ignore_cache_refresh":0,"headers_origin":"User-Agent:*"}' "https://api.leasewebcdn.com/origins/12345/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/origins/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';

$resource = sprintf($resource, $customerNumber);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$data = array(
  "label" => "Origin",
  "origin" => "http://origin.example.com",
  "refresh_every" => 86400,
  "ignore_cache_refresh" => 0,
  "headers_origin" => "User-Agent: *");

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = 'asfee3eqeq23eeded23eqed'
timestamp = int(time.time())

customerNumber = '12345'

resource = '/origins/{0}/'.format(customerNumber)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)
data = {'label':'Origin','origin':'http://origin.example.com','refresh_every': 86400, 'ignore_cache_refresh': 0, 'headers_origin': 'User-Agent: *'}

try:
  response = requests.post(fullUrl, data=data)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "succes":
    {
      "id": 1,
      "label": "My thumbs Origin",
      "origin": "http://thumbs.leaseweb.com",
      "refresh_every": 86400,
      "ignore_cache_control": 0,
      "basic_auth_user": "Leaseweb",
      "basic_auth_password" : "bewesaeL",
      "headers_origin" : "User-Agent: f222222ff2f2222f2f2ff2ff2ff22222"
    }
}

To create an new origin, send a POST request to /origins/{customer_number}.

The response will be a JSON object with the key success that contains the new origin.

Name Type Description
label string Custom name for the Origin
origin string The URL (HTTP) of the customer’s source, on domain level
refresh_every integer Refresh time for the Origin
ignore_cache_control integer Ignore Origin Cache Control values set by the Origin and use the CDN values. (0 = Inactive, 1 = Active)
basic_auth_user string The username that is used to authenticate the Origin
basic_auth_password string The password that is used to authenticate the Origin
headers_origin string The HTTP headers that are added to the Origin request

Retrieve a single Origin

curl -X GET "https://api.leasewebcdn.com/origins/1234567890/123/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/origins/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$originID = '123';

$resource = sprintf($resource, $customerNumber, $originID);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
originID = '123'

resource = '/origins/{0}/{1}'.format(customerNumber,originID)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "succes":
    {
      "id": 1,
      "label": "My thumbs Origin",
      "origin": "http://thumbs.leaseweb.com",
      "refresh_every": 86400,
      "ignore_cache_control": 0,
      "basic_auth_user": "Leaseweb",
      "basic_auth_password" : "bewesaeL",
      "headers_origin" : "User-Agent: f222222ff2f2222f2f2ff2ff2ff22222"
    }
}

To retrieve a specific Origin, send a GET request to /origins/{customer_number}/{originID}.

The response will be a JSON object with the key success that contains the specified origin.

Name Type Description
id integer The ID of the Origin
origin_type string Type of origin: “simple” or “s3”
label string Custom name for the Origin
origin string The URL (HTTP) of the customer’s source, on domain level
s3_bucket_name string The name of the S3 bucket (if origin type is S3) or empty string otherwise
refresh_every integer Refresh time for the Origin
ignore_cache_control integer Ignore Origin Cache Control values set by the Origin and use the CDN values. (0 = Inactive, 1 = Active)
proxy_header_host string The host sent in the header
cache_key string The key used to define the caching
basic_auth_user string The username (or access key id for s3 origin) that is used to authenticate the Origin
basic_auth_password string The password (or access key secret for s3 origin) that is used to authenticate the Origin
headers_origin string The HTTP headers that are added to the Origin request

Update a single Origin

curl -X PUT -d '{"label":"Origin","origin":"http://origin.example.com","refresh_every":"86400","ignore_cache_refresh":"0","headers_origin":"User-Agent: *"}' "https://api.leasewebcdn.com/origins/1234567890/123/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/origins/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$originID = '123';

$resource = sprintf($resource, $customerNumber, $originID);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$data = array(
  "label" => "Origin",
  "origin" => "http://origin.example.com",
  "refresh_every" => 86400,
  "ignore_cache_refresh" => 0,
  "headers_origin" => "User-Agent: *");

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
originId = '123'

resource = '/origins/{0}/{1}'.format(customerNumber,originID)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)
data = {'label':'Origin','origin':'http://origin.example.com','refresh_every': 86400, 'ignore_cache_refresh': 0, 'headers_origin': 'User-Agent: *'}

try:
  response = requests.put(fullUrl, data=data)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success": ""
}

To update a specific Origin, send a PUT request to /origins/{customer_number}/{originID}.

The response will be a JSON object with the key success that contains the specified origin.

Name Type Description
label string Custom name for the Origin
origin string The URL (HTTP) of the customer’s source, on domain level
refresh_every integer Refresh time for the Origin
ignore_cache_control integer Ignore Origin Cache Control values set by the Origin and use the CDN values. (0 = Inactive, 1 = Active)
basic_auth_user string The username that is used to authenticate the Origin
basic_auth_password string The password that is used to authenticate the Origin
headers_origin string The HTTP headers that are added to the Origin request

Delete a single Origin

curl -X DELETE "https://api.leasewebcdn.com/origins/1234567890/123/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/origins/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$originID = '123';

$resource = sprintf($resource, $customerNumber, $originID);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
originID = '123'

resource = '/origins/{0}/{1}'.format(customerNumber,originID)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.delete(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
    "success": ""
}

To delete an specific origin, send a DELETE request to /origin/{customer_number}/{originID}.

The response will be a JSON object with the key success.

Name Type Description
success string This string will be empty

Search

Retrieve search results (zones) for the given query

curl -X GET "https://api.leasewebcdn.com/search/origin/1234567890/thumbs/20/0/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/search/%s/%s/%s/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$zoneType = 'origin';
$customerNumber = '1234567890';
$query = 'thumbs';
$limit = '20';
$offset = '0';

$resource = sprintf($resource, $zoneType, $customerNumber, $query, $limit, $offset);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

zoneType = 'origin'
customerNumber = '1234567890'
query = 'thumbs'
limit = '20'
offset = '0'

resource = '/search/{0}/{1}/{2}/{3}/{4}'.format(zoneType,customerNumber,query,limit,offset)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "total":1,"success":
  [
    {
      "origin":"http://thumbs.leaseweb.com",
      "nginx_config_version":"106",
      "origin_id":1,
      "updated_at":1424860619,
      "ignore_cache_control":1,
      "max_filesize":"40m",
      "use_stale":0,
      "secure_manifest_only":0,
      "id":1,
      "global_secret":"",
      "basic_auth_user":"",
      "origin_label":"http://thumbs.leaseweb.com",
      "secure_url_active":0,
      "blocked_countries":"",
      "headers_add":"",
      "secure_url_ip":0,
      "headers_origin":"",
      "template":null,
      "push_zone_id":null,
      "customer_id":1,
      "content_disposition":0,
      "burst_size":null,
      "gzip":1,
      "refresh_every":10,
      "expires":"-1",
      "query_string":0,
      "active":1,
      "strip_cookies":0,
      "ftp_logs":0,
      "basic_auth_password":"",
      "referrer":"",
      "created_at":1410451694,
      "transfer_rate":null,
      "headers":"",
      "cname":"thumbs.leasewebcdn.com",
      "headers_remove":"",
      "zone_type":"hls",
      "origin_urlencoding":0,
      "dvr":0
    }
  ]
}

To search for a zone, send a GET request to /search/{zone_type}/{customer_number}/{query}/{limit}/{offset}.

The response will be a JSON object with the key success that contains the search result.

Name Type Description
origin string The URL (HTTP) of the source, on domain level
origin_s3_bucket_name string The name of the origin S3 bucket (if origin type is S3) or empty string otherwise
origin_type string Type of source origin: “simple” or “s3”
expires_404 integer The amount of time (in seconds) the 404 reply from the origin server is kept in cache
nginx_config_version string The config version of NGINX
origin_id integer The zone ID
sub_path string The sub path of the origin
secure_url_mode string Describes which mode is active (Simple, Advanced or disabled)
expires string The amount of time (in seconds) an URL will be held in the CDN’s cache
https_redirect string Redirects http traffic to https. Can either be disabled, temporary or permanent
updated_at integer Timestamp (UTC) when the zone was last updated
ignore_cache_control integer Ignore Origin Cache Control values set by the Origin and use the CDN values. (0 = Inactive, 1 = Active)
gzip integer Reduces the size of web content and improves the overall speed (0 = Inactive, 1 = Active)
whitelist string IPs or subnets added to the whitelist will always be allowed to access your content
aes_key string 64 character long string that is used to generate the secure link in encrypted mode
whitelisted_files string A list of files that are available even if secure_url_mode is enabled
active integer If the zone is active. (0 = Inactive, 1 = Active)
burst_size integer The initial data that can be downloaded at full speed before the specified transfer rate takes effect
sha_key string 64 character long string that is used to generate the secure link in encrypted mode
id integer The ID assigned to the Pull Zone
global_secret string A password used to generate the Secure URL
referrer string HTTP referral restrictions
referrer_check string The checking can be either on or off
vary_header integer If the vary header is enabled in the NGINX config. (0 = Inactive, 1 = Active)
query_string integer Include the query string as part of the cache key. (0 = Inactive, 1 = Active)
transfer_rate integer The bandwidth limit per connection in Kbps
alias string Aliases set for the CNAME
cname string Canonical Name for the Zone
origin_label string The label used for the Origin
zone_type string The type of the Pull Zone
headers_origin string The headers that are passed through from the Origin
created_at integer Timestamp (UTC) when the zone was created
refresh_every integer Refresh time for the zone

Statistics (deprecated)

Retrieve statistics data

curl -X GET "https://api.leasewebcdn.com/stats/hourly/1234567890/1433116800/1435708800/origin.example.com/NL/ams1/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/stats/%s/%s/%s/%s/%s/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$granularity = 'hourly';
$customerNumber = '1234567890';
$timestampStart = '1433116800';
$timestampEnd = '1435708800';
$cname = 'origin.example.com';
$country = 'nl';
$pop = 'ams1';

$resource = sprintf($resource, $granularity, $customerNumber, $timestampStart, $timestampEnd, $cname, $country, $pop);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

granularity = 'hourly'
customerNumber = '1234567890'
timestampStart = '1433116800'
timestampEnd = '1435708800'
cname = 'origin.example.com'
country = 'nl'
pop = 'ams1'

resource = '/stats/{0}/{1}/{2}/{3}/{4}/{5}/{6}'.format(granularity,customerNumber,timestampStart,timestampEnd,cname,country,pop)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
   "success":
   {
        "1234567890":
        {
            "2014_094_05_BytesCount": 5938,
            "2014_094_05_DownloadTime": 234,
            "2014_094_05_HitCount": 2,
            "2014_094_08_HitHTTPSCount": 0
        }
    }
}

To retrieve statistics for the given data, send a GET request to /stats/{granularity}/{customer_number}/{timestamp_start}/{timestamp_end}/{cname}/{county}/{pop}.

The response will be a JSON object with the key success that contains the statistics.

Name Type Description
date_BytesCount integer The amount of bytes used
date_DownloadTime integer The amount of downloads
date_HitCount integer The amount of HTTP hits
date_hitHTTPSCount integer The amount of HTTPS hits

Retrieve statistics data for the given type

curl -X GET "https://api.leasewebcdn.com/stats/geo/hourly/1234567890/1433116800/1435708800/origin.example.com/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/stats/%s/%s/%s/%s/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$type = 'geo';
$granularity = 'hourly';
$customerNumber = '1234567890';
$timestampStart = '1433116800';
$timestampEnd = '1435708800';
$cname = 'origin.example.com';

$resource = sprintf($resource, $type, $granularity, $customerNumber, $timestampStart, $timestampEnd, $cname);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

type = 'geo'
granularity = 'hourly'
customerNumber = '1234567890'
timestampStart = '1433116800'
timestampEnd = '1435708800'
cname = 'origin.example.com'

resource = '/stats/{0}/{1}/{2}/{3}/{4}/{5}'.format(type,granularity,customerNumber,timestampStart,timestampEnd,cname)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
    "success": {
        "1234567890": {
            "1397001600":{
                "CA": 45,
                "JP": 4,
                "US": 383,
                "AT": 2,
                "BR": 18,
                "PE": 19,
                "MX": 46
            },
            "1397088000": {
                "BE": 4,
                "FR": 1,
                "BG": 6,
                "RO": 36,
                "DE": 69,
                "JP": 61,
                "HU": 3
            },
            "1396310400": {}
        }
    }
}

To retrieve statistics for the given data, send a GET request to /stats/{type}/{granularity}/{customer_number}/{timestamp_start}/{timestamp_end}/{cname}/{county}/{pop}.

The response will be a JSON object with the key success that contains the statistics.

Name Type Description
timestamp array This array contains the data per country (e.g.: “CA”: 45)

Retrieve overview data

curl -X GET "https://api.leasewebcdn.com/stats/overview/1234567890/1433116800/self/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/stats/overview/%s/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$timestampStart = '1433116800';
$forWho = 'self';

$resource = sprintf($resource, $customerNumber, $timestampStart, $forWho);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
timestampStart = '1433116800'
forWho = 'self'

resource = '/stats/overview/{0}/{1}/{2}'.format(customerNumber,timestampStart,forWho)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
    "success":{
        "total":195442538324,
        "1234567890":{
            "zones":{
                "test1.leasewebcdn.com":1108348745,
                "test2.leasewebcdn.com":84774346,
                "test3.leasewebcdn.com":0,
                "test4.leasewebcdn.com":3224,
                "test5.leasewebcdn.com":731600100,
                "test6.leasewebcdn.com":6442471415
            },
            "total":8367197830
        },
        "subcustomers":[
            {
                "12345":{
                    "zones":{
                        "test1.example.com":178975123124
                    },
                    "total":178975123124
                }
            },
            {
                "12346":{
                    "zones":{
                        "test2.example.com":0,
                        "test3.example.com":0
                    },
                    "total":0
                }
            },
            {
                "12347":{
                    "zones":{
                        "cdn.example.com":427118373,
                        "cdn2.example.fm":248567503,
                        "mycdn.example.nl":17400,
                        "cdn3.example.nl":0
                    },
                    "total":675703276
                }
            },
            {
                "12348":{
                    "zones":{
                        "cdn4.example.com":6307178932,
                        "static-cdn.example.com":99791655,
                        "static.example.com":1017543507
                    },
                    "total":7424514094
                }
            }
        ]
    }
}

To retrieve overview statistics for the given data, send a GET request to /stats/overview/{customer_number}/{timestamp_start}/{for_who}.

The response will be a JSON object with the key success that contains the statistics.

Name Type Description
total integer The total of all collected data
———————- ——— ————————————————————————————————–
customerNumber array
> zones array This array contains all zones registered to the customer (e.g: “thumbs.leaseweb.com”: 123123)
> total integer The total of all the customers zones
———————- ——— ————————————————————————————————–
subCustomers array
> subCustomerNumber array
>> zones array This array contains all zones registered to the subCustomer (e.g: “thumbs.leaseweb.com”: 123123)
>> total integer The total of all the subCustomers zones

Retrieve the amount of api requests

curl -X GET "https://api.leasewebcdn.com/stats/api/1234567890/2015/7/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/stats/api/%s/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$year = '2015';
$month = '7';

$resource = sprintf($resource, $customerNumber, $year, $month);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
year = '2015'
month = '7'

resource = '/stats/api/{0}/{1}/{2}'.format(customerNumber,year,month)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
    "success":{
        "1234567890":0
        }
}

To retrieve the number of API calls for the given data, send a GET request to /stats/api/{customer_number}/{year}/{month}.

The response will be a JSON object with the key success that contains the statistics.

Name Type Description
customerNumber integer The amount of API calls made

Retrieve the amount of hits

curl -X GET "https://api.leasewebcdn.com/stats/traffic/1234567890/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/stats/traffic/%s/';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';

$resource = sprintf($resource, $customerNumber);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'

resource = '/stats/traffic/{0}'.format(customerNumber)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
    "success":
    {
        "1234567890":"1250"
    }
}

To retrieve the average traffic in Mb/s for the given data, send a GET request to /stats/traffic/{customer_number}.

The response will be a JSON object with the key success that contains the statistics.

Name Type Description
customerNumber integer The average traffic in Mb/s

Retrieve the 95th percentile points

curl -X GET "https://api.leasewebcdn.com/stats/95thpercentilepoints/1234567890/eu/1433116800/1435708800/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/stats/95thpercentilepoints/%s/%s/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$billingRegion = 'eu';
$timestampStart = '1433116800';
$timestampEnd = '1435708800';

$resource = sprintf($resource, $customerNumber, $billingRegion, $timestampStart, $timestampEnd);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
billingRegion = 'eu'
timestampStart = '1433116800'
timestampEnd = '1435708800'

resource = '/stats/95thpercentilepoints/{0}/{1}/{2}/{3}'.format(customerNumber,billingRegion,timestampStart,timestampEnd)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success":
    {
      "1234567890":
        {
          "95thpercentile":"7432",
          "points":
          {
            "1403289600":7911,
            "1404010500":3031,
            "1402273800":2709,
            "1402994700":5896,
            "1403715600":7306,
            "1401978900":1205,
            "1402699800":3128,
            "1403584500":4411,
            "1401847800":4693,
            "1402568700":4550
          }
      }
  }
}

To retrieve the 95th percentile points for the given data, send a GET request to /stats/95thpercentilepoints/{customer_number}/{billing_region}/{timestamp_start}/{timestamp_end}.

The response will be a JSON object with the key success that contains the statistics.

Name Type Description
customerNumber array
> 95thpercentile string the 95th percentile
> points array This array contains all the points (e.g: “1403289600”: 7945)

Retrieve the 95th percentile

curl -X GET "https://api.leasewebcdn.com/stats/95thpercentile/1234567890/eu/1433116800/1435708800/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/stats/95thpercentile/%s/%s/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$billingRegion = 'eu';
$timestampStart = '1433116800';
$timestampEnd = '1435708800';

$resource = sprintf($resource, $customerNumber, $billingRegion, $timestampStart, $timestampEnd);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
billingRegion = 'eu'
timestampStart = '1433116800'
timestampEnd = '1435708800'

resource = '/stats/95thpercentile/{0}/{1}/{2}/{3}'.format(customerNumber,billingRegion,timestampStart,timestampEnd)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
    "success":
    {
      "1234567890": 7432
    }
}

To retrieve the 95th percentile for the given data, send a GET request to /stats/95thpercentile/{customer_number}/{billing_region}/{timestamp_start}/{timestamp_end}.

The response will be a JSON object with the key success that contains the statistics.

Name Type Description
customerNumber integer The 95th percentile

Statistics

95th Percentile

curl -X GET "https://api.leasewebcdn.com/statistics/percentile/1234567890/1462203335/4a69f766bc48b1ed3d025339313196c388de8da5?start=2016-04-01T00:00:00+00:00&end=2016-05-01T00:00:00+00:00&pop=eu"
<?php
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$customerNumber = '1234567890';
$query_parameters = array(
    'start' => '2016-04-01T00:00:00+00:00',
    'end' => '2016-05-01T00:00:00+00:00',
    'pop' => 'eu',
);

$timestamp = time();
$resource = '/statistics/percentile/' . $customerNumber;
$hashedSignature = sha1($apiKey . $timestamp . $resource);
$fullUrl = sprintf('%s/%s/%s/%s?%s', $apiUrl, $resource, $timestamp, $hashedSignature, http_build_query($query_parameters));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'

customerNumber = '1234567890'
query_parameters = {
    'start': '2016-04-01T00:00:00+00:00',
    'end': '2016-05-01T00:00:00+00:00',
    'pop': 'eu'
}

timestamp = int(time.time())
resource = '/statistics/percentile/{0}'.format(customerNumber)
hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}/{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
    response = requests.get(fullUrl, params=query_parameters)
    print response.text
except requests.exceptions.RequestException as e:
    print e

Response Body

{
    "_metadata": {
        "from": "2016-04-01T00:00:00+00:00",
        "to": "2016-04-03T00:00:00+00:00",
        "customerNumber": "0123456789",
        "cname": "leasewebcdn.com",
        "alias": "my.leasewebcdn.com",
        "granularity": "day"
    },
    "metrics": {
        "percentileBps": {
            "unit": "bps",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        }
    }
}

GET /statistics/percentile/{customer_number}

Retrieve 95th percentile related statistics. The response can be filtered using the following query string parameters;

Query string parameters

Name Type Required Default Description
start date yes n/a Any date string accepted by dateutil.parser.parse to determine the start date of the statistics request, we recommend using a UNIX timestamp or RFC-3339.
end date yes n/a Any date string accepted by dateutil.parser.parse to determine the end date of the statistics request, we recommend using a UNIX timestamp or RFC-3339.
pop string no all The pop or region filter e.g.: us, eu, asia, ams1, fra1 or wdc1. Available regions and pops at /information/pops.
cname string no all The cname of a zone, can not be used in combination with the alias parameter.
alias string no all The alias of a zone, can not be used in combination with the cname parameter.

Bandwidth

curl -X GET "https://api.leasewebcdn.com/statistics/bandwidth/1234567890/1462203335/4a69f766bc48b1ed3d025339313196c388de8da5?start=2016-04-01T00:00:00+00:00&end=2016-04-02T00:00:00+00:00&granularity=5min"
<?php
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$customerNumber = '1234567890';
$query_parameters = array(
    'start' => '2016-04-01T00:00:00+00:00',
    'end' => '2016-04-02T00:00:00+00:00',
    'granularity' => '5min',
);

$timestamp = time();
$resource = '/statistics/bandwidth/' . $customerNumber;
$hashedSignature = sha1($apiKey . $timestamp . $resource);
$fullUrl = sprintf('%s/%s/%s/%s?%s', $apiUrl, $resource, $timestamp, $hashedSignature, http_build_query($query_parameters));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'

customerNumber = '1234567890'
query_parameters = {
    'start': '2016-04-01T00:00:00+00:00',
    'end': '2016-05-01T00:00:00+00:00',
    'granularity': 'day'
}

timestamp = int(time.time())
resource = '/statistics/bandwidth/{0}'.format(customerNumber)
hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}/{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
    response = requests.get(fullUrl, params=query_parameters)
    print response.text
except requests.exceptions.RequestException as e:
    print e

Response Body

{
    "_metadata": {
        "from": "2016-04-01T00:00:00+00:00",
        "to": "2016-04-03T00:00:00+00:00",
        "customerNumber": "0123456789",
        "cname": "leasewebcdn.com",
        "alias": "my.leasewebcdn.com",
        "granularity": "day"
    },
    "metrics": {
        "bps": {
            "unit": "bps",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        },
        "sslBps": {
            "unit": "bps",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        }
    }
}

GET /statistics/bandwidth/{customer_number}

Retrieve bandwidth related statistics. This includes served bps and SSL bps. The bps is calculated by averaging the served bits over time. The response can be filtered using the following query string parameters;

Query string parameters

Name Type Required Default Description
start date yes n/a Any date string accepted by dateutil.parser.parse to determine the start date of the statistics request, we recommend using a UNIX timestamp or RFC-3339.
end date yes n/a Any date string accepted by dateutil.parser.parse to determine the end date of the statistics request, we recommend using a UNIX timestamp or RFC-3339.
fields string no n/a* Comma separated fields to filter on specific metrics. Must be one or a multiple selection of bps or sslBps. Returns all available fields by default.
pop string no all The pop or region filter e.g.: us, eu, asia, ams1, fra1 or wdc1. Available regions and pops at /information/pops.
cname string no all The cname of a zone, can not be used in combination with the alias parameter.
alias string no all The alias of a zone, can not be used in combination with the cname parameter.
granularity enum no 5min The granularity of data grouping. Choose from: 5min, hour, day, month or year.

Live Bandwidth

The live bandwidth figure for your account is calculated based on 5 minutes of data, rounded to the previous 5 minute mark. Data that is newer than 5 minutes is still being processed by our platform, and thus giving different increasing values on every request.

To calculate the live bandwidth on your account, and retrieve it using this API call, you do the following:

You then send in a start time of 15:35 and an end time of 15:40. Any values after 15:40 up to the current time (15:48) are not counted.

Cache Performance

curl -X GET "https://api.leasewebcdn.com/statistics/cache/1234567890/1462203335/4a69f766bc48b1ed3d025339313196c388de8da5?start=2016-04-01T00:00:00+00:00&end=2016-05-01T00:00:00+00:00&granularity=month"
<?php
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$customerNumber = '1234567890';
$query_parameters = array(
    'start' => '2016-04-01T00:00:00+00:00',
    'end' => '2016-05-01T00:00:00+00:00',
    'granularity' => 'month',
);

$timestamp = time();
$resource = '/statistics/cache/' . $customerNumber;
$hashedSignature = sha1($apiKey . $timestamp . $resource);
$fullUrl = sprintf('%s/%s/%s/%s?%s', $apiUrl, $resource, $timestamp, $hashedSignature, http_build_query($query_parameters));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'

customerNumber = '1234567890'
query_parameters = {
    'start': '2016-04-01T00:00:00+00:00',
    'end': '2016-05-01T00:00:00+00:00',
    'granularity': 'day'
}

timestamp = int(time.time())
resource = '/statistics/cache/{0}'.format(customerNumber)
hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}/{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
    response = requests.get(fullUrl, params=query_parameters)
    print response.text
except requests.exceptions.RequestException as e:
    print e

Response Body

{
    "_metadata": {
        "from": "2016-04-01T00:00:00+00:00",
        "to": "2016-04-03T00:00:00+00:00",
        "customerNumber": "0123456789",
        "cname": "leasewebcdn.com",
        "alias": "my.leasewebcdn.com",
        "granularity": "day"
    },
    "metrics": {
        "cacheHits": {
            "unit": "hit",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        },
        "cacheBytes": {
            "unit": "byte",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        },
        "edgeHits": {
            "unit": "hit",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        },
        "edgeBytes": {
            "unit": "byte",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        },
        "originHits": {
            "unit": "hit",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        },
        "originBytes": {
            "unit": "byte",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        }
    }
}

GET /statistics/cache/{customer_number}

Retrieve cache performance related statistics. This includes served bytes and hits for Cache, Edge and Origin. The response can be filtered using the following query string parameters;

Query string parameters

Name Type Required Default Description
start date yes n/a Any date string accepted by dateutil.parser.parse to determine the start date of the statistics request, we recommend using a UNIX timestamp or RFC-3339.
end date yes n/a Any date string accepted by dateutil.parser.parse to determine the end date of the statistics request, we recommend using a UNIX timestamp or RFC-3339.
fields string no n/a* Comma separated fields to filter on specific metrics. Must be one or a multiple selection of cacheHits, cacheBytes, edgeHits, edgeBytes, originHits or originBytes. Returns all available fields by default.
pop string no all The pop or region filter e.g.: us, eu, asia, ams1, fra1 or wdc1. Available regions and pops at /information/pops.
cname string no all The cname of a zone, can not be used in combination with the alias parameter.
alias string no all The alias of a zone, can not be used in combination with the cname parameter.
granularity enum no 5min The granularity of data grouping. Choose from: 5min, hour, day, month or year.

Geographical

curl -X GET "https://api.leasewebcdn.com/statistics/geo/1234567890/1462203335/4a69f766bc48b1ed3d025339313196c388de8da5?start=2016-04-01T00:00:00+00:00&end=2016-05-01T00:00:00+00:00&granularity=month"
<?php
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$customerNumber = '1234567890';
$query_parameters = array(
    'start' => '2016-04-01T00:00:00+00:00',
    'end' => '2016-05-01T00:00:00+00:00',
    'granularity' => 'month',
);

$timestamp = time();
$resource = '/statistics/geo/' . $customerNumber;
$hashedSignature = sha1($apiKey . $timestamp . $resource);
$fullUrl = sprintf('%s/%s/%s/%s?%s', $apiUrl, $resource, $timestamp, $hashedSignature, http_build_query($query_parameters));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'

customerNumber = '1234567890'
query_parameters = {
    'start': '2016-04-01T00:00:00+00:00',
    'end': '2016-05-01T00:00:00+00:00',
    'granularity': 'day'
}

timestamp = int(time.time())
resource = '/statistics/geo/{0}'.format(customerNumber)
hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}/{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
    response = requests.get(fullUrl, params=query_parameters)
    print response.text
except requests.exceptions.RequestException as e:
    print e

Response Body

{
    "_metadata": {
        "from": "2016-04-01T00:00:00+00:00",
        "to": "2016-04-03T00:00:00+00:00",
        "customerNumber": "0123456789",
        "cname": "leasewebcdn.com",
        "alias": "my.leasewebcdn.com",
        "granularity": "day"
    },
    "metrics": {
        "hits": {
            "unit": "hit",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1,
                    "country": "NL"
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 2,
                    "country": "NL"
                },
                {
                    "timestamp": "2016-04-03T00:00:00+00:00",
                    "value": 3,
                    "country": "NL"
                },
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1,
                    "country": "US"
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 2,
                    "country": "US"
                },
                {
                    "timestamp": "2016-04-03T00:00:00+00:00",
                    "value": 3,
                    "country": "US"
                }
            ]
        }
    }
}

GET /statistics/geo/{customer_number}

Retrieve geographical related statistics. This includes hits served per country. The response can be filtered using the following query string parameters;

Query string parameters

Name Type Required Default Description
start date yes n/a Any date string accepted by dateutil.parser.parse to determine the start date of the statistics request, we recommend using a UNIX timestamp or RFC-3339.
end date yes n/a Any date string accepted by dateutil.parser.parse to determine the end date of the statistics request, we recommend using a UNIX timestamp or RFC-3339.
pop string no all The pop or region filter e.g.: us, eu, asia, ams1, fra1 or wdc1. Available regions and pops at /information/pops.
cname string no all The cname of a zone, can not be used in combination with the alias parameter.
alias string no all The alias of a zone, can not be used in combination with the cname parameter.
granularity enum no 5min The granularity of data grouping. Choose from: day, month or year.

Traffic

curl -X GET "https://api.leasewebcdn.com/statistics/traffic/1234567890/1462203335/4a69f766bc48b1ed3d025339313196c388de8da5?start=2016-04-01T00:00:00+00:00&end=2016-05-01T00:00:00+00:00&granularity=day"
<?php
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$customerNumber = '1234567890';
$query_parameters = array(
    'start' => '2016-04-01T00:00:00+00:00',
    'end' => '2016-05-01T00:00:00+00:00',
    'granularity' => 'day',
);

$timestamp = time();
$resource = '/statistics/traffic/' . $customerNumber;
$hashedSignature = sha1($apiKey . $timestamp . $resource);
$fullUrl = sprintf('%s/%s/%s/%s?%s', $apiUrl, $resource, $timestamp, $hashedSignature, http_build_query($query_parameters));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'

customerNumber = '1234567890'
query_parameters = {
    'start': '2016-04-01T00:00:00+00:00',
    'end': '2016-05-01T00:00:00+00:00',
    'granularity': 'day'
}

timestamp = int(time.time())
resource = '/statistics/traffic/{0}'.format(customerNumber)
hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}/{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
    response = requests.get(fullUrl, params=query_parameters)
    print response.text
except requests.exceptions.RequestException as e:
    print e

Response Body

{
    "_metadata": {
        "from": "2016-04-01T00:00:00+00:00",
        "to": "2016-04-03T00:00:00+00:00",
        "customerNumber": "0123456789",
        "cname": "leasewebcdn.com",
        "alias": "my.leasewebcdn.com",
        "granularity": "day"
    },
    "metrics": {
        "sslHits": {
            "unit": "hit",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        },
        "sslBytes": {
            "unit": "byte",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        },
        "hits": {
            "unit": "hit",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        },
        "bytes": {
            "unit": "byte",
            "values": [
                {
                    "timestamp": "2016-04-01T00:00:00+00:00",
                    "value": 1
                },
                {
                    "timestamp": "2016-04-02T00:00:00+00:00",
                    "value": 1
                }
            ]
        }
    }
}

GET /statistics/traffic/{customer_number}

Retrieve traffic related statistics. This includes served bytes, SSL bytes, hits and SSL Hits. The response can be filtered using the following query string parameters;

Query string parameters

Name Type Required Default Description
start date yes n/a Any date string accepted by dateutil.parser.parse to determine the start date of the statistics request, we recommend using a UNIX timestamp or RFC-3339.
end date yes n/a Any date string accepted by dateutil.parser.parse to determine the end date of the statistics request, we recommend using a UNIX timestamp or RFC-3339.
fields string no n/a* Comma separated fields to filter on specific metrics. Must be one or a multiple selection of sslHits, sslBytes, hits or bytes. Returns all available fields by default.
pop string no all The pop or region filter e.g.: us, eu, asia, ams1, fra1 or wdc1. Available regions and pops at /information/pops.
cname string no all The cname of a zone, can not be used in combination with the alias parameter.
alias string no all The alias of a zone, can not be used in combination with the cname parameter.
granularity enum no 5min The granularity of data grouping. Choose from: 5min, hour, day, month or year.

Version

Retrieve the current API Version

curl -X GET "https://api.leasewebcdn.com/version"
<?php

$resource = '/version';
$apiUrl   = 'https://api.leasewebcdn.com';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl . $resource);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import requests

resource = '/version'
apiUrl = 'https://api.leasewebcdn.com'

fullUrl = '{0}{1}'.format(apiUrl, resource)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "version":"1.10.0"
}

To retrieve the current API version, send a GET request to /version.

The response will be a JSON object with key version containing the api version

Name Type Description
version string The current version of the API

Push and Pull zones

Retrieve a Pull Zone

curl -X GET "https://api.leasewebcdn.com/zones/pull/1234567890/123/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/zones/pull/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$zoneID = '123';

$resource = sprintf($resource, $customerNumber, $zoneID);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
zoneID = '123'

resource = '/zones/pull/{0}/{1}'.format(customerNumber,zoneID)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "total":1,"success":
  [
    {
      "origin":"http:\/\/thumbs.leaseweb.com",
      "nginx_config_version":"100",
      "origin_id":616,
      "cdn_cluster":"hwc002a",
      "whitelist":"",
      "updated_at":1418162487,
      "ignore_cache_control":0,
      "max_filesize":"40m",
      "use_stale":0,
      "secure_manifest_only":0,
      "id":1,
      "global_secret":"",
      "basic_auth_user":"",
      "alias":"",
      "origin_label":"http:\/\/thumbs.leaseweb.com",
      "secure_url_active":0,
      "blocked_countries":"",
      "headers_add":"",
      "secure_url_ip":0,
      "ssl_enabled":0,
      "ssl_private_key":"",
      "ssl_certificate":"",
      "ssl_ca_bundle":"",
      "headers_origin":"",
      "template":null,
      "push_zone_id":null,
      "customer_id":1,
      "content_disposition":0,
      "cdn_domain":"",
      "burst_size":null,
      "gzip":1,
      "refresh_every":86400,
      "expires":"off",
      "https_redirect": "disabled",
      "query_string_mode":"full",
      "query_string_fields":"var1,var2",
      "active":1,
      "strip_cookies":1,
      "basic_auth_password":"",
      "referrer":"",
      "created_at":1418162487,
      "transfer_rate":null,
      "headers":"",
      "cname":"img.lw.cdn.leaseweb.com",
      "headers_remove":"",
      "zone_type":"vod",
      "origin_urlencoding":0,
      "dvr":0,
      "cold_hit_seeking":1
    }
  ]
}

To retrieve a pull zone for the given data, send a GET request to /zones/pull/{customer_number}/{zone_id}.

The response will be a JSON object with the key success that contains the statistics.

Name Type Description
origin string The URL (HTTP) of the source, on domain level
origin_s3_bucket_name string The name of the origin S3 bucket (if origin type is S3) or empty string otherwise
origin_type string Type of source origin: “simple” or “s3”
expires_404 integer The amount of time (in seconds) the 404 reply from the origin server is kept in cache
nginx_config_version string The config version of NGINX
origin_id integer The zone ID
sub_path string The sub path of the origin
secure_url_mode string Describes which mode is active (Simple, Advanced or disabled)
expires string The amount of time (in seconds) an URL will be held in the CDN’s cache
https_redirect string Redirects http traffic to https. Can either be disabled, temporary or permanent
ssl_enabled integer Specifies whether the SSL support is enabled (1) or disabled (0)
ssl_private_key string PEM-encoded private key of the domain
ssl_certificate string PEM-encoded certificate (or multiple certificates concatenated together) of the domain
ssl_ca_bundle string Optional PEM-encoded certificate authority (CA) bundle, empty string if it’s not present
updated_at integer Timestamp (UTC) when the zone was last updated
ignore_cache_control integer Ignore Origin Cache Control values set by the Origin and use the CDN values. (0 = Inactive, 1 = Active)
gzip integer Reduces the size of web content and improves the overall speed (0 = Inactive, 1 = Active)
whitelist string IPs or subnets added to the whitelist will always be allowed to access your content
aes_key string 64 character long string that is used to generate the secure link in encrypted mode
whitelisted_files string A list of files that are available even if secure_url_mode is enabled
active integer If the zone is active. (0 = Inactive, 1 = Active)
burst_size integer The initial data that can be downloaded at full speed before the specified transfer rate takes effect
sha_key string 64 character long string that is used to generate the secure link in encrypted mode
id integer The ID assigned to the Pull Zone
global_secret string A password used to generate the Secure URL
referrer string HTTP referral restrictions
referrer_check string The checking can be either on or off
vary_header integer If the vary header is enabled in the NGINX config. (0 = Inactive, 1 = Active)
query_string_mode string Either set to ‘off’, 'partial’ or 'full’ to define how the query string is used for the cache key
query_string_fields string Comma seperated fields to use when query_string_mode is set to partial
transfer_rate integer The bandwidth limit per connection in Kbps
alias string Aliases set for the CNAME
cname string Canonical Name for the Zone
origin_label string The label used for the Origin
zone_type string The type of the Pull Zone
headers_origin string The headers that are passed through from the Origin
created_at integer Timestamp (UTC) when the zone was created
refresh_every integer Refresh time for the zone
cold_hit_seeking integer Allows video files, when using a start parameter, to be partially fetched from the origin. Once the entire video has been transferred, it will then cache the file

Create a Pull Zone

curl -X POST -d '{"active":"1","cname":"pull","origin":"http://pull.example.com"}' "https://api.leasewebcdn.com/zones/pull/1234567890/123/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/zones/pull/%s/new';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$zoneID = '123';

$resource = sprintf($resource, $customerNumber, $zoneID);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$data = array(
  "active" => 1,
  "cname" => 'pull',
  "origin" => "http://pull.example.com"
  );

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'

resource = '/zones/pull/{0}/new'.format(customerNumber)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)
data = {'active': 1,'cname': 'pull','origin':'http://pull.example.com'}

try:
  response = requests.post(fullUrl, data=data)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "success":"Rule Created!",
  "id": 1
}

To create an new pull zone, send a POST request to /zones/pull/{customer_number}/new.

The response will be a JSON object with the key success that contains the new origin.

Name Type Description
success string Contains a string that notifies if the zone was successfully created
id integer The id of the created zone

Delete a Pull Zone

curl -X DELETE "https://api.leasewebcdn.com/zones/pull/1234567890/123/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/zones/pull/%s/%s/';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$zoneID = '123';

$resource = sprintf($resource, $customerNumber, $zoneID);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
zoneID = '123'

resource = '/zones/pull/{0}/{1}'.format(customerNumber,zoneID)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.delete(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
    "success": "Rule deleted!"
}

To delete a pull zone for the given data, send a DELETE request to /zones/pull/{customer_number}/{zone_id}.

The response will be a JSON object with the key success.

Name Type Description
success string Rule deleted!

Retrieve a Push Zone

curl -X GET "https://api.leasewebcdn.com/zones/push/1234567890/123/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/zones/push/%s/%s/';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$zoneID = '123';

$resource = sprintf($resource, $customerNumber, $zoneID);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
zoneID = '123'

resource = '/zones/push/{0}/{1}'.format(customerNumber,zoneID)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.get(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
  "total":2,
  "success":
  [
    {
      "ftp_user":"1",
      "name":"ftp_logs",
      "quota_limit":1000000000,
      "created_at":1397660535,
      "quota_use":0,
      "active":1,
      "customer_id":1,
      "id":1
    },
    {
      "ftp_user":"2",
      "name":"ftp_test",
      "quota_limit":9990000,
      "created_at":1397829690,
      "quota_use":0,
      "active":1,
      "customer_id":1,
      "id":2
    }
  ]
}

To retrieve a pull zone for the given data, send a GET request to /zones/pull/{customer_number}/{zone_id}.

The response will be a JSON object with the key success that contains the statistics.

Name Type Description
ftp_user string The ftp username
name string The name of the push zone
quota_limit integer The quota limit
quota_use integer The amount of quota used
cdn_cluster string The cluster on the LeaseWeb CDN where the Push Zone is configured
full_cname string The full CNAME
active integer If the zone is active. (0 = Inactive, 1 = Active)
created_at integer Timestamp (UTC) when the zone was created
id integer The zone id

Create a Push Zone

curl -X POST -d '{"active":"1","name":"push","quota_limit":"1000000"}' "https://api.leasewebcdn.com/zones/push/1234567890/123/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/zones/push/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$zoneID = '123';

$resource = sprintf($resource, $customerNumber, $zoneID);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$data = array(
  "active" => 1,
  "name" => 'push',
  "quota_limit" => 1000000
  );

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
zoneID = '123'

resource = '/zones/push/{0}/{1}'.format(customerNumber, zoneID)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)
data = {'active': 1,'name': 'push','quota_limit': 1000000}

try:
  response = requests.post(fullUrl, data=data)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
    "id":239,
    "username": 1234567890,
    "password": "AbCdEF!@#$%"
}

To update a push zone, send a POST request to /zones/push/{customer_number}.

The response will be a JSON object with the key success that contains the push zone data.

Name Type Description
username string The username for the FTP
id integer The id of the push zone

Delete a Push Zone

curl -X DELETE "https://api.leasewebcdn.com/zones/push/1234567890/123/1440593540/4a69f766bc48b1ed3d025339313196c388de8da5"
<?php

$resource = '/zones/push/%s/%s';
$apiUrl   = 'https://api.leasewebcdn.com';
$apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2';

$timestamp = time();
$customerNumber = '1234567890';
$zoneID = '123';

$resource = sprintf($resource, $customerNumber, $zoneID);

$hashedSignature = sha1($apiKey . $timestamp . $resource);

$fullUrl = '%s%s/%s/%s';
$fullUrl = sprintf($fullUrl, $apiUrl, $resource, $timestamp, $hashedSignature);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);

echo $output;
import time
import requests
import hashlib

apiUrl = 'https://api.leasewebcdn.com'
apiKey = '97eff4af4ba4f1ca772a64f87fc1b50cc43d5ed2'
timestamp = int(time.time())

customerNumber = '1234567890'
zoneID = '123'

resource = '/zones/push/{0}/{1}'.format(customerNumber,zoneID)

hashedSignature = hashlib.sha1(apiKey + str(timestamp) + resource).hexdigest()
fullUrl = '{0}{1}/{2}/{3}'.format(apiUrl, resource, timestamp, hashedSignature)

try:
  response = requests.delete(fullUrl)
  print 'Response: {0}:{1}'.format(response.status_code, response.text)
except requests.exceptions.RequestException as e:
  print e

Response Body

{
    "success": "Rule deleted!"
}

To delete a push zone for the given data, send a DELETE request to /zones/push/{customer_number}/{zone_id}.

The response will be a JSON object with the key success.

Name Type Description
success string Rule deleted!