9.4.1. User Notification Handler Module

The user notification handler module is used to send emails token owners or administrators in case of any event. Possible Actions sendmail

The sendmail action sends an email to the tokenowner user. The email is sent, if an administrator managed the users token.



  • optional

The subject line of the mail that is sent. sendsms

The sendsms action sends an SMS to the tokenowner. The SMS is sent, if an administrator managed the users token.


  • required Option
  • The SMS Gateway configuration. Options for both actions

Both actions sendmail and sendsms take several common options.


  • optional

Here the administartor can specify the body of the email, that is sent. The body may contain the following tags

  • {admin} name of the logged in user.
  • {realm} realm of the logged in user.
  • {action} the action that the logged in user performed.
  • {serial} the serial number of the token.
  • {url} the URL of the privacyIDEA system.
  • {user} the given name of the token owner.
  • {givenname} the given name of the token owner.
  • {surname} the surname of the token owner.
  • {username} the loginname of the token owner.
  • {userrealm} the realm of the token owner.
  • {tokentype} the type of the token.
  • {registrationcode} the registration code in the detail response.
  • {recipient_givenname} the given name of the recipient.
  • {recipient_surname} the surname of the recipient.


  • required

This specifies to which type of user the notification should be sent. Possible recipient types are:

  • token owner,
  • logged in user,
  • admin realm,
  • internal admin,
  • email address.

Depending on the recipient type you can enter additional information. The recipient type email takes a comma separated list of email addresses. Code

This is the event handler module for user notifications. It can be bound to each event and can perform the action:

  • sendmail: Send an email to the user/token owner
  • sendsms: We can also notify the user with an SMS.

The module is tested in tests/test_lib_events.py

class privacyidea.lib.eventhandler.usernotification.NOTIFY_TYPE[source]

Allowed token owner

ADMIN_REALM = 'admin realm'
EMAIL = 'email'
INTERNAL_ADMIN = 'internal admin'
LOGGED_IN_USER = 'logged_in_user'
TOKENOWNER = 'tokenowner'
class privacyidea.lib.eventhandler.usernotification.UserNotificationEventHandler[source]

An Eventhandler needs to return a list of actions, which it can handle.

It also returns a list of allowed action and conditions

It returns an identifier, which can be used in the eventhandlig definitions


This method returns a dictionary of allowed actions and possible options in this handler module.

Returns:dict with actions
description = 'This eventhandler notifies the user about actions on his tokens'
do(action, options=None)[source]

This method executes the defined action in the given event.

  • action
  • options (dict) – Contains the flask parameters g, request, response and the handler_def configuration

identifier = 'UserNotification'