Skip to main content
DELETE
/
destinos
/
{destino_id}
/
force
curl -X DELETE https://api.tesisrutas.com/destinos/507f1f77bcf86cd799439011/force \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"
{
  "message": "Destino con id 507f1f77bcf86cd799439011 eliminado permanentemente y carpeta Cloudinary eliminada."
}

Authentication

Required Role: Admin This endpoint requires authentication with admin privileges. This is a destructive operation that cannot be undone.
destino_id
string
required
MongoDB ObjectId of the destination to delete

Response

message
string
Success message confirming deletion
cloudinary_error
string
Error message if Cloudinary folder deletion failed (optional)
curl -X DELETE https://api.tesisrutas.com/destinos/507f1f77bcf86cd799439011/force \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"
{
  "message": "Destino con id 507f1f77bcf86cd799439011 eliminado permanentemente y carpeta Cloudinary eliminada."
}

Deletion Process

This endpoint performs a complete physical deletion in the following steps:

1. Validation

  • Verifies the destination exists in the database
  • Checks for associated multimedia files
  • Returns 400 error if multimedia files exist

2. Database Deletion

  • Permanently removes the document from MongoDB
  • Uses delete_one() operation (not a soft delete)
  • Cannot be recovered after deletion

3. Cloudinary Cleanup

  • Attempts to delete the folder: destinations/{destino_id}
  • This removes all uploaded files for this destination
  • If Cloudinary deletion fails, the database deletion still succeeds

Important Notes

Multimedia Must Be Deleted FirstYou cannot delete a destination that has associated multimedia files. Use the DELETE /destinos//multimedia endpoint to remove all files first.
Soft Delete AlternativeConsider using PUT /destinos/estado/ to deactivate a destination instead of permanent deletion. This preserves data and allows reactivation later.

Why This Constraint?

The multimedia validation ensures:
  • No orphaned files in Cloudinary
  • Explicit cleanup workflow - admins must consciously delete files first
  • Data integrity - prevents accidental loss of multimedia assets

Implementation Details

This endpoint:
  1. Retrieves the destination document
  2. Checks multimedia array length
  3. Blocks deletion if multimedia.length > 0
  4. Uses EliminarDestinoUseCase.eliminar_fisico() for database deletion
  5. Calls cloudinary.api.delete_folder() to remove all files
  6. Returns graceful error if Cloudinary cleanup fails
Cloudinary Folder Structure:
destinations/
  └── {destino_id}/
      ├── image1.jpg
      ├── image2.png
      └── video1.mp4
Source: destinos_router.py:56-91

Build docs developers (and LLMs) love