That’s what I’m trying to communicate (poorly). The second machine will have no idea about the return code of the first machine’s action.
Your API needs to send an action to the first machine, wait for the action to complete, get the action’s return code, and then issue a new action to the second machine if the first machine was successful.
This is one of the things that Server Automation can do for you, but if you don’t have Server Automation you’d need your own API utility to do it.