Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.
HTTP request
POST https://discoveryengine.googleapis.com/v1alpha/{parent=projects/*/locations/*/dataStores/*}/userEvents:purge
Required. The resource name of the catalog under which the events are created. The format is projects/{project}/locations/global/collections/{collection}/dataStores/{dataStore}.
Request body
The request body contains data with the following structure:
JSON representation
{"filter": string,"force": boolean}
Fields
filter
string
Required. The filter string to specify the events to be deleted with a length limit of 5,000 characters. The eligible fields for filtering are:
userPseudoId: Double quoted string. Specifying this will delete all events associated with a visitor.
userId: Double quoted string. Specifying this will delete all events associated with a user.
Note: This API only supports purging a max range of 30 days.
Examples:
Deleting all events in a time range: eventTime > "2012-04-23T18:25:43.511Z"
eventTime < "2012-04-23T18:30:43.511Z"
Deleting specific eventType in a time range: eventTime > "2012-04-23T18:25:43.511Z"
eventTime < "2012-04-23T18:30:43.511Z" eventType = "search"
Deleting all events for a specific visitor in a time range: eventTime > "2012-04-23T18:25:43.511Z"
eventTime < "2012-04-23T18:30:43.511Z" userPseudoId = "visitor1024"
Deleting the past 30 days of events inside a DataStore: *
The filtering fields are assumed to have an implicit AND.
force
boolean
The force field is currently not supported. Purge user event requests will permanently delete all purgeable events. Once the development is complete: If force is set to false, the method will return the expected purge count without deleting any user events. This field will default to false if not included in the request.
Response body
If successful, the response body contains an instance of Operation.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-27 UTC."],[[["\u003cp\u003eThis API operation permanently deletes user events based on a provided filter, which can take a significant amount of time to complete depending on the number of events.\u003c/p\u003e\n"],["\u003cp\u003eThe HTTP request is a \u003ccode\u003ePOST\u003c/code\u003e operation to the specified URL, using gRPC Transcoding syntax, and requires a \u003ccode\u003eparent\u003c/code\u003e path parameter indicating the resource name of the data store.\u003c/p\u003e\n"],["\u003cp\u003eThe request body accepts a JSON structure containing a \u003ccode\u003efilter\u003c/code\u003e string to specify events for deletion and a \u003ccode\u003eforce\u003c/code\u003e boolean field (currently not supported).\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003efilter\u003c/code\u003e string supports filtering by \u003ccode\u003eeventType\u003c/code\u003e, \u003ccode\u003eeventTime\u003c/code\u003e, \u003ccode\u003euserPseudoId\u003c/code\u003e, and \u003ccode\u003euserId\u003c/code\u003e, with a maximum length of 5,000 characters and a 30-day time range limit.\u003c/p\u003e\n"],["\u003cp\u003eThe operation requires the OAuth scope \u003ccode\u003ehttps://www.googleapis.com/auth/cloud-platform\u003c/code\u003e and the IAM permission \u003ccode\u003ediscoveryengine.userEvents.purge\u003c/code\u003e on the parent resource.\u003c/p\u003e\n"]]],[],null,["# Method: projects.locations.dataStores.userEvents.purge\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [IAM Permissions](#body.aspect_1)\n\nDeletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.\n\n### HTTP request\n\n`POST https://discoveryengine.googleapis.com/v1alpha/{parent=projects/*/locations/*/dataStores/*}/userEvents:purge`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n### Request body\n\nThe request body contains data with the following structure:\n\n### Response body\n\nIf successful, the response body contains an instance of [Operation](/generative-ai-app-builder/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation).\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/cloud-platform`\n\nFor more information, see the [Authentication Overview](/docs/authentication#authorization-gcp).\n\n### IAM Permissions\n\nRequires the following [IAM](https://cloud.google.com/iam/docs) permission on the `parent` resource:\n\n- `discoveryengine.userEvents.purge`\n\nFor more information, see the [IAM documentation](https://cloud.google.com/iam/docs)."]]