You can verify a specific domain or all authentication domains you have
registered with Postmaster Tools.

## Verify a specific domain

To verify a specific domain, call
[`domains.get()`](https://developers.google.com/workspace/gmail/postmaster/reference/rest/v2/domains/get)
with the name of the domain. Following is a code sample showing how to verify a
specific domain:

### Java

    /**
     * Gets a specific domain registered by the client.
     *
     * @param service Authorized Gmail PostmasterTools API instance.
     * @param domainName The fully qualified domain name.
     * @return The domain.
     * @throws IOException if an error occurs.
     */
    public static Domain getDomain(
        PostmasterTools service, String domainName) throws IOException {
      String query = String.format("domains/%s", domainName);
      Domain domain = service.domains().get(query).execute();
      System.out.println(domain.toPrettyString());
      return domain;
    }

### Python

    def get_domain(service, domain_name):
      """Gets a specific domain registered by the client.

      Args:
        service: Authorized Gmail PostmasterTools API instance.
        domain_name: The fully qualified domain name.

      Returns:
        The domain.
      """
      try:
        query = 'domains/' + domain_name
        domain = service.domains().get(name=query).execute()
        print(domain)
        return domain
      except errors.HttpError as err:
        print(f'An error occurred: {err}')

## Verify all domains

To verify all domains, call
[`domains.list()`](https://developers.google.com/workspace/gmail/postmaster/reference/rest/v2/domains/list).
Following is a code sample showing how to verify all domains:

### Java

    /**
     * Lists the domains that have been registered by the client.
     *
     * @param service Authorized Gmail PostmasterTools API instance.
     * @return Response message for ListDomains.
     * @throws IOException if an error occurs.
     */
    public static ListDomainsResponse listDomains(
        PostmasterTools service) throws IOException {
      ListDomainsResponse listDomainsResponse =
          service.domains().list().execute();
      for (Domain domain : listDomainsResponse.getDomains()) {
        System.out.println(domain.toPrettyString());
      }
      return listDomainsResponse;
    }

### Python

    def list_domains(service):
      """Lists the domains that have been registered by the client.

      Args:
        service: Authorized Gmail PostmasterTools API instance.

      Returns:
        Response message for ListDomains.
      """
      try:
        domains = service.domains().list().execute()
        if not domains:
          print('No domains found.')
        else:
          print('Domains:')
          for domain in domains.get('domains', []):
            print(domain)
        return domains
      except errors.HttpError as err:
        print(f'An error occurred: {err}')