We have a script that cleans up test users after QA cycles. It’s a simple Node.js script using the genesyscloud npm package. The goal is to remove the user so they don’t show up in the agent list, but we need to keep the interaction data for audit logs.
Here is the snippet we use:
const { UsersApi } = require('@genesyscloud/genesyscloud');
const usersApi = new UsersApi({ basePath: 'https://api.mypurecloud.com' });
async function deleteUser(userId) {
try {
await usersApi.deleteUser({
userId: userId,
removeInteractions: true // This is the default behavior I think?
});
console.log(`Deleted user ${userId}`);
} catch (error) {
console.error('Error:', error);
}
}
The documentation is a bit vague on what removeInteractions actually does. Does it delete the interaction records entirely, or just detach the user ID? If I set it to false, does the user stay active? We tried setting it to false and the user still appears in the UI as ‘Disabled’ but the interactions are gone from the search view. That’s not what we want.
We need the interactions to remain queryable by the original user ID. Is there a different endpoint or a specific flag I’m missing?
- Environment: US-East-1
- SDK: @genesyscloud/genesyscloud v8.2.0
- API Endpoint: DELETE /api/v2/users/{userId}
- Status: 204 No Content returned, but data seems lost