We have a cleanup script running in our node backend that prunes inactive users from the Genesys Cloud instance. The goal is to remove access immediately but keep the interaction history (voice, chat, etc.) intact for compliance reporting.
Currently, the script sends a DELETE request to /api/v2/users/{id}. It returns a 204 No Content, which is expected. The user is gone from the active directory view. However, when we pull analytics data for a queue where that user was previously assigned, the agentId field in the interaction records is still there, but the agentName is null or shows as ‘Deleted User’.
Here is the snippet handling the deletion:
const response = await platformClient.users.deleteUser(userId);
console.log(`User ${userId} deleted. Status: ${response.statusCode}`);
The issue is that downstream dashboards break because they join on the user object which no longer exists. I read somewhere that simply deleting the user might orphan the data in a way that makes it hard to attribute interactions later.
Is there a specific API flag or a different endpoint I should use to ‘archive’ or ‘disable’ the user instead of a hard delete? Or is the standard practice to just keep the user object and set enabled to false via a PATCH request to /api/v2/users/{id}? I want to make sure I’m not violating any retention policies by keeping disabled accounts around indefinitely.
Also, does the DELETE endpoint have any cascading effects on group memberships or role assignments that I should be catching with try/catch blocks before calling it?