Save running configure to file

Hello!
I need solution to save haproxy configuration after change some parameters via socket API Is there way to save running config to file?