Skip to content

Add a custom hostname to a site's CDN

PUT /v1/sites/{siteId}/cdn/hostname

Serves the site's files from a hostname of your own, like cdn.example.com, instead of the CDN's own address. Use a name that isn't used for anything else yet. The CDN must be on (409 cdn_off), and a site has one hostname: remove it first to use another (409 hostname_exists). A failed one is replaced. Sending the hostname the site already has, while it's being set up or in use, changes nothing: the answer is 200 with the CDN as it is.

What happens next. The answer is 202 with customHostname.status: "validating" and the DNS records to add, in customHostname.records: one proves the hostname is yours (for its SSL certificate; it appears a few seconds after this call), one sends its visitors to the CDN. When the hostname's domain is registered with Rabbitflare and uses Rabbitflare DNS (customHostname.dnsZone), add them in the panel, on the domain's DNS page. Once they're in place, setup usually takes a few minutes; poll GET /sites/{siteId}/cdn until customHostname.status is active.

Limits. Up to 5 hostnames an hour per site, and 5 a day per account (429 rate_limited; a day ends at 00:00 UTC). Hostnames added through the API also share a daily limit for all accounts together: when it's reached, the answer is 429 rate_limited with the seconds to wait until the day ends. One of the delivery options: while they aren't open to the account (deliveryOptions: false), it answers 403 feature_unavailable.

Scopes

The token needs this scope. Without it, the request is refused with insufficient_scope (see Scopes).

sites:write
Manage sites. Domains, SSL, CDN, cache, firewall, malware protection, resources, backups, staging, Media Offload, SMTP and RabbitPress Cache. Choosing Rabbitflare Backup for a site's backups, and turning on Media Offload or a site's malware protection, also need Turn on paid features: they start monthly charges.

Headers

FieldType and description
Idempotency-Key

string 1 to 255 characters

A key of your own for this request, like a UUID: letters, digits and _ - : . Send the request again with the same key (after a timeout, say) and it's done only once. Keys are kept for 24 hours (see Idempotency).

Path parameters

FieldType and description
siteId Required

string

The site's id.

Request body

JSON, with these fields. Fields that aren't listed are refused.

FieldType and description
hostname Required

string Up to 253 characters

A hostname on a domain of your own that isn't used for anything else yet, like cdn.example.com (no https:// or path).

Example request

curl -X PUT "https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/cdn/hostname" \
  -H "Authorization: Bearer $RABBITFLARE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "hostname": "cdn.example.com"
}'

Response

202 Accepted Returns the SiteCdn object in data. It can also answer 200 OK.

The SiteCdn object's fields 28 fields
FieldType and description
status

string

off: the site serves every file itself. enabling: being set up (see stage; usually 3 to 10 minutes). active: the site's files are served from the CDN. failed: setting it up stopped (see lastError); switching it on again carries on where it stopped.

Known values: offenablingactivefailed More can appear.

stage

string or null

While enabling, or where a failed setup stopped: creating (setting up the site's CDN), deploying (spreading it to every location), verifying (checking it serves the site's files), then installing (switching the site's pages to it). Null otherwise.

Known values: creatingdeployingverifyinginstalling More can appear.

blockedReason

string or null

Why the CDN can't be switched on (or changed) for this site right now, in a sentence: the site is a staging copy, is still installing, or is on your own server or a trial server, its server is off, or its built-in address has no SSL certificate yet. Null when nothing stands in the way.

domain

string or null

The CDN's own address for the site's files, which the site's pages use (until a custom hostname is active). Null while the CDN is off or being set up.

startedAt

string or null An ISO 8601 time, in UTC

When the setup started, while enabling or failed. Null otherwise.

enabledAt

string or null An ISO 8601 time, in UTC

When the CDN came on, while it's active. Null otherwise.

lastError

string or null

Why the setup failed (with status: "failed"). Null otherwise.

purging

boolean

Whether files are being cleared from the CDN now (it takes a minute or two).

purgedAt

string or null An ISO 8601 time, in UTC

When files were last cleared from the CDN. Null when they never were.

usage

object or null

What the CDN served for the site over the last days days. Null while it's off, or when the figures can't be read just now.

days

integer

The number of days the figures cover, up to now.

requests

integer

Requests the CDN served for the site.

bytes

integer

Bytes the CDN served for the site.

deliveryOptions

boolean

Whether the delivery options are open to the account: choosing the kinds of files the CDN serves and paths it leaves on the server (PUT /sites/{siteId}/cdn/settings), a custom hostname, and clearing particular files. When false, those answer 403 feature_unavailable; switching the CDN on and off and clearing everything work either way.

settings

object

What the CDN serves. It applies whenever the CDN is on; a site that never chose serves every kind and keeps no paths.

types

array of strings

The kinds of files the CDN serves, from the site's /wp-content and /wp-includes folders: images (Images: JPG, PNG, GIF, WebP, AVIF, SVG, ICO), css (CSS: Stylesheets), js (JavaScript: Scripts), fonts (Fonts: WOFF2, WOFF, TTF, OTF, EOT), media (Video and audio: MP4, WebM, MP3, M4A, WAV, OGG), documents (PDFs: PDF documents).

Known values: imagescssjsfontsmediadocuments More can appear.

exclude

array of strings

Paths kept on the server: files whose address starts with one of them are never served from the CDN.

customHostname

object or null

The site's custom CDN hostname, while the CDN is on. Null when it has none, or when the delivery options aren't open to the account.

hostname

string

The hostname the site's files are served from, like cdn.example.com.

status

string

validating: waiting for its DNS records (add both). attaching: adding it and its certificate to the CDN. deploying: spreading it to every CDN location (usually 3 to 10 minutes). checking: checking it serves the site's files (its routing record must point at the CDN). installing: switching the site's pages to it. active: the site's files are served from it. removing: being removed (the site already uses the CDN's own address again). failed: see error.

