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.customer.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.customer.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.customer.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.customer.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
API key for authentication. Make sure to include the word apikey, followed by a single space and then your token.
Example: apikey 1234_abcdef
Body
Alias hostname. Wildcard hostnames are not supported.
"shop.example.com"
ID of the CDN resource whose settings the alias is served with.
4567
ID of your own SSL certificate to serve for the alias. The certificate must cover the alias hostname. A Let's Encrypt certificate issued for one of your CDN resources cannot be used.
Omit it to have a Let's Encrypt certificate issued automatically.
890
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
Domain validation method used to issue the Let's Encrypt certificate. Defaults to dns_01. Can be passed only when automated is true.
dns_01, http_01 "http_01"
Whether the alias is enabled. Defaults to true.
true
Response
Successful.
Alias ID.
123
Alias hostname. Cannot be changed after creation.
"shop.example.com"
ID of the CDN resource whose settings the alias is served with. Cannot be changed after creation.
4567
How the alias certificate is managed. Can be changed while the alias is served.
Possible values:
true– A Let's Encrypt certificate is issued and renewed automatically.false– The certificate referenced byssl_id, if any, was added by you.
true
Domain validation method used to issue the Let's Encrypt certificate for the alias. null when automated is false.
dns_01, http_01 "http_01"
ID of the SSL certificate served for the alias.
890
Whether you have enabled the alias.
Possible values:
true– The alias is enabled.false– The alias is paused and is not served.
true
Whether the alias is enabled by the system. Follows the state of the CDN resource.
Possible values:
true– The alias can be served.false– The alias is not served because its CDN resource is not active.
true
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"
Date and time when the served certificate expires (ISO 8601/RFC 3339 format, UTC). null while no certificate is served.
"2027-01-01T10:00:00Z"
Date and time when the alias was created (ISO 8601/RFC 3339 format, UTC).
"2026-09-01T10:00:00Z"
Date and time when the alias was last changed (ISO 8601/RFC 3339 format, UTC).
"2026-09-01T10:05:00Z"
Was this page helpful?