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

# Removing a domain

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder containing the API gateway.
  1. Navigate to **API Gateway**.
  1. Click the API gateway name.
  1. Navigate to the **Domains** tab.
  1. Click ![image](../../_assets/options.svg) in the domain row and select **Detach**.
  1. Confirm your action.
  1. Delete the resource record created when adding the domain to the API gateway:
      
      * If your domain is delegated to Cloud DNS:

        1. Navigate to **Cloud DNS**.
        1. Select the zone hosting the domain.
        1. Click ![image](../../_assets/options.svg) in the record row with the ![image](../../_assets/api-gateway/service-icon.svg) icon and select ![image](../../_assets/console-icons/trash-bin.svg) **Delete**.
        1. Confirm the deletion.

      * If a third-party DNS provider manages your domain, delete the record on the domain management page of your provider.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. View the description of the CLI command for removing a domain:

      ```bash
      yc serverless api-gateway remove-domain --help
      ```

  1. Run this command:

      ```bash
      yc serverless api-gateway remove-domain <API_gateway_ID> --domain-id <domain_ID>
      ```

  1. Delete the resource record created when adding the domain to the API gateway:
      
      * If your domain is delegated to Cloud DNS:

        1. Get a list of all records in the DNS zone by specifying the relevant zone ID:

            ```
            yc dns zone list-records <DNS_zone_ID>
            ```
        
            The record in question is of the `ANAME` type and has a value in `d5dm1lba80md********.i9******.apigw.yandexcloud.net` format.

        1. Delete the record:

            ```
            yc dns zone delete-records <DNS_zone_ID> \
              --record "<domain_name> <TTL> <record_type> <value>"
            ```

      * If a third-party DNS provider manages your domain, delete the record on the domain management page of your provider.

- API {#api}

  To remove a domain from an API gateway, use the [removeDomain](../apigateway/api-ref/ApiGateway/removeDomain.md) REST API method for the [ApiGateway](../apigateway/api-ref/ApiGateway/index.md) resource or the [ApiGatewayService/RemoveDomain](../apigateway/api-ref/grpc/ApiGateway/removeDomain.md) gRPC API call.

  Delete the resource record created when adding the domain to the API gateway:
      
  * If your domain is delegated to Cloud DNS, use the [updateRecordSets](../../dns/api-ref/DnsZone/updateRecordSets.md) REST API method for the [DnsZone](../../dns/api-ref/DnsZone/index.md) resource or the [DnsZoneService/UpdateRecordSets](../../dns/api-ref/grpc/DnsZone/updateRecordSets.md) gRPC API call.

  * If a third-party DNS provider manages your domain, delete the record on the domain management page of your provider.

{% endlist %}