Skip to content

Get and update account info

By , Head of IntegrationsUpdated

Open this page in a new chat

Short answer

This page has 2 commands: Get account info (GET /v2/account) and Update account info (POST /v2/account). Each call needs a bearer token and counts towards your hourly API limit. Below are the parameters, sample code in 9 languages and a sample answer.

After reading this you will know

  • How to get and update account info
  • 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.

GEThttps://api.sirv.com/v2/account

Use this API method to get information about the account, including its CDN URL; account name; additional domains; remote fetching status; date created and more.

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', {
method: 'GET',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Example response

{
"dateCreated": "2014-10-14T14:15:18.580Z",
"alias": "demo",
"fileSizeLimit": 50000000,
"fetching": {
"enabled": false,
"type": "http",
"http": {
"auth": {
"enabled": false,
"password": "",
"username": ""
},
"url": "https://somesite.com/folder/"
},
"maxFilesize": 2097152
},
"minify": {
"enabled": true
},
"cdnTempURL": "demo.sirv.com",
"cdnURL": "demo.sirv.com",
"aliases": {
"demo": {
"prefix": "/",
"cdn": true
},
"anotherdemo": {
"prefix": "/",
"cdn": true
},
"demo-cdntest": {
"prefix": "/"
},
"demo-jwt": {
"prefix": "/",
"cdn": true
}
},
"status": {
"status": "active",
"details": {}
}
}
POSThttps://api.sirv.com/v2/account

Use this method to change the account options. You can enable or disable JS/CSS file minification.

You can also enable/disable automatic fetching via HTTP or S3 from a remote location.

Request body (JSON)

FieldTypeRequiredExampleDescription
minifyobjectNoMinification of JS and CSS files served from your account.
minify.enabledbooleanYestrueEnable or disable automatic minification of JS/CSS files
fetchingobjectNoFetching: Sirv copies a file from your own server or S3 bucket the first time someone requests it.
fetching.enabledbooleanYesfalsetrue to turn fetching on, false to turn it off.
fetching.typestringYeshttpOne of: http, s3.
fetching.httpobjectYesWhere to fetch from when the type is http: the address of your server.
fetching.s3objectYesWhere to fetch from when the type is s3: the bucket, its access keys and an optional endpoint and prefix.
aliasesobjectNoSettings for each account name (alias), with the alias as the key.
aliases.<alias>objectNoSettings for one alias: cdn (true to serve it through the CDN), prefix and defaultProfile.

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', {
method: 'POST',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' },
body: JSON.stringify({
"fetching": {
"enabled": false
}
}),
});
console.log(res.status, await res.text());

Response

HTTP 200 with an empty body when the command succeeds.

Back to top