Just noticed that deleting a user via the API seems to orphan their historical conversation data. I need to remove a terminated agent but keep their past interactions intact for audit trails.
client.users_api.delete_user(user_id)
The call returns 204 No Content, but querying interactions by that user_id later yields empty results. Is there a soft delete flag or specific header to preserve historical linkage?
Does the users_api have a parameter to archive rather than hard delete, or must I use the archived_user endpoint instead?
Take a look at at deactivating the user instead of deleting them to preserve historical data integrity. The API supports a soft delete pattern via the user management endpoint which retains interaction links.
I normally fix this by orchestrating the status change via MuleSoft to ensure the status field is explicitly set to inactive before any downstream cleanup jobs run. This preserves the foreign keys in the interaction archive. See the official docs here: https://developer.genesys.cloud/api/v2/users/put_user
Have you tried deactivating instead? Cause: Hard deletes remove user entities, breaking foreign key references in Interaction archives. Solution: Use the JS SDK to patch the status.
Ah, yeah, this is a known issue… The hard delete endpoint /api/v2/users/{userId} permanently removes the user entity, which breaks foreign key references in the Interaction archive. Your data is not lost, but the link to the user_id is severed. The suggestions above regarding deactivation are correct. I usually implement this via my Python wrapper by updating the user status to inactive instead of deleting. This preserves the audit trail while revoking access. Here is the exact call using the official SDK.
from platformclientv2.models.user import User
# Deactivate user to preserve historical interaction links
client.users_api.put_user(
user_id="your-user-id",
body=User(body_status="inactive", body_email="[email protected]")
)
Do not use delete_user if you need to query interactions by agent later. The inactive status keeps the user object alive in the database, maintaining referential integrity for historical reports.