---
name: azion-add-a-custom-domain-to-an-application
description: >-
  List a hostname you own on a domain that serves an application, point its DNS record at the Azion address, and close that address, from Console or the API.
---

# Add a custom domain to an application

> Platform versions: this page applies to API v3.x only, not to API v6.x and API v4.x.
> Equivalent page for API v4.x: [Add a custom domain to a workload](/en/documentation/guides/platform/migration/configure-a-domain.md)
> Release stage: Deprecated.

You can serve an [application](/en/documentation/platform/applications/v3/) on a domain you own from Azion Console or the API. A [domain](/en/documentation/platform/domains/) connects hostnames to an application, and lists those hostnames in its **CNAME** field.

A custom domain, on this page, is a hostname of a domain you own, such as `www.example.com`. Every domain already answers on its Azion address, a hostname that Azion generates in the form `xxxxxxxxxx.map.azionedge.net`. Serving your own hostname takes two changes: the domain lists the hostname, and a DNS record points the hostname at the Azion address.

---

## Prerequisites

### Console

- An application for the domain to serve.
- A domain you own, and access to its DNS records at your DNS provider or in [Edge DNS](/en/documentation/platform/edge-dns/).
- Access to Azion Console. For more information, refer to [How to access Azion Console](/en/documentation/guides/platform/account-and-billing/how-to-access-azion-console/).

### API

- An application for the domain to serve, and its ID.
- A domain you own, and access to its DNS records at your DNS provider or in [Edge DNS](/en/documentation/platform/edge-dns/).
- A personal token for the `Authorization` header, in the form `Token [TOKEN VALUE]`. To create a token, refer to [Personal tokens](/en/documentation/fundamentals/personal-tokens/).
- `curl` or another HTTP client.

---

## List the hostnames on a domain

### Console

To list a hostname on a domain in Azion Console:

1. **Open Domains**

   Access [Azion Console](https://console.azion.com/) > **Domains**.

2. **Start a domain**

   Select **+ Domain**, or select an existing domain to edit it.

3. **Name the domain**

   Enter a name. The name identifies the entry on the account and is not a hostname.

4. **Choose the environment**

   In **Environment Type**, select **Global Edge Network** for production or **Staging Network** for a test environment.

5. **Select the application and the firewall**

   In **Applications**, select your application. In **Firewall**, select your firewall.

6. **List the hostnames**

   In **CNAME**, list the hostnames you serve, one per line.

7. **Decide on the Azion address**

   Leave **CNAME access only** off to keep the `xxxxxxxxxx.map.azionedge.net` address reachable, or turn it on to answer only the hostnames you listed.

8. **Select the certificate**

   In **Digital Certificate**, select **Azion SAN** or a certificate of your own.

9. **Save the domain**

   Select **Save**.

### API

To create the domain with the API, send a `POST` to `/domains`. The request carries the header `Accept: application/json; version=3`, and `<application-id>` is the ID of the application the domain serves:

```bash
curl --request POST \
  --url https://api.azionapi.net/domains \
  --header 'Accept: application/json; version=3' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Token [TOKEN VALUE]' \
  --data '{
  "name": "my-domain",
  "cnames": ["www.example.com"],
  "cname_access_only": false,
  "digital_certificate_id": null,
  "edge_application_id": <application-id>
}'
```

| Key                      | What it carries                                                                     |
| ------------------------ | ----------------------------------------------------------------------------------- |
| `name`                   | The name of the entry on the account. It is not a hostname                          |
| `cnames`                 | The hostnames the domain serves                                                     |
| `cname_access_only`      | `false` keeps the Azion address reachable; `true` answers only the listed hostnames |
| `digital_certificate_id` | `null` selects the **Azion SAN** certificate                                        |
| `edge_application_id`    | The ID of the application the domain serves                                         |

The response returns the domain as Azion stored it, with its Azion address in `domain_name`:

```json
{
  "results": {
    "id": 1234567,
    "name": "my-domain",
    "cnames": ["www.example.com"],
    "cname_access_only": false,
    "digital_certificate_id": null,
    "edge_application_id": 1234567890,
    "is_active": true,
    "domain_name": "xxxxxxxxxx.map.azionedge.net"
  }
}
```

For every field, refer to [Domains](/en/documentation/platform/domains/).

---

## Point the domain at the Azion address

Requests reach the application once DNS resolves your hostname to the Azion address of the domain. The API returns that address in `domain_name`.

At your DNS provider, create a record for the hostname with these values:

| Field | Value                                                                   |
| ----- | ----------------------------------------------------------------------- |
| Name  | Your hostname, such as `www.example.com`                                |
| Type  | `CNAME`                                                                 |
| Value | The Azion address of the domain, such as `xxxxxxxxxx.map.azionedge.net` |

When [Edge DNS](/en/documentation/platform/edge-dns/) holds the zone of your domain, create the record there instead.

Once resolvers pick up the record and the domain change propagates, requests to your hostname reach the application the domain serves. A change takes several minutes to reach all of Azion's distributed infrastructure, and requests can receive the old or the new configuration meanwhile. Repeat a request until the answers agree.

HTTPS on your hostname needs a server certificate that covers it, and the default Azion SAN certificate does not cover a hostname of your own. To get a certificate for your domain, refer to [Request a Let's Encrypt certificate](/en/documentation/guides/application-security/tls-and-certificates/how-to-generate-a-lets-encrypt-certificate/v3/) or [Upload a digital certificate](/en/documentation/guides/application-security/tls-and-certificates/digital-certificates/v3/).

---

## Close the Azion address

With **CNAME access only** off, the domain also answers on its Azion address. Turn it on when the domain must answer only on your hostnames. Do it after your hostnames answer as expected, because a closed Azion address no longer serves your application.

To close the Azion address in Azion Console:

1. **Open the domain**

   Access [Azion Console](https://console.azion.com/) > **Domains** > **the domain that lists your hostname**.

2. **Turn on CNAME access only**

3. **Save the domain**

   Select **Save**.

With the API, `cname_access_only` set to `true` makes the same choice when you create the domain.

---

## Next steps

- [Request a Let's Encrypt certificate](/en/documentation/guides/application-security/tls-and-certificates/how-to-generate-a-lets-encrypt-certificate/v3.md): Serve HTTPS on your hostname with a certificate that Azion requests and renews.
- [Set a Firewall on a domain](/en/documentation/guides/application-security/firewall-and-waf/firewall-protect-your-domain/v3.md): Inspect the requests that reach your hostname with a firewall on the domain.
- [Domains](/en/documentation/platform/domains.md): Look up every field of a domain, such as CNAME and CNAME access only.
- [Edge DNS](/en/documentation/platform/edge-dns.md): Host the zone of your domain at Azion and create its records there.
