We are building an automated offboarding script using the Genesys Cloud Python SDK to handle user lifecycle management. The goal is to remove inactive users from the platform while preserving their historical interaction data for compliance and New Relic custom event tracking.
The current implementation uses delete_users_user from the SDK. Here is the relevant snippet:
from genesyscloud import users_api_client
try:
api_response = users_api_client.delete_users_user(
user_id=user_id,
soft_delete=True
)
except Exception as e:
print(f"Deletion failed for {user_id}: {e}")
When soft_delete=True, the user status changes to ‘deleted’ in the UI, which seems correct. However, we are noticing that subsequent queries to the conversations API for interactions associated with this user ID sometimes return inconsistent results or fail to link the deleted user profile correctly in our downstream analytics.
We need to ensure that the user record is removed from active provisioning but the userId remains valid as a foreign key in historical conversation logs. Is there a specific sequence of API calls or a different endpoint we should use to archive the user data before deletion? We want to avoid data loss in our NRQL dashboards that aggregate metrics by userId.
Also, does the delete_users_user method support batch operations? We have about 500 users to process monthly, and making individual HTTP requests is hitting our rate limits quickly. We tried using the batch endpoint but got a 400 Bad Request error on the payload structure.
Any insights on the best practice for this? We want to keep the historical data intact while cleaning up the active user list.