Known values: validatingattachingdeployingcheckinginstallingactiveremovingfailed More can appear.

records

array of objects

The DNS records to add for it, while it's being set up. The validation record appears a few seconds after the hostname is added; once the hostname is active only the routing record is listed (keep it).

Show its 4 fields
FieldType and description
type

string

The record's type: CNAME.

Known values: CNAME More can appear.

name

string

The record's name (where to add it), in full.

value

string

What the record points at.

purpose

string

validation: proves the hostname is yours, for its SSL certificate. routing: sends the hostname's visitors to the CDN.

Known values: validationrouting More can appear.

dnsZone

string or null

The domain registered with Rabbitflare, and using Rabbitflare DNS, that the hostname is on: add the records in the control panel, on the domain's DNS page. Null when its DNS is elsewhere: add the records there.

error

string or null

Why setting it up failed (with status: "failed"). Remove it and add it again to start over. Null otherwise.

addedAt

string An ISO 8601 time, in UTC

When the hostname was added.

Example response

202 Accepted
{
  "data": {
    "status": "active",
    "stage": null,
    "blockedReason": null,
    "domain": "d1a2b3c4e5f6g7.cdn.example.net",
    "startedAt": null,
    "enabledAt": "2026-11-18T09:42:10.000Z",
    "lastError": null,
    "purging": false,
    "purgedAt": "2026-11-18T11:05:33.000Z",
    "usage": {
      "days": 7,
      "requests": 184220,
      "bytes": 9310442118
    },
    "deliveryOptions": true,
    "settings": {
      "types": [
        "images",
        "css",
        "js",
        "fonts",
        "media",
        "documents"
      ],
      "exclude": []
    },
    "customHostname": {
      "hostname": "cdn.example.com",
      "status": "validating",
      "records": [
        {
          "type": "CNAME",
          "name": "_3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c.cdn.example.com",
          "value": "_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d.validation.example.net",
          "purpose": "validation"
        },
        {
          "type": "CNAME",
          "name": "cdn.example.com",
          "value": "d1a2b3c4e5f6g7.cdn.example.net",
          "purpose": "routing"
        }
      ],
      "dnsZone": "example.com",
      "error": null,
      "addedAt": "2026-11-18T10:15:02.000Z"
    }
  }
}

Errors

The errors this request can answer besides those every request can (a missing token, a missing scope, the rate limits). Each answer is an Error object (see Errors).

Status and codeWhen, and what to do
403 feature_unavailable

This product isn't open to the account.

Contact support if you'd like it opened.

404 not_found

The resource doesn't exist, or isn't this account's.

Check the id. Ids of other accounts' resources answer the same way.

409 staging_busy

A staging operation is running on this site, or on a site of this server.

Wait until it finishes (activeRun in GET /sites/{siteId}/staging is null again), or cancel it, then try again.

409 cdn_off

The site's CDN isn't on, and this needs it.

Turn the CDN on first (POST /v1/sites/{siteId}/cdn/actions/enable) and wait until it's active.

409 hostname_exists

The site's CDN already has a custom hostname.

Remove it first (DELETE /v1/sites/{siteId}/cdn/hostname), then add the new one.

409 busy

Another change is still in progress on this server or site, or something else under way stops this one for now (a site backup running on the server, the server's backups being moved): message says what.

Wait until it finishes, then try again. A change to the server or site itself is done when its pendingAction is null again; for anything else, message says how long to wait.

409 server_restoring

The server is being restored, and nothing else can change it or its sites until that's done.

Wait until the restore finishes (the server's pendingAction is null again), then try again. A restore that stopped partway keeps pendingAction: "restore", with the server's lastError set, until our team has checked the server.

422 validation_failed

One or more fields are missing or wrong. fields names each one with what's wrong.

Correct the fields named in fields. Unknown fields are refused too.

429 rate_limited

Too many requests. scope says which limit: token, account, create, operation or network.

Wait for Retry-After seconds, then go on more slowly.

502 cdn_error

The CDN didn't accept the change just now.

Try again in a few minutes.

503 cdn_limit

Custom CDN hostnames can't be added right now.

Try again later. Our team has been told.

Rate limit

Write requests: 30 a minute per token, 60 per account. More in Rate limits.

Added on .

Popular

API docs