Hi Sachin,
In that case, I would indeed recommend having the button trigger a process and run the API call within that process. Provide the attempt number as input to the process (set to zero on the initial call).
If the API returns an error code, you can use that code to determine if you want to do a retry (as Kilian mentioned, it does not always make sense to try again). If the error code/message warrants a retry, increase the input attempt number and use it as an input for the next trigger of the process. Finally, before calling the process again, you should implement some logic to check if the maximum number of retries has been reached.