[Yandex Cloud documentation](../../index.md) > [Yandex API Gateway](../index.md) > [Step-by-step guides](index.md) > Managing an API gateway > Adding a domain

# Adding a domain

You can add your own domain to access the API gateway. You can add a wildcard domain, e.g., `*.example.com`, to the API gateway for it to handle requests for all `example.com` subdomains. You can also add multiple domains. The domain will be identified by the `Host` header.

{% note warning %}

If a third-party DNS provider manages your domain, it must be a third-level domain or lower. For example, you can add the `www.example.com` domain, but not `example.com`. This has to do with how CNAME records are processed on DNS hostings. Learn more in [RFC 1912, section 2.4](https://www.ietf.org/rfc/rfc1912.txt).

To use a second-level domain, such as `example.com`, delegate it to [Yandex Cloud DNS](../../dns/index.md) and create an [ANAME record](../../dns/concepts/resource-record.md#aname) in the DNS zone.

{% endnote %}

Make sure you have an [IETF](https://www.ietf.org/) (RFC [2459](https://www.ietf.org/rfc/rfc2459.txt)/[3280](https://www.ietf.org/rfc/rfc3280.txt)/[5280](https://www.ietf.org/rfc/rfc5280.txt)) compliant [X.509 certificate](https://en.wikipedia.org/wiki/X.509) on the domain. For [ECDSA](https://en.wikipedia.org/wiki/ECDSA) certificates, only the P-256 curve is supported.

To add a domain to an API gateway:

{% list tabs group=instructions %}

- Management console {#console}

    1. Add a CNAME record to your DNS provider or to your own DNS server:
    
        ```text
        <domain> IN CNAME <API_gateway_service_domain>
        ```

        To find out an API gateway's service domain:

       1. Navigate to the [management console](https://console.yandex.cloud).
       1. Select the folder where the API gateway is located and go to **API Gateway**.
       1. Select the API gateway.
       1. You can see the service domain in the **Default domain** field.

        Domain names must end in a dot.

        To use a top-level domain or higher, delegate it to [Yandex Cloud DNS](../../dns/index.md) and create an [ANAME record](../../dns/operations/resource-record-create.md) in the DNS zone. You can create a record in Yandex Cloud DNS both before and after creating the domain. For more information, see step 6.

    1. In the [management console](https://console.yandex.cloud), select the folder containing the API gateway.

    1. Navigate to **Certificate Manager** and do the following:

        1. Add a [Let's Encrypt<sup>®</sup> certificate](../../certificate-manager/operations/managed/cert-create.md) or a [user certificate](../../certificate-manager/operations/import/cert-create.md) for the domain you are adding.

            {% note info %}

            Make sure to timely update your certificates. Learn more about updating [Let's Encrypt<sup>®</sup> certificates](../../certificate-manager/operations/managed/cert-update.md) and [custom certificates](../../certificate-manager/operations/import/cert-update.md).

            {% endnote %}

        1. Wait until the certificate status switches to `Issued`.
    
    1. Go back to the folder page.

    1. Navigate to **API Gateway** and do the following:

        1. Select the API gateway.
        1. Navigate to the **Domains** tab.
        1. Click **Attach**, select a certificate, and enter a domain name (FQDN).

    1. If you skipped step 1 and did not add a CNAME record, create an ANAME record in Yandex Cloud DNS:

        1. Click **Create record** in the domain row.
        1. If you do not have a DNS zone with the same name as the domain, create one. To do this, click **Create zone**.
        1. Select a different value in the **TTL (in seconds)** field, if required.
        1. Click **Create**.
        
- API {#api}

  To add a domain to an API gateway, use the [addDomain](../apigateway/api-ref/ApiGateway/addDomain.md) REST API method for the [ApiGateway](../apigateway/api-ref/ApiGateway/index.md) resource or the [ApiGatewayService/AddDomain](../apigateway/api-ref/grpc/ApiGateway/addDomain.md) gRPC API call.

{% endlist %}