Running into a weird behavior with the Users API. We have a cleanup job that runs nightly to remove terminated agents. Using the standard DELETE /api/v2/users/{id} endpoint. The call returns a clean 204 No Content. No errors. No warnings.
But when I check the reporting dashboard the next morning, all the interaction history for that user is gone. Calls, chats, everything. It’s not just hidden. It’s like the user never existed. We need the historical data for compliance audits. We can’t just wipe it.
I read the docs on user lifecycle. It mentions deactivating users. But there’s no PATCH /api/v2/users/{id} endpoint with a deactivate flag that keeps history. Or at least I can’t find one. The SDK method usersApi.deleteUser is pretty straightforward. No options to preserve history.
Here’s what I’m doing:
from nice_cxone import UsersApi
users_api = UsersApi(configuration)
try:
users_api.delete_user(user_id=agent_id)
print(f"User {agent_id} deleted.")
except Exception as e:
print(f"Error deleting user: {e}")
The response is always 204. But the data is gone. I tried adding a custom attribute to the user before deletion. Didn’t help. The history is tied to the user ID. If the user ID is gone, the history is orphaned or deleted.
Is there a way to delete the user but keep the interactions? Maybe soft delete? Or do I need to archive the data first? I can’t see an API endpoint for archiving user interactions. The /api/v2/analytics/interactions endpoint lets me query data, but not export or archive it.
We’re using the Python SDK v1.0.0. The timezone is America/Mexico_City. The cleanup job runs at 02:00 AM CST. The data disappears immediately after the delete call. No delay.
Any ideas? I don’t want to build a custom archive system if there’s a built-in way to handle this. The docs are silent on this. Or maybe I’m missing a step. Is there a retention policy setting I can change via API? I checked the admin UI. No obvious setting for this. Just a switch for ‘Allow users to be deleted’. That’s it.