> For the complete documentation index, see [llms.txt](https://docs.link11.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.link11.com/using-link11/api/secure-cdn.md).

# Secure CDN

The Link11 Secure CDN API is used to perform common configuration tasks remotely.&#x20;

{% hint style="info" %}
The information below assumes you have already the [Introduction to the Link11 API](/using-link11/api/introduction.md).
{% endhint %}

## Service Key definition

`apikey=l11cdn`

## Domain Key definition <a href="#id-customerapi-webddos-webddoscommands" id="id-customerapi-webddos-webddoscommands"></a>

For the commands that include a Domain Key (referred to below as $DOMAINKEY), here is how to obtain this value:

* In WebGUI, navigate to the Secure CDN section
* Go to the Instances page
* Find the instance that is your desired target for the API command. Extract the first part of its Backend CNAME; this is the Domain Key. (Example: if the Backend CNAME is `foo.l11cdn.net`, the $DOMAINKEY API parameter is `foo`.)&#x20;

{% hint style="info" %}
Note: while other Link11 services specify this parameter as `&domainkey=`, for Secure CDN it is specified via`&domain=`.
{% endhint %}

## Password definition <a href="#id-customerapi-webddos-webddoscommands" id="id-customerapi-webddos-webddoscommands"></a>

The Secure CDN API includes a `password` parameter. (referred to below as $PASSWORD). This is obtained/defined as follows:

* In WebGUI, navigate to Secure CDN / Instances
* Find the instance that is your desired target for the API command, and select its "Edit" button
* The "Edit Secure CDN Instance" page will be displayed. At the bottom, find the [API Password](/product-guides/secure-cdn/interface/instances.md#api-password) field.

## Whitelisting IPs for API access <a href="#id-customerapi-webddos-webddoscommands" id="id-customerapi-webddos-webddoscommands"></a>

API access is limited to whitelisted IP addresses. To allow a range of IPs to submit API commands:

* Navigate to the "Edit Secure CDN Instance" page, as described above
* Enter the IP(s) in the [API IP ACL Limits](/product-guides/secure-cdn/interface/instances.md#api-ip-acl-limits).

***

## API Commands <a href="#id-customerapi-cloudinsights-routeannouncement" id="id-customerapi-cloudinsights-routeannouncement"></a>

### **Get Statistics**

Retrieves statistics for a CDN Node.

`https://api.link11.de/?apikey=l11cdn&domain=[$DOMAINKEY]&password=[$PASSWORD]&get-stats&from=[Unix-timestamp]&to=[Unix-timestamp]&aggregate=[timeframe]&type=clientbytes`

| Parameter | Description                                                                                                                                                                                                                                                                                                                                               |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| from      | Unix timestamp in UTC, determining the start time/date of the query                                                                                                                                                                                                                                                                                       |
| to        | Unix timestamp in UTC, determining the end time/date of the query                                                                                                                                                                                                                                                                                         |
| aggregate | The "bucket" size for the returned records in seconds. Example: To return data in one-hour buckets, set the value to 3600 (seconds in an hour).                                                                                                                                                                                                           |
| type      | <p><code>clientbytes</code></p><ul><li>returns statistics between the requestor (client) and the Link11 proxies</li></ul><p><code>serverbytes</code></p><ul><li>returns statistics between the Link11 proxies and the customer origin</li></ul><p><code>total</code></p><ul><li>returns the combined statistics for clientbytes and serverbytes</li></ul> |

### **Get Node IP4s**

Get list of Link11 CDN nodes (IPv4) which are used as source IPs to access the origin servers

`https://api.link11.de/?apikey=l11cdn&domain=[$DOMAINKEY]&password=[$PASSWORD]&cmd=get_node_ip4s`

or for JSON Format

`https://api.link11.de/?apikey=l11cdn&domain=[$DOMAINKEY]&password=[$PASSWORD]&cmd=get_node_ip4s&format=json`

**Response:**

```
HTTP/1.1 200 OK 
Server: nginx/1.12.2 
Date: Sun, 01 Oct 2017 09:11:42 GMT 
Content-Type: text/html; charset=UTF-8 

200 5 results 

A1.b1.c1.d1 
A2.b2.c2.d2 
A3.b3.c3.d3 
A4.b4.c4.d4 
A5.b5.c5.d5
```

Or in the JSON Format

```
["A1.b1.c1.d1","A2.b2.c2.d2","A3.b3.c3.d3","A4.b4.c4.d4","A5.b5.c5.d5"]
```

### **Get Node IP6s**

Get list of Link11 CDN nodes (IPv6) which are used as source IPs to access the origin servers

`https://api.link11.de/?apikey=l11cdn&domain=[$DOMAINKEY]&password=[$PASSWORD]&cmd=get_node_ip6s`

or for JSON Format

`https://api.link11.de/?apikey=l11cdn&domain=[$DOMAINKEY]&password=[$PASSWORD]&cmd=get_node_ip6s&format=json`

**Response:**

```
$ curl -i 'https://api.link11.de/?apikey=l11cdn&domain=********&password=********************************&cmd=get_node_ip6s' 
HTTP/1.1 200 OK 
Server: nginx/1.12.2 
Date: Sun, 01 Oct 2017 09:11:42 GMT 
Content-Type: text/html; charset=UTF-8 

200 4 results 

Xxxx1:aa1:28:6::10 
Xxxx2:aa2:28:6::10 
Xxxx3:aa2:28:6::10 
Xxxx4:aa3:28:6::10
```

Or in the JSON Format:

```
["Xxxx1:aa1:28:6::10“,"Xxxx2:aa2:28:6::10“,"Xxxx3:aa2:28:6::10“,"Xxxx4:aa3:28:6::10“]
```

### **Purge Cache**

Purges cached objects from all CDN Nodes under a certain path

`https://api.link11.de/?apikey=l11cdn&domain=[$DOMAINKEY]&password=[$PASSWORD]&cmd=cachepurge&path=[$PATH]`

| Parameter | Example                                              | Explanation                                                                                 |
| --------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| path      | <https://www.domain.com/images/example.jpg>          | Exact URL that will be purged                                                               |
| folder    | <https://www.domain.com/images/>                     | 'URL starts with': all locations under that URL will be purged                              |
| regex     | https\\:\\/\\/www\\.domain\\.com\\/images\\/\*\\.jpg | Pattern matching (Perl compatible Regex), all locations matching the pattern will be purged |

**Response:**

```
HTTP/1.1 200 OK 
Server: nginx/1.12.2 
Date: Sun, 01 Oct 2017 09:11:42 GMT 
Content-Type: text/html; charset=UTF-8 

200 Purging in progress
```

### Get Logs

Retrieves access and/or error log information for CDN instance locations.

{% hint style="info" %}
This API command is available to customers who have purchased the Access Logs feature. If the command is used without that purchase having been made, a 403 error will be returned.
{% endhint %}

`https://api.link11.de/?apikey=l11cdn&domain=[$DOMAINKEY]&password=[$PASSWORD]&cmd=get_log&locationuid=abcdefg,123456&type=error&format=csv&from=[Unix-timestamp]&to=[Unix-timestamp]`

| Parameter   | Explanation                                                                                                                                                                                                              |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| from        | Unix timestamp in UTC, determining the start time/date of the query                                                                                                                                                      |
| to          | Unix timestamp in UTC, determining the end time/date of the query                                                                                                                                                        |
| format      | `csv` or `json`                                                                                                                                                                                                          |
| type        | `error` or `access`                                                                                                                                                                                                      |
| locationuid | An optional parameter. Including one or more comma-separated location UIDs will return filtered logs limited to only the selected location(s). Omitting this parameter will return logs for all locations in the domain. |

#### Example response

```
┌────────────────date─┬─uid──────┬─ip────────────────────┬─line───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ 2022-11-01 11:30:46 │ ece4b2e2 │ ::ffff:85.131.131.132 │ 2022/11/01 11:30:46 [info] 670058#670058: *4388569 client 2003:da:f717:c001:d430:a233:3f26:f350 closed keepalive connection                                                                                                                                │
│ 2022-11-01 11:30:46 │ c8bef791 │ ::ffff:85.131.131.133 │ 2022/11/01 11:30:46 [info] 666713#666713: *7431834 peer closed connection in SSL handshake while SSL handshaking, client: 2001:9e8:22ad:9c00:7cdc:6440:91d4:e98e, server: [::]:443                                                                         │
│ 2022-11-01 11:30:46 │ ddd67f2e │ ::ffff:37.252.225.17  │ 2022/11/01 11:30:46 [info] 824048#824048: *457069 client canceled stream 3 while connecting to upstream, client: 154.28.112.195, server: media.exampleshop.de, request: "GET /eBayArticle/10015719_Carhartt_Herren_Buffalo_Cap_musk_green_01.jpg HTTP/2.0", upstream: "https://128.12.8.1:443/eBayArticle/10015719_Carhartt_Herren_Buffalo_Cap_musk_green_01.jpg", host: "media.exampleshop.de", referrer: "https://www.ebay.fr/itm/303948559614?hash=item46c4bef4fe:g:oXEAAOSw2XZh3lRv&amdata=enc:AQAHAAAAoNWfqoqt+gHeWkEfmrsyf/4JBFpxwP7Bz+t/k38IlsxpwSc9ALF2H42XwpX/CzEWt+n8ChfCbtSHZANi1Ldm9NRtyIxPSfnb4F11a1y09axFN1VS54JD6LNnO81Fj+Qyusy3h68BbWjpFioUdoktGE4hLc4Rm/kuLu+mA/k6fkmm6hKECz8Lkd7Jq2twfJnCzl1oM3+UxpE6riKpvV1c6ig=%7Ctkp:Bk9SR7qym8zhYA" │
│ 2022-11-01 11:30:46 │ ddd67f2e │ ::ffff:37.252.225.17  │ 2022/11/01 11:30:46 [info] 824048#824048: *457069 client canceled stream 5 while connecting to upstream, client: 154.28.112.195, server: media.exampleshop.de, request: "GET /eBayArticle/10015719_Carhartt_Herren_Buffalo_Cap_scout_blue_02.jpg HTTP/2.0", upstream: "https://128.12.8.1:443/eBayArticle/10015719_Carhartt_Herren_Buffalo_Cap_scout_blue_02.jpg", host: "media.exampleshop.de", referrer: "https://www.ebay.fr/itm/303948559614?hash=item46c4bef4fe:g:oXEAAOSw2XZh3lRv&amdata=enc:AQAHAAAAoNWfqoqt+gHeWkEfmrsyf/4JBFpxwP7Bz+t/k38IlsxpwSc9ALF2H42XwpX/CzEWt+n8ChfCbtSHZANi1Ldm9NRtyIxPSfnb4F11a1y09axFN1VS54JD6LNnO81Fj+Qyusy3h68BbWjpFioUdoktGE4hLc4Rm/kuLu+mA/k6fkmm6hKECz8Lkd7Jq2twfJnCzl1oM3+UxpE6riKpvV1c6ig=%7Ctkp:Bk9SR7qym8zhYA" │
│ 2022-11-01 11:30:46 │ ddd67f2e │ ::ffff:37.252.225.17  │ 2022/11/01 11:30:46 [info] 824048#824048: *457069 client canceled stream 23 while connecting to upstream, client: 154.28.112.195, server: media.exampleshop.de, request: "GET /eBayArticle/10015719_Carhartt_Herren_Buffalo_Cap_blue_spruce.jpg HTTP/2.0", upstream: "https://128.12.8.1:443/eBayArticle/10015719_Carhartt_Herren_Buffalo_Cap_blue_spruce.jpg", host: "media.exampleshop.de", referrer: "https://www.ebay.fr/itm/303948559614?hash=item46c4bef4fe:g:oXEAAOSw2XZh3lRv&amdata=enc:AQAHAAAAoNWfqoqt+gHeWkEfmrsyf/4JBFpxwP7Bz+t/k38IlsxpwSc9ALF2H42XwpX/CzEWt+n8ChfCbtSHZANi1Ldm9NRtyIxPSfnb4F11a1y09axFN1VS54JD6LNnO81Fj+Qyusy3h68BbWjpFioUdoktGE4hLc4Rm/kuLu+mA/k6fkmm6hKECz8Lkd7Jq2twfJnCzl1oM3+UxpE6riKpvV1c6ig=%7Ctkp:Bk9SR7qym8zhYA" │
```
