You just have to create the QueryExpression as you require for your audit search and it will delete those records that are obtained.
/// <summary>
/// Creates a BulkDelete job to delete audit record history for a
/// specific action and shows the job created.
/// </summary>
/// <param name="svc">IOrganizationService to use</param>
/// <param name="actionValue">The audit action value</param>
static void BulkDeleteAuditHistoryByAction(IOrganizationService svc, int actionValue)
{
Guid jobId;
var querySet = new QueryExpression(entityName: "audit");
querySet.Criteria.AddCondition(
attributeName: "action",
conditionOperator: ConditionOperator.Equal,
values: actionValue);
var req = new BulkDeleteRequest
{
QuerySet = new QueryExpression[] { querySet },
JobName = $"Bulk Delete of audit records with action = {actionValue}",
SendEmailNotification = false,
ToRecipients = new Guid[] { },
CCRecipients = new Guid[] { },
RecurrencePattern = string.Empty,
StartDateTime = DateTime.UtcNow
};
try
{
var resp = (BulkDeleteResponse)svc.Execute(req);
jobId = resp.JobId;
Entity bulkDeleteJob =
svc.Retrieve(
entityName: "asyncoperation",
id: jobId,
columnSet: new ColumnSet("name", "statecode", "statuscode"));
Console.WriteLine($"Job Name: {bulkDeleteJob["name"]}");
Console.WriteLine($"Job Id: {bulkDeleteJob.Id}");
Console.WriteLine($"State: {bulkDeleteJob.FormattedValues["statecode"]}");
Console.WriteLine($"Status: {bulkDeleteJob.FormattedValues["statuscode"]}");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
https://learn.microsoft.com/en-us/power-apps/developer/data-platform/auditing/delete-audit-data?tabs=sdk#use-bulkdelete-to-delete-audit-data