Update user attributes by external API


The Keycloak extension that I’m trying to develop is very dependend on external API (to which code I have also access to adn created some dedicated endpoints).
Keycloak is well adapted to receiving user data from external sources by implementing providers, but I have a problem with saving changes when user updates his profile.
The current solution I’ve implemented is based on AbstractUserAdapter implementation and setAttribute(String name, List values) function, which is called for each user attribute that has been modyfied.
In that function I send PATCH request to external API, so when user modify multiple attributes, we send multiple requests - and here is my main issue.
Also the external system, sometimes needs to update version of user consents (I resolved it by comparing versions and creating required action UPDATE_PROFILE and setting consent attributes to false when diffrent - user have to click them and they are updated).
But some consents are optional, so there is no change in user attributes when he not click them - that means no setAttribute() function will be done and no udpate to API sent.
I resolved it by creating EventListener and telling API to update versions every time, when UPDATE_PROFILE take place - new consent version is set to false.
But this brings another problem - when external API for example, has connection problems, user will be informed about successful profile update, but Keycloak has not saved to API.

Is there any solution that I can use after user profile modification, to update every user attribute at once by sending it to external API and still have the possibility to inform user that something went wrong if changes has throwed error?
Thanks for any help in advance!

Best Regards,