Overview
ThedeleteParkingSpot endpoint permanently removes a parking spot document from Firestore. This operation cannot be undone.
Endpoint
Authentication
CORS-enabled endpoint with wildcard origin (*). Should be restricted to admin users in production.
Request Body
The unique identifier of the parking spot to delete (e.g., “A-01”, “I-16”). Will be trimmed and converted to uppercase.
Response
Indicates whether the deletion was successful
Result message: “Puesto eliminado exitosamente”
Error message (only present on failure)
Success Response
- 200 OK - Spot deleted successfully
- 204 No Content - OPTIONS preflight response
Error Responses
- 400 Bad Request - Missing required parameter
id - 500 Internal Server Error - Database or server error
Important Notes
- Firestore’s
delete()succeeds even if the document doesn’t exist (idempotent operation) - No validation is performed to check if spot has active reservations
- Historical data in
occupancy_historyis not affected
Code Example
Success Response Example
Error Response Example
Missing ID
Safe Deletion Workflow
For production systems, consider implementing a soft-delete pattern:Bulk Deletion Pattern
For deleting multiple spots:Data Processing
- ID normalization: Trimmed and converted to uppercase (“a-01” → “A-01”)
- Idempotent: Calling delete on a non-existent spot returns success
- No cascade: Related data in other collections is not affected
Pre-Deletion Checklist
Before deleting a spot, consider:- Active Reservations: Check if spot has
status === 2 - Sensor Integration: Update or remove sensor mappings
- Analytics: Export historical data if needed
- User Notifications: Alert users with active reservations
- Map Updates: Update frontend map displays
Related Endpoints
- Create Parking Spot - Create a new spot
- Get Parking Status - Check spot status before deletion
- Release Parking Spot - Clear reservations before deletion