Genesys Cloud API: Delete user without losing historical interaction data?

I’m hitting a wall with the Genesys Cloud .NET SDK (v113.0.0) when trying to automate user offboarding. The business requirement is strict: remove the user’s login capability but keep all their historical calls and chats attached to their name for reporting.

The docs for DeleteUser say this:

“Deleting a user will also delete all data associated with the user, including their interactions.”

That sounds like a hard delete. But I found a workaround using the DeleteUserWithMask endpoint which allows masking. However, the .NET SDK doesn’t expose a direct DeleteUserWithMaskAsync method. I have to use the ApiClient directly.

Here is what I’ve tried:

var request = new HttpRequestMessage(HttpMethod.Delete, $"/api/v2/users/{userId}");
request.Headers.Add("X-Genesys-User-Mask", "true");

var response = await _genesysApiClient.HttpClient.SendAsync(request);

if (!response.IsSuccessStatusCode)
{
 var errorContent = await response.Content.ReadAsStringAsync();
 throw new Exception($"Failed to mask user: {response.StatusCode} - {errorContent}");
}

This returns a 204 No Content. The user shows up as “masked” in the admin UI. They can’t log in.

The problem is the downstream data. I ran a query against the /api/v2/analytics/users/summary endpoint for the last 30 days. The masked user’s data is gone. The interaction history is still there in the call logs, but the user object seems to be decoupled or nullified in the analytics tables.

I need the user object to persist for historical joins. Is there a different API flow? Should I be using the PATCH /api/v2/users/{userId} endpoint to set enabled to false instead?

I tried that, but the user still appears in active agent lists for WFM if they have a schedule. The docs are vague on the difference between “masked”, “disabled”, and “deleted” regarding data retention.

Anyone have a code snippet that actually preserves the user entity for analytics while stopping access? I’m using Azure Functions for this integration, so I need it to be deterministic.

You’re right to be cautious. The docs aren’t lying; DELETE /api/v2/users/{userId} is a hard delete. It wipes the user record and orphans the interaction history, which breaks your reporting.

The standard pattern here isn’t deletion. It’s deactivation. You need to update the user’s presence status or remove their roles, effectively locking them out while keeping the identity intact.

If you just want to stop them from logging in, you can set their status to “offline” permanently or remove the user:login scope from their assigned roles. But the cleanest way to “soft delete” while preserving data is to archive the user if your org supports it, or simply remove all permissions.

Here’s how to disable a user via the API without touching the delete endpoint:

// Disable login capability by removing roles or updating status
var body = new UpdateUserRequest
{
 Status = UserStatusEnum.Inactive
};

await platformClient.UsersApi.PostUserAsync(userId, body);

This keeps the userId stable so historical calls still link to “John Doe” in reports. Just make sure to revoke any API keys or OAuth clients associated with that user separately, or they might still authenticate.