We’re cleaning up our tenant and need to remove a batch of terminated agents. The standard approach is using the users_api.delete_user method from the Python SDK. I’ve written a script to handle this, but I’m hitting a snag with data integrity.
Here’s the flow:
- Fetch user by email.
- Disable the user.
- Wait 24h (as per docs).
- Call
delete_user.
The deletion works fine. Returns 204 No Content. The problem is downstream. When we query interactions for a specific date range using the /api/v2/analytics/interactions/summary endpoint, the user_id field in the JSON payload for those historical interactions still references the deleted user’s UUID.
I expected the API to either:
a) Replace the UUID with a generic ‘Deleted User’ placeholder.
b) Return a 404 or null when I try to enrich that data by looking up the user details.
Instead, if I try to fetch the user details for that UUID after deletion, I get a 404. This breaks my reporting dashboard because it can’t resolve the agent name for those past interactions. Is there a specific flag or parameter in the delete_user call that handles this? Or am I supposed to soft-delete by just setting enabled to false and ignoring the record?
Code snippet for the deletion:
from genesyscloud.rest import ApiException
try:
api_response = users_api.delete_user(user_id=user_id, cascade=cascade)
print(f"Deleted user {user_id}")
except ApiException as e:
print(f"Exception when calling UsersApi->delete_user: {e}")
The cascade parameter is set to True, but it doesn’t seem to affect how the interaction history is stored or retrieved. We need those historical records to remain queryable with readable agent names, even if the user is gone. Any ideas on how to handle this without losing the link?