Skip to content

Add or remove a custom domain

By , Head of IntegrationsUpdated

Open this page in a new chat

Short answer

This page has 2 commands: Add custom domain (POST /v2/account/custom-domain) and Remove custom domain (DELETE /v2/account/custom-domain). Use this method to configure a custom CDN domain for an account alias. Each call needs a bearer token and counts towards your hourly API limit.

After reading this you will know

  • How to add or remove a custom domain
  • Which parameters each of the 2 commands takes
  • Sample code in 9 languages and a sample answer

Every command on this page needs a bearer token and counts towards your hourly limit.

POSThttps://api.sirv.com/v2/account/custom-domain

Use this method to configure a custom CDN domain for an account alias.

Request body (JSON)

FieldTypeRequiredExampleDescription
aliasstringYesmy-accountAccount name (alias) that the domain serves.
domainstringYescdn.example.comYour custom domain, for example cdn.example.com.

Example request

// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/account/custom-domain', {
method: 'POST',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' },
body: JSON.stringify({
"alias": "my-account",
"domain": "cdn.example.com"
}),
});
console.log(res.status, await res.text());

Response

HTTP 200 with an empty body when the command succeeds.

DELETEhttps://api.sirv.com/v2/account/custom-domain

Use this method to remove the custom CDN domain from an account alias.

Query parameters

NameTypeRequiredExampleDescription
aliasstringYesmy-accountAccount name (alias) that the domain serves.
domainstringYescdn.example.comCustom domain to remove.

Example request

// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/account/custom-domain?alias=my-account&domain=cdn.example.com', {
method: 'DELETE',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Response

HTTP 200 with an empty body when the command succeeds.

Back to top