The AnyPoint CLI has API-contract-specific commands that could make this into a very simple script. You could also try building a script by studying the API Manager Experience API or reverse engineering this through building a script with browser dev tools.