Help for in-game terrain editor

I would like to have an ingame terrain editor like Age of Empire.
Do any you know what API or example I can use.

Thanks