# Method: projects.locations.products.purge

- [HTTP request](https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/projects.locations.products/purge#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/projects.locations.products/purge#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/projects.locations.products/purge#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/projects.locations.products/purge#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/projects.locations.products/purge#body.response_body)
- [Authorization Scopes](https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/projects.locations.products/purge#body.aspect)
- [ProductSetPurgeConfig](https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/projects.locations.products/purge#ProductSetPurgeConfig)
  - [JSON representation](https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/projects.locations.products/purge#ProductSetPurgeConfig.SCHEMA_REPRESENTATION)
- [Try it!](https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/projects.locations.products/purge#try-it)

Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet.

If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted.

It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted.

It's not possible to undo the products.purge operation. Therefore, it is recommended to keep the csv files used in productSets.import (if that was how you originally built the Product Set) before starting products.purge, in case you need to re-import the data after deletion.

If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the products.purge operation has finished for that ProductSet.

The `https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/Operation` API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)

### HTTP request

`POST https://vision.googleapis.com/v1p4beta1/{parent=projects/*/locations/*}/products:purge`

The URL uses [gRPC Transcoding](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto) syntax.

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. The project and location in which the Products should be deleted. Format is `projects/PROJECT_ID/locations/LOC_ID`. <br /> |

### Request body

The request body contains data with the following structure:

| JSON representation ||
|---|---|
| ``` { "force": boolean, // Union field `target` can be only one of the following: "productSetPurgeConfig": { object (`https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/projects.locations.products/purge#ProductSetPurgeConfig`) }, "deleteOrphanProducts": boolean // End of list of possible types for union field `target`. } ``` |

| Fields ||
|---|---|---|
| `force` | `boolean` The default value is false. Override this value to true to actually perform the purge. |
| Union field `target`. The Products to delete. `target` can be only one of the following: |||
| `productSetPurgeConfig` | ``object (`https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/projects.locations.products/purge#ProductSetPurgeConfig`)`` Specify which ProductSet contains the Products to be deleted. |
| `deleteOrphanProducts` | `boolean` If deleteOrphanProducts is true, all Products that are not in any ProductSet will be deleted. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/vision/docs/reference/rest/v1p4beta1/Operation`.

### Authorization Scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloud-platform`
- `https://www.googleapis.com/auth/cloud-vision`

For more information, see the [Authentication Overview](https://cloud.google.com/docs/authentication/).

## ProductSetPurgeConfig

Config to control which ProductSet contains the Products to be deleted.

| JSON representation ||
|---|---|
| ``` { "productSetId": string } ``` |

| Fields ||
|---|---|
| `productSetId` | `string` The ProductSet that contains the Products to delete. If a Product is a member of productSetId in addition to other ProductSets, the Product will still be deleted. |

## Try it!