Deleting Genesys Cloud user via API without nuking historical data?

I’m running a Terraform script to clean up some stale test accounts using the genesyscloud_user resource, but I’m hitting a wall with the genesyscloud_platformapi_user_api.DeleteUser method. The goal is to remove the user from active provisioning while keeping their chat and voice history intact for compliance audits. When I call the delete endpoint, the user gets marked as deleted, but the associated interaction logs seem to lose the user context or get archived in a way that breaks our downstream reporting queries.

I’ve tried setting the deleteUser flag to false in the API call, but it just returns a 400 Bad Request saying the user must be deleted to proceed. Is there a specific header or parameter I’m missing to preserve the historical data link? Here’s the payload I’m sending:

{
 "deleteUser": false
}

The response is just a generic error. I need to know if this is even possible via the REST API or if I have to use a different endpoint to soft-delete the user without touching the interaction history.

You’re hitting the expected behavior for a hard delete. The DELETE /api/v2/users/{userId} endpoint removes the resource entirely from the provisioning layer. Once that user ID is gone, any downstream analytics or interaction logs that rely on that foreign key will either break or lose context. It’s a common gotcha when automating cleanup with Terraform.

Don’t delete the user. Patch them instead.

Use PATCH /api/v2/users/{userId} to set the status to inactive or off. This keeps the user object in the database, preserving the ID reference for historical data, while removing their ability to log in or receive calls.

Here’s the payload you need:

{
 "status": "off",
 "statusUpdatedTime": "2023-10-27T14:00:00.000Z",
 "name": "Test User (Disabled)"
}

If you’re using the Python SDK, it looks like this:

from genesyscloud.platform_client import PlatformClient

genesys = PlatformClient.create_instance()
user_id = "your-user-id-here"

body = {
 "status": "off"
}

# Update the user status
genesys.Users.update_user(user_id, body=body)

This approach maintains referential integrity. Your New Relic dashboards pulling from the Analytics API will still see the userId field populated in the interaction history. You can filter by status: off in your queries if you need to exclude inactive users from current metrics, but the historical record remains intact.

Also, check if you need to remove them from specific routing queues or wrap-up codes before deactivating. Leaving them in active queues might cause unexpected routing behavior even if their status is off.