A Keycloak extension that listens for user events (create, update, delete, register, login, logout, verify email, etc.) and forwards them to your webhook.
CREATEDUPDATEDDELETEDLOGINLOGOUTVERIFY_EMAIL
# Clone the repository
git clone https://github.com/huynxtb/keycloak-user-event-listener.git
cd keycloak-user-event-listener
# Copy example environment file
cp .env.sample .env
# Edit .env and set your WEBHOOK_URL
# Build the extension
mvn clean package
# Copy JAR to Keycloak providers
cp target/keycloak-user-event-listener.jar providers/docker-compose up -d# Copy example environment file
cp .env.sample .env
# Edit .env and update the WEBHOOK_URL
# Example:
# WEBHOOK_URL=https://your-webhook.com/endpointmvn clean package# Create providers directory if it doesn't exist
mkdir -p keycloak/providers
# Copy JAR to providers directory
cp target/keycloak-user-event-listener.jar keycloak/providers/- Access Keycloak Admin Console (default: http://localhost:8080)
- Log in as admin (default credentials: admin/123456789Aa)
- Create a new realm

- Navigate to:
- Add
keycloak-user-event-listener

- Save
- Ensure your webhook endpoint is publicly accessible
- Configure the
WEBHOOK_URLin the.envordocker-compose.yamlfile
You can use services like webhook.site to test the webhook integration:
- Get a temporary webhook URL from webhook.site
- Add it to your
.envfile - Create a user in Keycloak
- Check the webhook.site dashboard for the event data
Note: In this test, webhook.site is used.
-
Go to Users
-
Add User
-
Fill in the required fields
-
Check your webhook endpoint for the notification on webhook.site

-
The JSON response will look like:
{
"action": "CREATED",
"realmId": "e777f408-8f4e-4d90-ad9f-8dd1ffc40607",
"realmName": "keycloak-user-event-realm",
"id": "96a32d95-ee36-4f2b-8990-ac0c782d6c36",
"username": "admin",
"email": "admin@gmail.com",
"emailVerified": false,
"enabled": true,
"ipAddress": "172.18.0.1",
"createdTimestamp": 1753233395093,
"roles": [
"default-roles-keycloak-user-event-realm"
],
"attributes": [
{
"key": "firstName",
"value": "XUAN HUY"
},
{
"key": "lastName",
"value": "NGUYEN"
},
{
"key": "email",
"value": "admin@gmail.com"
},
{
"key": "username",
"value": "admin."
}
],
"groups": []
}Events for UPDATED, DELETED, LOGIN, LOGOUT, and VERIFY_EMAIL will have similar payloads with the corresponding action value.
-
Webhook not receiving events
- Check if the
WEBHOOK_URLin.envis correct - Verify the event listener is enabled in Keycloak
- Check Keycloak logs for any errors
- Check if the
-
Build failures
- Ensure Maven is installed
- Check Java version (requires Java 11+)
# View Keycloak logs
docker-compose logs -f keycloakPull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.


