These instructions will allow you to change your google apps for business primary domain without writing an code...
- Open this page in a new tab: https://developers.google.com/admin-sdk/directory/v1/reference/customers/update
- Click Try It
- Make sure you’re logged into your relevant Google account (you should see your mail address in the top right corner).
- Next to customerKey type: my_customer
- Next to fields type: customerDomain
- Click next to ‘Request Body’, and in the –add a property– drop-down that appears, choose: customerDomain
- The following will magically appear: “customerDomain”:
- Type your secondary domain in the box next to “customerDomain”: (leave out the www. bit, just type in yourdomainname.com)
- Click Authorise and Execute
- Select the Default Scope
https://productforums.google.com/forum/#!topic/apps/5EcHKfRHRhw;context-place=forum/apps http://www.saysjen.com/swapping-your-google-apps-primary-domain-to-your-secondary-domain-for-dummies/
@vonpupp, you first need to enable API access from the SECURITY tab in the admin console.