How to create a route from a route template ?

Dear all 

I want to create automatically a route using a route template, and start it before promotion between 2 states.

I know it was possible using tcl program and triggers, but is there existing java program , or just the link for the correct API ?

Regards