You’ll need to GET the goal (http://api.beeminder.com/#getgoal), then build an updated
roadall, then PUT the updated values for the goal (http://api.beeminder.com/#putgoal).
roadall is an array of (date, value, rate) triples, meaning "on date X, the value for the road was Y, and changing at rate Z from then on.) So you’ll need to do a fair bit of calculation to figure out how to munge it in order to leave you with the exact amount of safety buffer you want, but it’s not impossible.
Unfortunately, while you can replicate it this way, there isn’t (to the best of my knowledge) an API that directly just retroratchets a goal. I doubt, however, that as @openmedi says it’s because this is a feature reserved for certain premium plans: the road editor is also reserved for the same premium plans, and the API has features to directly replicate what the road editor can do.