Hostnames and certificates
On this page
A zone serves on the hostnames you add, each a CNAME to cdn.cachegenie.com (the zone object's CNAME_TARGET), and on nothing else. Five calls manage the hostnames and three more the certificate on one of them; the hostname object says whether SSL is on, whether HTTP is redirected, and which certificate is in place.
The hostname object#
| Field | Type | Meaning |
|---|---|---|
ID | Integer | The hostname id, used in the paths below |
HOSTNAME | String | The name, lower case |
SSL_ENABLED | Integer | 1 when the name is served over HTTPS |
FORCE_SSL | Integer | 1 when HTTP is redirected to HTTPS with a 301 and a Strict-Transport-Security header |
SSL_CERTIFICATE | String | LETSENCRYPT or CUSTOM. LETSENCRYPT with CERTIFICATE_EXPIRES 0 means no certificate has been issued yet |
CERTIFICATE_EXPIRES | Integer | When the certificate in place expires, Unix seconds; 0 when there is none |
TIMESTAMP | Integer | When the hostname was added |
List hostnames#
GET https://api.cachegenie.com/v1/cdn/{ZONE_ID}/hostnamesEvery hostname on the zone as DATA.CDN_HOSTNAMES, oldest first, with MESSAGE Data returned for all CDN Hostnames for this CDN Zone.
{
"CODE": 200,
"MESSAGE": "Data returned for all CDN Hostnames for this CDN Zone.",
"DATA": {
"CDN_HOSTNAMES": [
{
"ID": 4021,
"HOSTNAME": "www.example.com",
"SSL_ENABLED": 1,
"FORCE_SSL": 0,
"SSL_CERTIFICATE": "LETSENCRYPT",
"CERTIFICATE_EXPIRES": 1796976000,
"TIMESTAMP": 1789200000
},
{
"ID": 4022,
"HOSTNAME": "cdn.example.com",
"SSL_ENABLED": 1,
"FORCE_SSL": 1,
"SSL_CERTIFICATE": "LETSENCRYPT",
"CERTIFICATE_EXPIRES": 1797062400,
"TIMESTAMP": 1789203600
}
]
}
}Add a hostname#
POST https://api.cachegenie.com/v1/cdn/{ZONE_ID}/hostnames- HOSTNAME (String, required): a full name of at least two labels, letters, digits and hyphens with a last label of letters only, up to 253 characters. A subdomain such as
cdn.example.comorwww.example.comis recommended; a root (apex) domain such asexample.comorexample.co.ukneedsACCEPT_APEXbeside it. No wildcard, no port, no IP address, no name that is cachegenie.com or under it, and not a name already on any zone. Point it atcdn.cachegenie.comwith a CNAME record. - ACCEPT_APEX (Integer, optional): 1 to add a root domain anyway. Its DNS record has to be an ALIAS, or a CNAME your DNS provider flattens, and both bypass GeoDNS, so visitors may be served from a location further from them; a subdomain has no such trade-off. Not needed for a subdomain. See Root and apex domains.
curl -X POST https://api.cachegenie.com/v1/cdn/AB12CD34E/hostnames \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"HOSTNAME": "cdn.example.com"}'The answer is the new hostname object with MESSAGE CDN Hostname Created.. It is created with SSL off, so that the DNS can be pointed at the zone first; switch SSL on afterwards and a certificate is issued. See Hostnames and certificates. What can go wrong:
- 400
Missing HOSTNAME in JSON Body.:HOSTNAMEis absent. - 400
Invalid CDN Hostname.: the name breaks one of the rules above. - 400
Apex and root domains need ACCEPT_APEX: 1. CNAME flattening and ALIAS records bypass GeoDNS routing to the nearest location, so visitors may be served from a location further away. Send ACCEPT_APEX: 1 to add {HOSTNAME} anyway, or use a subdomain such as www.{HOSTNAME} or cdn.{HOSTNAME} instead. See https://docs.cachegenie.com/zones/hostnames-and-certificates#root-and-apex-domains for details.: the name is a root domain andACCEPT_APEXis not 1. - 400
This CDN Hostname already exists, please try again.: the name is already on a zone, on this account or another. - 500
Unable to create CDN Hostname - Internal Server Error, please try again.: a write that did not go through.
View a hostname#
GET https://api.cachegenie.com/v1/cdn/{ZONE_ID}/hostnames/{HOSTNAME_ID}One hostname object, MESSAGE CDN Hostname Data Returned.. A hostname that is not on this zone answers 404 CDN Hostname not found.
Update a hostname#
POST https://api.cachegenie.com/v1/cdn/{ZONE_ID}/hostnames/{HOSTNAME_ID}- SSL_ENABLED (Integer, optional): 1 for on, 0 for off; any other value is refused with 400
SSL_ENABLED must be 1 or 0.; left out ornull, unchanged. Switching SSL off switchesFORCE_SSLoff with it. - FORCE_SSL (Integer, optional): 1 for on, 0 for off; any other value is refused with 400
FORCE_SSL must be 1 or 0.; left out ornull, unchanged. On needs SSL on and a certificate that has not expired.
curl -X POST https://api.cachegenie.com/v1/cdn/AB12CD34E/hostnames/4022 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"SSL_ENABLED": 1, "FORCE_SSL": 1}'The answer is the updated object with MESSAGE CDN Hostname Updated.. Asking for Force SSL before a certificate exists is 400 FORCE_SSL needs SSL_ENABLED and a certificate for the hostname (Let's Encrypt once issued, or an uploaded one); see SSL_CERTIFICATE and CERTIFICATE_EXPIRES on the hostname.: switch SSL on, wait for CERTIFICATE_EXPIRES to show a date in the future, then send FORCE_SSL.
Delete a hostname#
DELETE https://api.cachegenie.com/v1/cdn/{ZONE_ID}/hostnames/{HOSTNAME_ID}Removes the hostname and every certificate it had, at once. MESSAGE CDN Hostname Deleted. with an empty DATA. Any hostname may be deleted, the zone's last one too, after which the zone serves nothing until another is added.
View the certificate#
GET https://api.cachegenie.com/v1/cdn/{ZONE_ID}/hostnames/{HOSTNAME_ID}/certificateMESSAGE CDN Hostname Certificate Returned. and four fields: TYPE (LETSENCRYPT or CUSTOM), ISSUER (the issuer's name; Let's Encrypt for ours), EXPIRES (Unix seconds, 0 when none is in place yet) and UPLOADED (when a custom certificate was uploaded, 0 for Let's Encrypt).
Upload your own certificate#
POST https://api.cachegenie.com/v1/cdn/{ZONE_ID}/hostnames/{HOSTNAME_ID}/certificate- CERTIFICATE (String, required): the certificate in PEM form, leaf first, intermediates after it. Up to 64 KB.
- PRIVATE_KEY (String, required): the matching key in PEM form, unencrypted. RSA of 2048 bits or more, or EC on P-256, P-384 or P-521 with a named curve. Up to 16 KB.
curl -X POST \
https://api.cachegenie.com/v1/cdn/AB12CD34E/hostnames/4022/certificate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -n --rawfile c fullchain.pem --rawfile k privkey.pem \
'{CERTIFICATE: $c, PRIVATE_KEY: $k}')"The certificate has to cover the hostname (common name or a subject alternative name; a wildcard covers one label), be unexpired and not start more than a day in the future. Saving replaces any certificate the hostname had, the Let's Encrypt one included, switches SSL on, and puts it on every location within about fifteen seconds. The answer is MESSAGE CDN Hostname Certificate Saved. with the certificate object above as DATA. Each refusal is the sentence the NOC's Own certificate panel shows:
- 400
CERTIFICATE and PRIVATE_KEY (both PEM text) are required.: either field is absent. - 400
Paste both the certificate and its private key.: either one is empty. - 400
The certificate or key is larger than expected. Paste the PEM text only.: the certificate is over 64 KB or the key over 16 KB. - 400
The certificate must be PEM text starting with -----BEGIN CERTIFICATE-----.: the certificate does not start with that line. - 400
The certificate could not be read. Paste the PEM certificate exactly as it was issued.: the certificate is not one. - 400
The private key is encrypted. Remove the passphrase and paste the unencrypted PEM key.: the key has a passphrase. - 400
The private key could not be read. It must be an unencrypted PEM key (RSA or EC).: the key is not one. - 400
The private key does not belong to this certificate.: the key and the certificate do not match. - 400
RSA keys must be 2048 bits or longer.: an RSA key under 2048 bits. - 400
EC keys must use a named curve (P-256, P-384 or P-521) rather than explicit curve parameters. Export the key with named-curve parameters and try again.: an EC key on another curve, or written with explicit parameters. - 400
Only RSA and EC keys are supported.: a key of any other type. - 400
This certificate expired on {date}. Upload a current one.: the certificate has expired. - 400
This certificate is not valid until {date}.: the certificate starts more than a day from now. - 400
This certificate is not issued for {hostname}. It covers {names}.: the certificate does not cover the hostname. - 500
Unable to save the certificate - Internal Server Error, please try again.: a write that did not go through.
Remove your own certificate#
DELETE https://api.cachegenie.com/v1/cdn/{ZONE_ID}/hostnames/{HOSTNAME_ID}/certificateDeletes an uploaded certificate, switches FORCE_SSL off, and starts a Let's Encrypt issuance for the name. MESSAGE CDN Hostname Certificate Removed.. A hostname that has no uploaded certificate answers 404 This hostname has no own certificate; it uses Let's Encrypt., so a delete never silently switches Force SSL off on a Let's Encrypt hostname.