Creating a CDN Site
Creating a Site
You can create a new CDN site by making an HTTP POST request to the Create a site endpoint:
$ curl --request POST \
--url https://gateway.stackpath.com/delivery/v1/stacks/STACK_ID/sites \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer BEARER_TOKEN' \
--data '{
"domain": "domain.com",
"origin": {
"path": "/",
"hostname": "domain.com",
"port": 80,
"securePort": 443
},
"features": [
"CDN"
]
}
Remember to replace BEARER_TOKEN with your bearer token value and STACK_ID with the Stack ID.
This call tells the API to create a new CDN site for a domain named domain.com
on a Stack named My Default Stack.
This call should produce a response similar to the following:
HTTP/1.1 200 OK
Date: Thu, 27 Feb 2020 00:54:57 GMT
Content-Type: application/json
Content-Length: 316
Connection: keep-alive
Vary: Accept-Encoding
Grpc-Metadata-Content-Type: application/grpc
Strict-Transport-Security: max-age=15724800; includeSubDomains
{
"site": {
"id": "414aafec-e508-49d5-8ebe-5b1e3258654d",
"stackId": "74dd3b65-5f01-4b1e-8fcc-ad8443568af7",
"label": "domain.com",
"status": "ACTIVE",
"features": [
"CDN"
],
"apiLoginUrls": [],
"shieldPopCodes": [],
"createdAt": "2020-02-27T00:54:49.878509Z",
"updatedAt": "2020-02-27T00:54:57.080636Z",
"apiUrls": [],
"monitoring": false
}
}
Retrieving a Site
You can retrieve the newly created site with an HTTP GET call to the Get a site endpoint:
$ curl -i --request GET \
--url https://gateway.stackpath.com/delivery/v1/stacks/STACK_ID/sites/SITE_ID \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer BEARER_TOKEN'
As with the previous call, replace the BEARER_TOKEN and STACK_ID. In addition, replace SITE_ID with the ID of the new site.
The contents of this call's response should match the response from the call that initially created the site:
HTTP/1.1 200 OK
Date: Thu, 27 Feb 2020 01:01:14 GMT
Content-Type: application/json
Content-Length: 316
Connection: keep-alive
Vary: Accept-Encoding
Grpc-Metadata-Content-Type: application/grpc
Strict-Transport-Security: max-age=15724800; includeSubDomains
{
"site": {
"id": "414aafec-e508-49d5-8ebe-5b1e3258654d",
"stackId": "74dd3b65-5f01-4b1e-8fcc-ad8443568af7",
"label": "domain.com",
"status": "ACTIVE",
"features": [
"CDN"
],
"apiLoginUrls": [],
"shieldPopCodes": [],
"createdAt": "2020-02-27T00:54:49.878509Z",
"updatedAt": "2020-02-27T00:54:57.080636Z",
"apiUrls": [],
"monitoring": false
}
}
Updated 5 months ago