--- sidebar_label: 'Handling user accounts' sidebar_position: 2 --- # Handling user accounts When a new user account is registered in Future Ordering, the most common approach for integrating external loyalty systems is to create and maintain an internal representation of this account. Any changes to the user account after registration should also be reflected in the external system. To achieve this, it is recommended to subscribe and react to some of the available user related events. :::info See the [event reference](/events) for a complete description of user related events. ::: ## Adding user accounts Subscribe to the `user.created` or `user.logged_in` events to know when to add a user account to your loyalty system. Use the [get user](/api#tag/Users/operation/get-user) endpoint to retrieve additional user data after receiving the event. :::info Before adding a user to your external loyalty system, make sure that the account is of a desirable account type and that it has not been deleted. For more information, refer to the guides on [account types](../users/account-types) and [account deletion](../users/account-lifetime#account-deletion). ::: ## Updating user accounts Subscribe to the `user.updated` and `user.communication_preferences.updated` events to know when to update the user's information and [communication preferences](#respecting-communication-preferences). Use the [get user](/api#tag/Users/operation/get-user) and [get user communication preferences](/api#tag/Communication-Preferences/operation/652797ec494955f323831b7c) endpoints to retrieve additional user data after receiving the events. ## Removing user accounts Subscribe to the `user.deletion_requested` event to know when to remove a user and their associated data from the external loyalty system. :::warning It is important that `user.deletion_requested` events are respected and that the affected user's personal data is properly removed from any external systems within a reasonable amount of time after the event has been received. Continued storage of a user's personal data after account deletion has been requested might be in violation of local data protection or privacy regulations. ::: ## Respecting communication preferences When communicating with the user outside of Future Ordering, make sure to respect the user's communication preferences. Refer to the guide on [user communication preferences](../users/communication-preferences) for more information. ## Age requirements It is common for loyalty systems or regulation to impose requirements on a user's age before enabling loyalty functionality. For these purposes, Future Ordering supports enabling a required `birthdate` field for registered users. :::info For more information on the birthdate field, please contact [support@futureordering.com](mailto:support@futureordering.com). ::: ## Example: External loyalty system integration The following diagram describes the user account handling processes when integrating an external loyalty system and exemplifies some of the interactions between systems: ```mermaid sequenceDiagram actor user as User participant fo as Future Ordering participant loyint as Loyalty Integration participant loy as Loyalty System user ->> fo: Create user fo->>loyint: (Event) user.created loyint-->>fo: 202 Accepted loyint->>loyint: Process event loyint->>fo: Get user information + communication preferences loyint->>loy: Create user in loyalty system note over user: Alternative: React on user log in event to create user user ->> fo: User logged in fo->>loyint: (Event) user.logged_in loyint-->>fo: 202 Accepted loyint->>loyint: Process event loyint->>fo: Get user information loyint->>fo: Get user communication preferences loyint->>loy: Create user in loyalty system note over user: User information updated user ->> fo: User information updated fo->>loyint: (Event) user.updated loyint-->>fo: 202 Accepted loyint->>loyint: Process event loyint->>fo: Get user information loyint->>loy: Update user information in loyalty system note over user: User communication preferences updated user ->> fo: User updated communication preferences fo->>loyint: (Event) user.communication_preferences.updated loyint-->>fo: 202 Accepted loyint->>loyint: Process event loyint->>fo: Get user communication preferences loyint->>loy: Update user communication preferences in loyalty system note over user: User is ending the account - user can not longer login, FO deletes personal data after x days. user ->> fo: User ends the account fo->>loyint: (Event) user.deletion_requested loyint-->>fo: 202 Accepted loyint->>loyint: Process event loyint->>loy: Delete user in loyalty system ```