Search code examples
google-apigoogle-apps

Add a domain alias to a secondary domain using the Google Apps Domains API


I'm using Google Apps and I'm trying to add a domain alias to a secondary domain I own.

According to this Google Apps blog article "the [domains] API lets you programmatically add aliases for any domain, primary or secondary, but aliases for secondary domain can only be added via the API."

I tried the API on the APIs explorer (at the bottom of the page) but only managed to add a domain alias to my primary domain and not to my secondary.

Using a POST method I've tried:

{
 "domainName": "alias.domain.com",
 "domainAliases": [
  {
   "parentDomainName": "secondary.domain.com",
   "verified": true
  }
 ]
}

Any light on the matter would be greatly appreciated.

Regards,

Jo


Solution

  • You need to use the DomainAliases API:

    https://developers.google.com/admin-sdk/directory/v1/reference/domainAliases/insert

    From there enter:

    customer = your immutable ID
    domainAliasName = the alias to add
    parentDomainName = the secondary domain to which you want to add an alias
    

    That should be it.