Programatically create inbound / outbound route

Hello. My voip provider - flowroute - allows you to use their api to register a DID. Thats the easy part. Now that I have a DID registered, I need to tell my freepbx box to add this outbound route, and create an inbound route with a default user and destination.

Is there any way to do this in an automated way. I am open to having a program write to the conf files if need be. But ideally there would be a more integrated approach.