The Delete Product endpoint enables you to permanently remove products from your catalog. This operation includes comprehensive safety checks, dependency validation, and cascading cleanup of related data. Use this endpoint with caution as deleted products cannot be recovered.
Endpoint Details
Authentication : Required (API Key & Secret)
Idempotency : Supported (recommended for delete operations)
Parameters
Product ID to delete Format : UUID v4Example : "550e8400-e29b-41d4-a716-446655440000"
Query Parameters
Force deletion even with dependencies Default : falseExample : true
Delete related data (images, analytics) Default : trueExample : false
Safety Considerations
Pre-deletion Checks
Active Transactions : Products with pending transactions cannot be deleted
Payment Links : Active payment links prevent deletion
Invoice References : Products referenced in unpaid invoices are protected
Dependencies : Related data is identified and handled appropriately
Dependency Resolution
Images : Product images are removed from CDN and storage
Analytics : Historical data is archived before deletion
References : Payment links and invoices are updated or protected
Cache : All cached product data is invalidated
Request Examples
Basic Delete
Force Delete
Delete Without Cascade
JavaScript
Python
PHP
curl -X DELETE "https://api.devdraft.ai/api/v0/products/550e8400-e29b-41d4-a716-446655440000" \
-H "x-client-key: YOUR_CLIENT_KEY" \
-H "x-client-secret: YOUR_CLIENT_SECRET" \
-H "x-idempotency-key: $( uuidgen )"
Success Response (200 OK)
{
"productId" : "550e8400-e29b-41d4-a716-446655440000" ,
"deleted" : true ,
"deletionTimestamp" : "2024-01-21T10:30:00.000Z" ,
"cascadeOperations" : {
"imagesRemoved" : 3 ,
"analyticsArchived" : true ,
"cacheInvalidated" : true ,
"paymentLinksUpdated" : 1
},
"backupInfo" : {
"backupId" : "backup_987654321" ,
"retentionPeriod" : "30 days" ,
"recoveryPossible" : false
},
"affectedSystems" : [
"product_catalog" ,
"image_storage" ,
"analytics_warehouse" ,
"payment_links" ,
"search_index"
],
"warnings" : [
"Product had 45 historical transactions - analytics data has been archived" ,
"Related payment link has been deactivated"
]
}
Error Responses
400 Bad Request - Has Dependencies
404 Not Found
409 Conflict
422 Unprocessable Entity
{
"statusCode" : 400 ,
"message" : "Cannot delete product with active dependencies" ,
"error" : "Bad Request" ,
"details" : {
"productId" : "550e8400-e29b-41d4-a716-446655440000" ,
"dependencies" : [
{
"type" : "payment_link" ,
"id" : "pl_123456789" ,
"description" : "Active payment link with recent transactions"
},
{
"type" : "pending_transaction" ,
"count" : 2 ,
"description" : "Pending transactions awaiting completion"
}
],
"recommendations" : [
"Deactivate payment link before deletion" ,
"Wait for pending transactions to complete" ,
"Use force=true to override safety checks"
]
}
}
Alternative Actions
Archive Instead of Delete
When deletion isn’t appropriate, consider archiving:
// Archive high-value products instead of deleting
const archiveHighValueProduct = async ( productId ) => {
const product = await manager . getProduct ( productId );
// Check if product should be archived instead
const shouldArchive =
product . analytics ?. totalRevenue > 1000 ||
product . analytics ?. totalTransactions > 10 ||
new Date ( product . analytics ?. lastSaleDate ) > new Date ( Date . now () - 7 * 24 * 60 * 60 * 1000 );
if ( shouldArchive ) {
return await manager . archiveProduct ( productId );
}
return await manager . deleteProduct ( productId );
};
Bulk Operations
For managing multiple products:
// Clean up products by category
const cleanupByCategory = async ( categoryFilter ) => {
const allProducts = await manager . getAllProducts ();
const candidates = allProducts . products . filter ( categoryFilter );
// Separate into archive and delete candidates
const archiveCandidates = candidates . filter ( p =>
p . analytics ?. totalRevenue > 500 ||
p . analytics ?. totalTransactions > 5
);
const deleteCandidates = candidates . filter ( p =>
! archiveCandidates . includes ( p )
);
// Execute operations
const archiveResults = await Promise . all (
archiveCandidates . map ( p => manager . archiveProduct ( p . id ))
);
const deleteResults = await manager . bulkDelete (
deleteCandidates . map ( p => p . id )
);
return {
archived: archiveResults . length ,
deleted: deleteResults . successful . length ,
failed: deleteResults . failed . length
};
};
Best Practices
Safety Protocols
Always check dependencies before deletion unless absolutely necessary
Use dry runs for bulk operations to preview changes
Archive valuable products instead of deleting when possible
Validate permissions for deletion operations
Monitor deletion patterns for unusual activity
Recovery Planning
Backup Strategy : Critical product data is automatically backed up
Retention Period : Backups retained for 30 days minimum
Recovery Process : Contact support for emergency recovery needs
Audit Trail : All deletions are logged for compliance
Batch Operations : Use bulk delete for multiple products
Async Processing : Large deletions are processed asynchronously
Rate Limiting : Respect API rate limits for bulk operations
Resource Impact : Consider server load during peak times
Next Steps
After deleting products, you can:
Verify Cleanup : Confirm all related data has been properly removed
Update Catalogs : Refresh product listings and search indexes
Review Analytics : Analyze the impact on overall catalog performance
Monitor Systems : Check for any issues in related services
Document Changes : Record deletion decisions for audit purposes
For more information, see: