Configuring DNS on the domain

After your API is deployed, users of your API need to access it through a domain name rather than an IP address. You can either:

  • Configure as the domain name (where PROJECT_ID is your Google Cloud project ID).
  • Or register your own domain name, such as, which entails:
    • Configuring DNS name servers (or using Cloud DNS).
    • Updating registry addresses.
    • Creating and maintaining DNS records.

    If you already have a DNS infrastructure, or you want to register your own domain name, see Serving an API from your domain name for more information.

This page describes how to configure Cloud Endpoints APIs to use as the domain name. The configuration steps on this page are applicable for APIs using OpenAPI running on Compute Engine, Google Kubernetes Engine, or Kubernetes. The domain name isn't supported for APIs running on App Engine. For APIs on App Engine, we recommend that you use as the Endpoints service name. When you deploy the API to App Engine, a DNS entry with a name in the format is created automatically.

The domain is managed by Google and shared by Google Cloud customers. Because Google Cloud projects are guaranteed to have a globally unique project ID, a domain name in the format is unique and can be used as the domain name for your API. Configuring the domain name is optional. If you prefer, you can register your own domain name.


As a starting point, this page assumes that you have already created your Cloud Endpoints API and deployed it to Compute Engine, Google Kubernetes Engine, or Kubernetes. If you need an API for testing, you can use one of the tutorials that walk you through configuring and deploying a sample API.

Configuring DNS

The following procedure describes how to configure DNS for Cloud Endpoints APIs that use .endpoints.[PROJECT_ID] as the Endpoints service name where [PROJECT_ID] represents your Google Cloud project ID. For convenience, the procedure refers to your OpenAPI configuration file as openapi.yaml.

To configure DNS:

  1. Open openapi.yaml, and add the x-google-endpoints field to the file as shown in the following snippet:
        swagger: "2.0"
        host: "[API_NAME].endpoints.[PROJECT_ID]"
        - name: "[API_NAME].endpoints.[PROJECT_ID]"
          target: "[IP_ADDRESS]"

    Typically, you configure the host field and the field to be the same. When you deploy your OpenAPI specification, the text specified in the host field is used as the name of your Endpoints service.

  2. Replace [API_NAME] with the name of your API (for example, bookstore or my-cool-api).
  3. Replace [PROJECT_ID] with your Google Cloud project ID.
  4. Replace [IP_ADDRESS] with an IPv4 address.

    For example, if you deploy your Endpoints API service to a Compute Engine virtual machine instance, you can use the external IP of that virtual machine. Alternatively, if you run your code on a group of virtual machine instances (or GKE pods) behind a load balancer, you can use the IP address of the load balancer.

  5. Deploy your new OpenAPI specification to Service Management using the following command:
    gcloud endpoints services deploy openapi.yaml

For example, if the following is specified in an openapi.yaml file:

    swagger: "2.0"
    host: ""
    - name: ""
      target: ""

When you deploy the openapi.yaml using the previous gcloud command, Service Management creates a DNS A-record,, which resolves to the target IP address, You might need to wait a few minutes for the new DNS configuration to propagate.

What's next