
Hi everyone,
I’m working with the Dynamics Web API and am looking for a way to query deleted objects, such as opportunities. While I know that the audits entity
(api/data/v9.1/audits$filter=action+eq+3+and+objecttypecode+eq+opportunity)
can be used to query deletion objects.
I’m wondering if there are any other methods or API endpoints available to directly query or filter deleted records.
Thanks in advance!
You're right, the audits entity is the primary way to track deletions in Dynamics 365 (Dataverse) via the Web API. However, there isn't a dedicated, direct API endpoint or filter to retrieve only deleted records without resorting to the audit logs.
Here's a breakdown of why and what alternatives you have:
Why No Direct Endpoint?
statecode is set to 2 for inactive).Alternatives and Considerations:
audits Entity (Most Common):
audits entity using action eq 3 (delete) and objecttypecode eq [entity type code] (e.g., 4 for opportunities).objectid field in the audits entity contains the GUID of the deleted record.[your-org-url]/api/data/v9.1/audits?$filter=action eq 3 and objecttypecode eq
true.true.Recommendations:
audits entity is the most reliable and supported way to query deleted records using the Web API.By using the audits entity and carefully filtering the results, you can retrieve the deleted records you need.