The API you're looking for in particular is https://developer.cisco.com/meraki/api-v1/#!update-device-management-interface and will give you a query something like this (this is using dual WAN on an MX64):
PUT /api/v1/devices/[SERIAL NUMBER]/managementInterface {"wan1":{"wanEnabled":"enabled","usingStaticIp":false,"vlan":null},"wan2":{"wanEnabled":"enabled","usingStaticIp":false,"vlan":null},"ddnsHostnames":{"activeDdnsHostname":"[NETWORK_NAME]-wired-[GENERATED-NAME].dynamic-m.com","ddnsHostnameWan1":"[NETWORK_NAME]-wired-[GENERATED-NAME]-1.dynamic-m.com","ddnsHostnameWan2":"[NETWORK_NAME]-wired-[GENERATED-NAME]-2.dynamic-m.com"}}