{
  "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"
  ]
}
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

method
string
DELETE
url
string
/api/v0/products/{id}
Authentication: Required (API Key & Secret)
Idempotency: Supported (recommended for delete operations)

Parameters

id
string
required
Product ID to delete
Format: UUID v4
Example: "550e8400-e29b-41d4-a716-446655440000"

Query Parameters

force
boolean
Force deletion even with dependencies
Default: false
Example: true
cascade
boolean
Delete related data (images, analytics)
Default: true
Example: 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

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)"

Response Format

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

{
  "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

  1. Always check dependencies before deletion unless absolutely necessary
  2. Use dry runs for bulk operations to preview changes
  3. Archive valuable products instead of deleting when possible
  4. Validate permissions for deletion operations
  5. 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

Performance Considerations

  • 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:
  1. Verify Cleanup: Confirm all related data has been properly removed
  2. Update Catalogs: Refresh product listings and search indexes
  3. Review Analytics: Analyze the impact on overall catalog performance
  4. Monitor Systems: Check for any issues in related services
  5. Document Changes: Record deletion decisions for audit purposes