import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
alias = client.cdn.aliases.create(
cname="shop.example.com",
resource_id=4567,
)
print(alias.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cdn"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
alias, err := client.CDN.Aliases.New(context.TODO(), cdn.AliasNewParams{
Cname: "shop.example.com",
ResourceID: 4567,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", alias.ID)
}
curl --request POST \
--url https://api.gcore.com/cdn/aliases \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"cname": "shop.example.com",
"resource_id": 4567,
"ssl_id": 890,
"automated": true,
"challenge_type": "http_01",
"active": true
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cname: 'shop.example.com',
resource_id: 4567,
ssl_id: 890,
automated: true,
challenge_type: 'http_01',
active: true
})
};
fetch('https://api.gcore.com/cdn/aliases', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/cdn/aliases",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cname' => 'shop.example.com',
'resource_id' => 4567,
'ssl_id' => 890,
'automated' => true,
'challenge_type' => 'http_01',
'active' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.gcore.com/cdn/aliases")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"cname\": \"shop.example.com\",\n \"resource_id\": 4567,\n \"ssl_id\": 890,\n \"automated\": true,\n \"challenge_type\": \"http_01\",\n \"active\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/aliases")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cname\": \"shop.example.com\",\n \"resource_id\": 4567,\n \"ssl_id\": 890,\n \"automated\": true,\n \"challenge_type\": \"http_01\",\n \"active\": true\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"cname": "shop.example.com",
"resource_id": 4567,
"automated": true,
"challenge_type": "http_01",
"ssl_id": 890,
"active": true,
"enabled": true,
"status": "active",
"ssl_status": "issued",
"ssl_validity_not_after": "2027-01-01T10:00:00Z",
"created": "2026-09-01T10:00:00Z",
"updated": "2026-09-01T10:05:00Z"
}{
"errors": {
"field_name": [
"Error description."
]
}
}Create alias
Create an alias: a hostname you own that is served with the settings of one of your CDN resources and with its own SSL certificate.
By default, a Let’s Encrypt certificate is issued for the alias automatically. Choose how its domain is validated with challenge_type.
To use your own certificate instead, pass its ID in ssl_id. The certificate must cover the alias hostname; a Let’s Encrypt certificate issued for one of your CDN resources cannot be used.
The hostname must be unique across all CDN resources, additional CNAMEs and aliases.
The DNS record the hostname needs for Let’s Encrypt domain validation is returned in ssl_provisioning of the alias details.
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
alias = client.cdn.aliases.create(
cname="shop.example.com",
resource_id=4567,
)
print(alias.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cdn"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
alias, err := client.CDN.Aliases.New(context.TODO(), cdn.AliasNewParams{
Cname: "shop.example.com",
ResourceID: 4567,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", alias.ID)
}
curl --request POST \
--url https://api.gcore.com/cdn/aliases \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"cname": "shop.example.com",
"resource_id": 4567,
"ssl_id": 890,
"automated": true,
"challenge_type": "http_01",
"active": true
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cname: 'shop.example.com',
resource_id: 4567,
ssl_id: 890,
automated: true,
challenge_type: 'http_01',
active: true
})
};
fetch('https://api.gcore.com/cdn/aliases', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/cdn/aliases",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cname' => 'shop.example.com',
'resource_id' => 4567,
'ssl_id' => 890,
'automated' => true,
'challenge_type' => 'http_01',
'active' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.gcore.com/cdn/aliases")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"cname\": \"shop.example.com\",\n \"resource_id\": 4567,\n \"ssl_id\": 890,\n \"automated\": true,\n \"challenge_type\": \"http_01\",\n \"active\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cdn/aliases")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cname\": \"shop.example.com\",\n \"resource_id\": 4567,\n \"ssl_id\": 890,\n \"automated\": true,\n \"challenge_type\": \"http_01\",\n \"active\": true\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"cname": "shop.example.com",
"resource_id": 4567,
"automated": true,
"challenge_type": "http_01",
"ssl_id": 890,
"active": true,
"enabled": true,
"status": "active",
"ssl_status": "issued",
"ssl_validity_not_after": "2027-01-01T10:00:00Z",
"created": "2026-09-01T10:00:00Z",
"updated": "2026-09-01T10:05:00Z"
}{
"errors": {
"field_name": [
"Error description."
]
}
}Authorizations
Body
How the alias certificate is managed. Defaults to true when ssl_id is omitted and to false when ssl_id is passed.
Possible values:
true– A Let's Encrypt certificate is issued and renewed automatically.ssl_idmust be omitted.false– Your own certificate referenced byssl_id, if any, is served.
true
Response
Successful.
Alias status.
Possible values:
inactive– The alias or its CDN resource is disabled; the alias is not served.pending– The alias configuration has not reached the CDN yet.http_only– The alias is served over HTTP only.active– The alias is served over HTTP and HTTPS.
inactive, pending, http_only, active "active"
Outcome of the certificate we manage for the alias.
Possible values:
pending– A certificate attempt is in progress, or was stopped by pausing the alias and starts again after it is resumed.issued– The latest attempt succeeded.failed– The latest attempt ended without a certificate.null– No certificate is managed for the alias: the alias uses a certificate you provided, or is automated and has never opened an attempt.
pending, issued, failed "issued"
Was this page helpful?