Deleting a user via API: how to preserve historical interaction data?

We’re running a cleanup job to remove terminated agents from our CXone instance using the REST API. The goal is to delete the user record but keep the interaction history intact for compliance reporting.

I’m using the standard delete endpoint:

DELETE /api/v2/users/{userId}

The call returns 200 OK, which confirms the user is removed. However, when I query the analytics later, the agent name on past calls shows up as ‘Unknown User’. The interaction data isn’t gone, but the link to the user profile is broken.

I checked the response headers and the request body. There’s no flag like preserveHistory=true in the docs. I tried updating the user status to inactive first, then deleting, but the result is the same. The historical data loses the user reference.

Is there a specific header or query parameter to keep the user metadata linked to past interactions? Or do I need to export the data before deleting the user?

We’ve tried archiving the user first, but that doesn’t stop the name from disappearing on old records.

Deleting the user record is the problem. The API call DELETE /api/v2/users/{userId} hard-deletes the identity. Analytics joins on the user ID, so once that ID is gone, the name resolves to ‘Unknown’. You don’t need to delete the user to remove access. Just deactivate them. It keeps the ID alive for historical reports but blocks login.

PUT /api/v2/users/{userId}
Content-Type: application/json

{
 "enabled": false
}

This is the standard move for terminated agents. The user stays in the system as a ghost record. Analytics keeps the name. Compliance stays happy. If you truly need to purge PII, that’s a different workflow involving data retention policies, but for simple cleanup, disabling is safer. Don’t delete unless you want broken reports.