# Feed removal – unprocessed raw product cleanup (v12) `DELETE /api/feeds/{id}` (dashboard) and `DELETE /api/v1/feeds/{id}` (public API, where authorized) now use the same service transaction: 1. Lock the company-owned feed (`SELECT … FOR UPDATE`). Cross-company IDs return 404. 2. Transfer raw products still associated with another existing feed (legacy `feed_ids`) to that surviving feed. 3. Delete raw products owned only by the removed feed when `is_processed = false` and `processing_status IN ('unprocessed', 'failed')`. 4. Remove deleted-feed references from the `feed_ids` arrays of retained raw products. 5. Delete the input-feed row and let normal foreign keys remove its mappings/sync history while setting feed IDs to NULL on preserved products. 6. Commit all actions together. If any statement fails, nothing is deleted. **Never deleted:** already processed products; actively processing raw products; products owned by another feed; users' other companies' data. When a processed output points to a raw product that is removed, PostgreSQL detaches its `raw_product_id` reference; the processed output stays. **Response:** `{ "id": "...", "deleted": true, "deleted_unprocessed_products": 42 }`. **Caveat:** a raw product in `processing` status is not deleted because a worker may be generating content; deleting the source feed detaches it instead. The worker should be deployed with the matching API release so feed synchronization writes respect the deleted feed's FK. **Checks:** `go test ./internal/feeds -run TestDeleteFeedRemovesOnlyOwnedUnprocessedProducts -count=1` from `apps/api`, with migrated test PostgreSQL and `DATABASE_URL`. This verifies two deleted rows, processed/processing preservation, multi-source reassignment, tenant boundaries, and repeat deletion. A full Go 1.25 build and DB integration test must run on the deployment/test environment. No database migration is necessary.