I'm interested in why you'd want to do this? Using the API implies a significant scale: lots of MXes configured as Hubs. Given the quantity of tunnels you end up with, with a full mesh of Hubs, for example, these things often don't go well together. If you only have a handful of Hubs (i.e. you use Hub and Spoke setup - which is what's recommended, in order to scale, generally) you'd normally configure each of them through the UI.