DELETE /api/v2/users/{userId} causing 400 'User has active interactions' error

Trying to automate offboarding for terminated agents. The script needs to delete the user record via the REST API. I’m running into a hard stop with a 400 Bad Request.

The error payload is pretty clear:

{
 "code": "entity.in_use",
 "message": "User has active interactions",
 "status": 400,
 "messageParameters": {}
}

I understand the platform prevents deleting users with active data to preserve audit trails. The docs suggest deactivating first. I tried sending a PATCH to /api/v2/users/{userId} with "isActive": false before the DELETE. That part works. The status flips to inactive. But the subsequent DELETE still fails with the same error.

Is there a specific wait time required after deactivation? Or do I need to clear the user’s current state and end any lingering sessions via the API before the delete will stick? I’ve been trying to script this end-to-end without manual intervention in the admin portal.

Here is the sequence I’m running in Python:

  1. PATCH user to inactive.
  2. Wait 5 seconds.
  3. DELETE user.

Step 3 always bombs out. Checking the interaction endpoints for this user ID returns an empty list, so there shouldn’t be anything blocking it.