Deleting Products from Marqo
This guide shows you how to delete product documents from your Marqo ecommerce search index. Learn how to remove specific products by ID or completely reset your index.
Prerequisites
- A Marqo Cloud account (sign up here)
- Your Marqo API key (find your API key guide)
- An existing ecommerce index with products (add products guide)
Delete Documents by ID
Remove specific product documents by making a DELETE /documents
request with an ids
array in the request body.
Endpoint: DELETE https://ecom.marqo-ep.ai/api/v1/indexes/{index_name}/documents
Request Body:
{
"ids": ["43207430723", "43207430724", "43207430725"]
}
Single Product Deletion
Delete one product by providing a single ID in the ids
array:
{
"ids": ["43207430723"]
}
Batch Product Deletion
Delete multiple products by providing multiple IDs:
{
"ids": ["43207430723", "43207430724", "43207430725", "43208765432"]
}
Single Product Deletion
Delete one specific product by providing its ID:
curl -X DELETE https://ecom.marqo-ep.ai/api/v1/indexes/{index_name}/documents \
-H "Authorization: Bearer {api_key}" \
-H "Content-Type: application/json" \
-d '{"ids": ["43207430723"]}'
Batch Product Deletion
Delete multiple products efficiently in a single request:
# Delete multiple products
curl -X DELETE https://ecom.marqo-ep.ai/api/v1/indexes/{index_name}/documents \
-H "Authorization: Bearer {api_key}" \
-H "Content-Type: application/json" \
-d '{"ids": ["43207430723", "43207430724", "43207430725", "43208765432"]}'
# Delete product variants
curl -X DELETE https://ecom.marqo-ep.ai/api/v1/indexes/{index_name}/documents \
-H "Authorization: Bearer {api_key}" \
-H "Content-Type: application/json" \
-d '{"ids": ["43207430726", "43207430727", "43207430728"]}'
Note: Replace {index_name}
with your actual index name and {api_key}
with your API key.
Deletion Response
The response provides detailed information about the deletion operation:
{
"details": {
"deletedDocuments": 2,
"receivedDocumentIds": 2
},
"items": [
{"_id": "43207430723", "result": "deleted", "status": 200},
{"_id": "43207430724", "result": "deleted", "status": 200}
]
}
Response Fields
Field Name | Type | Description |
---|---|---|
details.deletedDocuments |
Integer | Number of documents successfully deleted |
details.receivedDocumentIds |
Integer | Number of document IDs received in the request |
items |
Array | Status of each individual document deletion |
items[].\_id |
String | The ID of the document |
items[].result |
String | Result of the deletion operation |
items[].status |
Integer | HTTP status code for this specific deletion |
Status Codes
Status Code | Description |
---|---|
200 |
Document successfully deleted |
404 |
Document with the specified ID was not found |
400 |
Bad request (invalid ID format) |
500 |
Internal error |
Common Deletion Scenarios
Product Discontinuation
Remove discontinued products from your catalog:
curl -X DELETE https://ecom.marqo-ep.ai/api/v1/indexes/{index_name}/documents \
-H "Authorization: Bearer {api_key}" \
-H "Content-Type: application/json" \
-d '{"ids": ["43209876543", "43209876544", "43209876545"]}'
Variant Management
Remove specific variants while keeping the parent product:
curl -X DELETE https://ecom.marqo-ep.ai/api/v1/indexes/{index_name}/documents \
-H "Authorization: Bearer {api_key}" \
-H "Content-Type: application/json" \
-d '{"ids": ["43207654321", "43207654322"]}'
Seasonal Cleanup
Remove seasonal products after the season ends:
curl -X DELETE https://ecom.marqo-ep.ai/api/v1/indexes/{index_name}/documents \
-H "Authorization: Bearer {api_key}" \
-H "Content-Type: application/json" \
-d '{"ids": ["43208123456", "43208123457", "43208123458"]}'
Catalog Migration
Reset index before importing new catalog:
# Clear existing catalog
curl -X POST https://ecom.marqo-ep.ai/api/v1/indexes/{index_name}/reset \
-H "Authorization: Bearer {api_key}" \
-H "Content-Type: application/json"
# Then add new catalog using the add documents endpoint
Best Practices
Deletion Safety
- Verify IDs - Ensure product IDs exist before attempting deletion
- Backup data - Keep backups before bulk deletions
- Test first - Test deletion operations on a staging index
- Batch wisely - Delete in reasonable batch sizes (50-100 IDs)