User creation through Keycloak REST API doesn't produce REGISTER event for SPI

I want to call an external REST-API, when a new user has been registered in keycloak. The REST call should create a minimal user entity in my spring backend (which has its own db). When the REST call fails, it should abort the register process, so I can’t miss register events on the spring side.

What I found out was that Keycloak supports custom SPI’s, where I can listen to those kinds of events and act with custom Java code to it. Sounded like a perfect fit for my use case. But after implementing a poc, I noticed that the event is only fired when a registration is done through the register page (Keycloak UI). Since I’m implementing a mobile app, I want to do the registration process through the REST API with my own native UI (Android/iOS).

How I created the user via REST Api: Keycloak REST API: Create a New User - Apps Developer Blog

SPI Code which I followed next to the Keycloak: keycloak-extensions/ at master · zonaut/keycloak-extensions · GitHub

Are these events really only fired when you use the UI or did I miss something?

Thank your very very much for any help !

Yes, a REGISTER event is only called when the user self-registers using the UI. Using the API or Admin UI, the admin event (OperationType.CREATE, ResourceType.USER) is fired. I have a base EventListener class here for catching both: keycloak-events/ at main · p2-inc/keycloak-events · GitHub
Please note that this has not been tested with users added via Identity/Federated Providers, and it may not catch the appropriate events for those.

Thank you very much ! That helped a lot