Zones
A zone is one origin with its hostnames and its settings. Five calls create, read, update and delete zones, and every setting a zone has is a field on the same object.
The zone object#
| Field | Type | Meaning |
|---|---|---|
| ID | String | The zone id: nine upper-case letters and digits. Never changes |
| ZONE_NAME | String | The name, lower case. It is also the default hostname, {ZONE_NAME}.zone.cg-cdn.com. Set on create, never changed |
| ORIGIN_URL | String | Scheme, hostname or IP address, optional port, optional path; no query string and no credentials. The bucket endpoint on an S3 zone, the web server on a SITE zone; empty on a TUNNEL zone |
| HOST_HEADER | String | The Host header sent to the origin; empty means the hostname from ORIGIN_URL. Not used while ADD_HOST_HEADER is 1, nor on S3 |
| ORIGIN_CERTIFICATE | Integer | 1 when the zone has an origin certificate, 0 when not. Read only: the certificate has its own endpoint, Origin certificates |
| VERIFY_ORIGIN_SSL | Integer | 1 to check the origin's certificate. Starts 0 |
| ADD_HOST_HEADER | Integer | 1 to send each viewer's hostname as Host and cache each hostname separately. Starts 0; a SITE zone starts 1. Not used on S3 |
| FOLLOW_REDIRECTS | Integer | 1 to follow the origin's redirects at the edge. Starts 0. Not used on S3 or SITE |
| STRIP_COOKIES | Integer | 1 to remove Set-Cookie from responses and drop viewers' cookies before the origin. Starts 1; a SITE zone starts 0 |
| BLOCK_ROOT | Integer | 1 to answer directory paths with 403. Starts 0 |
| BLOCK_POST | Integer | 1 to answer POST with 403. Starts 0 |
| ADD_CANONICAL_HEADER | Integer | 1 to add a canonical Link header naming the file at the origin. Starts 1; a SITE zone starts 0. Not used on S3 or SITE |
| ADD_CORS_HEADER | Integer | 1 to add CORS headers on stylesheets and fonts. Starts 1 |
| CACHE_EXP | String | Cache Expiration Time in seconds, returned as a string: "-1" respects the origin, "0" caches nothing, or one of the fixed values below. Starts "-1" |
| HOME_POP | String | The origin shield setting: a location id, auto to have the location nearest your origin measured and chosen for you (Auto Detect), or empty for off. See Locations and Origin shield. Empty and not used on a TUNNEL zone, where every location fetches through the location the connector is connected to |
| HOME_POP_LOCATION | String | The location the shield uses now: the one Auto Detect has chosen so far (empty until its first choice, within about ten minutes of switching it on), or the one HOME_POP names. Read only |
| STATUS | String | ACTIVE, or PAUSED while CacheGenie has paused the zone under the Acceptable Use Policy: it stays listed and readable here, and every request to it is refused until it is resumed |
| ORIGIN_TYPE | String | STANDARD, S3, SITE or TUNNEL |
| S3_BUCKET, S3_REGION, S3_ACCESS_KEY | String | The bucket details on an S3 zone; empty otherwise |
| S3_ADDRESSING | String | PATH or VHOST |
| S3_SECRET_KEY_SET | Integer | 1 when a secret key is stored. The secret itself is never returned |
| TUNNEL_ENDPOINT | Integer | On a TUNNEL zone, the ENDPOINT_ID of the tunnel endpoint it fetches from (see Tunnels); 0 on any other type |
| TUNNEL_MODE | String | How a TUNNEL zone is delivered: SITE, a whole website, or STANDARD, static files. Kept while the zone is another type |
| TUNNEL_TARGET | String | Where the endpoint points, such as https://192.168.1.5:443; empty on any other type. Read only |
| TOKEN_AUTH | Integer | 1 to serve only signed links. The key is on its own endpoint: see Signing keys |
| MAINTENANCE | Integer | 1 to answer the zone's requests with the maintenance page. See Maintenance mode |
| USAGE_PAUSED | Integer | 1 while every zone on the account is paused because its free usage is used and it has no card (see Free usage and pausing). Read only |
| BLOCK_IPS, ALLOW_IPS | String | Addresses and CIDR ranges, one per line |
| COUNTRIES | String | Two-letter country codes, comma separated, upper case |
| COUNTRY_MODE | String | BLOCK to refuse the countries listed, ALLOW to serve only them |
| BLOCK_ASNS | String | AS numbers, comma separated, without the AS |
| BLOCK_TOR, BLOCK_VPN, BLOCK_HOSTING | Integer | 1 to refuse that kind of network |
| TIMESTAMP | Integer | When the zone was created, Unix seconds |
What each setting does at the edge is in Zone settings; the blocking fields are explained in Blocking visitors.
List zones#
https://api.cachegenie.com/v1/cdnEvery zone on the account, newest first, as DATA.CDN_ZONES: a paused zone is listed with the rest, and a deleted one is not.
curl https://api.cachegenie.com/v1/cdn \
-H "Authorization: Bearer YOUR_API_KEY"{
"CODE": 200,
"MESSAGE": "Data returned for all CDN Zones for this account.",
"DATA": {
"CDN_ZONES": [
{
"ID": "AB12CD34E",
"ZONE_NAME": "video",
"ORIGIN_URL": "https://origin.example.com",
"HOST_HEADER": "",
"ORIGIN_CERTIFICATE": 0,
"VERIFY_ORIGIN_SSL": 1,
"ADD_HOST_HEADER": 0,
"FOLLOW_REDIRECTS": 0,
"STRIP_COOKIES": 1,
"BLOCK_ROOT": 0,
"BLOCK_POST": 0,
"ADD_CANONICAL_HEADER": 1,
"ADD_CORS_HEADER": 1,
"CACHE_EXP": "-1",
"HOME_POP": "alpha1",
"HOME_POP_LOCATION": "alpha1",
"STATUS": "ACTIVE",
"ORIGIN_TYPE": "STANDARD",
"S3_BUCKET": "",
"S3_REGION": "",
"S3_ADDRESSING": "PATH",
"S3_ACCESS_KEY": "",
"S3_SECRET_KEY_SET": 0,
"TOKEN_AUTH": 0,
"MAINTENANCE": 0,
"USAGE_PAUSED": 0,
"BLOCK_IPS": "",
"ALLOW_IPS": "",
"COUNTRIES": "",
"COUNTRY_MODE": "BLOCK",
"BLOCK_ASNS": "",
"BLOCK_TOR": 0,
"BLOCK_VPN": 0,
"BLOCK_HOSTING": 0,
"TUNNEL_ENDPOINT": 0,
"TUNNEL_MODE": "SITE",
"TUNNEL_TARGET": "",
"TIMESTAMP": 1789200000
}
]
}
}View a zone#
https://api.cachegenie.com/v1/cdn/{ZONE_ID}One zone object, with MESSAGE CDN Zone Data Returned.. A zone that does not exist, is deleted, or belongs to another account answers 404 CDN Zone not found.; a lower-case or malformed id is a 404 too.
Create a zone#
https://api.cachegenie.com/v1/cdnZONE_NAMEStringrequired4 to 40 letters and digits. Lower-cased, and refused if an active zone already has it, because it becomes a hostname.ORIGIN_URLString unless ORIGIN_TYPE is TUNNELrequiredhttp://orhttps://, a hostname or IP address, an optional port and an optional path, which is put in front of the path a viewer asks for. No query string, no credentials, and no hostname that contains cachegenie.com or cg-cdn.com.ORIGIN_TYPEStringoptionalSTANDARD(the default),S3,SITEorTUNNEL. See Origin types below for what each needs.HOST_HEADERStringoptionala hostname, or empty for none.CACHE_EXPStringoptionalone of the values below, sent as a string or as a number. Anything else is refused.HOME_POPStringoptionalan active location id,auto, or empty.- The eight switches,
VERIFY_ORIGIN_SSL,ADD_HOST_HEADER,FOLLOW_REDIRECTS,STRIP_COOKIES,BLOCK_ROOT,BLOCK_POST,ADD_CANONICAL_HEADERandADD_CORS_HEADER: integers, 1 or 0, each optional. A switch left out takes the default in the table above. TOKEN_AUTHandMAINTENANCE: integers, optional, 1 to switch on. Both start 0.- The bucket fields,
S3_BUCKET,S3_REGION,S3_ACCESS_KEYandS3_SECRET_KEY: strings, required together when ORIGIN_TYPE is S3;S3_ADDRESSING,PATHorVHOST, is optional and starts as PATH. TUNNEL_ENDPOINT, an integer, required when ORIGIN_TYPE is TUNNEL, andTUNNEL_MODE,SITE(the default) orSTANDARD, optional.- The blocking rules,
BLOCK_IPS,ALLOW_IPS,COUNTRIES,COUNTRY_MODEandBLOCK_ASNSas strings andBLOCK_TOR,BLOCK_VPNandBLOCK_HOSTINGas integers, each optional. See Blocking fields below.
curl -X POST https://api.cachegenie.com/v1/cdn \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"ZONE_NAME": "video",
"ORIGIN_URL": "https://origin.example.com",
"VERIFY_ORIGIN_SSL": 1,
"HOME_POP": "alpha1"
}'The answer is the new zone object with MESSAGE CDN Zone Created.. Creating a zone also creates its default hostname, video.zone.cg-cdn.com, with SSL on, and mints a signing key. What can go wrong, each a 400:
Missing required request parameters in JSON Body.: ZONE_NAME or ORIGIN_URL is absent.Unable to decode JSON Body.: the body is not JSON.Invalid Zone Name.,This CDN Zone Name already exists, please try again.Invalid Origin URL.,Invalid Host Header.CACHE_EXP is not one of the Cache Expiration Time values offered for a CDN Zone.HOME_POP must be the ID of an active CDN location (see GET /v1/nodes), "auto" to let CacheGenie choose the location nearest your origin, or empty to turn the origin shield off.- The origin type and blocking messages listed below.
A write that did not go through is 500 Unable to create CDN Zone - Internal Server Error, please try again.
Update a zone#
https://api.cachegenie.com/v1/cdn/{ZONE_ID}Every field of the object except ID, ZONE_NAME, STATUS, USAGE_PAUSED, TIMESTAMP, S3_SECRET_KEY_SET, ORIGIN_CERTIFICATE, HOME_POP_LOCATION and TUNNEL_TARGET (send S3_SECRET_KEY to change the secret), each optional. A field left out (or sent as null) keeps its value; an empty string clears HOST_HEADER, HOME_POP and each blocking list. A body of {} is accepted and changes nothing; a body that is not JSON is refused. The answer is the updated object with MESSAGE CDN Zone Updated.; every change reaches every location within about five seconds.
curl -X POST https://api.cachegenie.com/v1/cdn/AB12CD34E \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"CACHE_EXP": "86400", "STRIP_COOKIES": 1}'The refusals are the create's, with one wording of its own: ORIGIN_URL must start with http:// or https:// and name a hostname or IP address. A zone with an origin certificate keeps an https:// ORIGIN_URL: an http:// one is 400 ORIGIN_URL has to be https:// while the zone has an origin certificate. Revoke it first with DELETE /v1/cdn/{ZONE_ID}/origin-certificate., and 409 when a certificate was created while the call was made. Switching TOKEN_AUTH on when the zone somehow has no key mints one. A write that did not go through is 500 Unable to update CDN Zone - Internal Server Error, please try again.
Delete a zone#
https://api.cachegenie.com/v1/cdn/{ZONE_ID}Removes the zone's hostnames and their certificates and marks the zone deleted; its statistics and the month's usage stay, because they are what the month is invoiced on. The answer is CDN Zone Deleted. with an empty DATA. A zone that cannot be deleted answers 400 Unable to delete CDN Zone, CANNOT_DELETE flag is set to TRUE.; a write that did not go through is 500.
Origin types#
STANDARD needs nothing beyond ORIGIN_URL. SITE takes the web server as ORIGIN_URL and, unless the same request sets them itself, starts with ADD_HOST_HEADER 1, FOLLOW_REDIRECTS 0, STRIP_COOKIES 0, BLOCK_ROOT 0, BLOCK_POST 0, ADD_CANONICAL_HEADER 0 and CACHE_EXP "-1"; switching a zone to SITE applies the same defaults to the fields the request did not send, and switching away does not revert them. See Full site origins.
TUNNEL fetches from an endpoint of one of your tunnels (see CacheGenie Tunnels), named by TUNNEL_ENDPOINT, an ENDPOINT_ID from Tunnels. ORIGIN_URL is not sent and reads empty, and HOME_POP is not used. TUNNEL_MODE is SITE to deliver a whole website, with the SITE defaults above, or STANDARD for static files; left out, a new tunnel zone is SITE and an existing one keeps its delivery. Switching a zone to TUNNEL also sets VERIFY_ORIGIN_SSL, FOLLOW_REDIRECTS and ADD_CANONICAL_HEADER to 0 and clears HOME_POP, for the fields the request did not send; VERIFY_ORIGIN_SSL can be switched back on, and then an https service has to present a certificate a public authority issued for the hostname it is asked for. Switching a tunnel zone to another type needs an ORIGIN_URL, and a zone with an origin certificate cannot become a tunnel zone until the certificate is revoked. Each refusal is a 400 unless marked:
TUNNEL_ENDPOINT is required for a tunnel zone (see GET /v1/tunnels/{TUNNEL_ID}/endpoints).Choose the tunnel endpoint this zone fetches from.: TUNNEL_ENDPOINT is not an id.Choose how the tunnel's service is delivered: static files, or a full website.ORIGIN_URL does not apply to a tunnel zone: its origin is TUNNEL_ENDPOINT.HOME_POP is not applicable to a tunnel zone: the tunnel's entry node is its Home PoP.ORIGIN_URL is required when a tunnel zone changes to another origin type.A tunnel zone takes no origin certificate. Revoke it first with DELETE /v1/cdn/{ZONE_ID}/origin-certificate.- 404
Tunnel endpoint not found.: the endpoint is not one of yours, or it has just been deleted.
S3 takes the bucket endpoint as ORIGIN_URL and needs S3_BUCKET (3 to 63 lower-case letters, digits, dots and hyphens), S3_REGION (such as eu-west-1, or auto), S3_ACCESS_KEY (8 to 128 characters) and S3_SECRET_KEY (8 to 256); S3_ADDRESSING is PATH unless you send VHOST. On an update an empty S3_SECRET_KEY keeps the stored one; switching to another type clears the bucket, region and keys and puts the addressing back to PATH, and bucket fields sent to a zone that is not S3, with no ORIGIN_TYPE beside them, are ignored. The secret is never returned. See Private bucket origins. Each refusal is a 400:
curl -X POST https://api.cachegenie.com/v1/cdn \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"ZONE_NAME": "library",
"ORIGIN_TYPE": "S3",
"ORIGIN_URL": "https://s3.eu-west-1.amazonaws.com",
"S3_BUCKET": "my-video-bucket",
"S3_REGION": "eu-west-1",
"S3_ADDRESSING": "PATH",
"S3_ACCESS_KEY": "AKIAIOSFODNN7EXAMPLE",
"S3_SECRET_KEY": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
}'Choose an origin type: a standard public origin, a private S3 bucket, a full site, or a CacheGenie Tunnel.The bucket name must be 3 to 63 characters using lower case letters, numbers, dots and hyphens, starting and ending with a letter or a number.The region must be the one your bucket lives in, such as eu-west-1 or de. Use auto if your provider does not use regions.Choose how the bucket is addressed: in the path, or as part of the endpoint host.The access key looks wrong. It is 8 to 128 characters and holds no spaces or quotes.Enter the secret key for this bucket. It is stored once and never shown again.The secret key looks wrong. It is 8 to 256 characters and holds no spaces or quotes.With virtual hosted addressing the endpoint must start with the bucket name, for example https://{bucket}.s3.eu-west-1.amazonaws.com. Choose path style instead if your endpoint is the plain one.The endpoint already starts with the bucket name, so choose virtual hosted addressing (otherwise the bucket would be asked for twice).
Blocking fields#
The four lists are strings: addresses one per line (a newline in JSON is \n), country codes and AS numbers comma separated. Addresses are normalised on save (host bits cleared, /32 and /128 dropped), AS numbers may be written with or without the AS, and each list is de-duplicated. At most 1,000 entries in each address list and 200 AS numbers. A list left out keeps its value and an empty string clears it; COUNTRY_MODE is BLOCK or ALLOW, and an empty value leaves it as it was. Each refusal is a 400:
The blocked addresses list is too long: keep it to 1000 entries or fewer.and the same for the always allow list."X" is not an address or a range. Write one per line, either a single address (203.0.113.9 or 2001:db8::1) or a block in CIDR form (203.0.113.0/24 or 2001:db8::/32).The AS number list is too long: keep it to 200 entries or fewer."X" is not an AS number. Write them as numbers separated by commas, with or without the AS (16509 or AS16509).Choose whether the countries listed are the ones to block or the only ones to serve."X" is not a country code. Use the two letter ISO codes, separated by commas (GB, IE, FR).Choose at least one country to serve, or switch back to blocking: serving only the countries on an empty list would refuse everyone.
Cache Expiration values#
CACHE_EXP has to be one of these values, sent as a string or as a number; it is always returned as a string. The label is what the NOC shows.
| Value | Label |
|---|---|
| "-1" | Respect Origin Cache-Control |
| "0" | Do Not Cache |
| "180" | 3 Minutes |
| "1200" | 20 Minutes |
| "3600" | 1 Hour |
| "10800" | 3 Hours |
| "43200" | 12 Hours |
| "86400" | 1 Day |
| "259200" | 3 Days |
| "604800" | 1 Week |
| "2592000" | 1 Month |
| "7776000" | 3 Months |
| "31919000" | 1 Year |