Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/MateoNavarroMN/Balsamoa-Backend/llms.txt

Use this file to discover all available pages before exploring further.

This endpoint permanently removes a product image in two steps: it first deletes the physical file from the server’s disk, then removes the corresponding record from the producto_imagenes table. Use this when you want to discard a standalone image that is no longer needed without modifying the product itself.

Request

PropertyValue
MethodDELETE
Path/api/v1/admin/imagenes/:id

Path Parameters

id
integer
required
The numeric ID of the image record in the producto_imagenes table. This ID is returned when images are listed via the admin product endpoints.

Behavior

  1. The server validates that id is a valid integer.
  2. It looks up the image record in producto_imagenes by ID to retrieve the stored url.
  3. If the url starts with /recursos/, the corresponding file is deleted from the local disk using fs.unlinkSync.
  4. The database record is then deleted with DELETE FROM producto_imagenes WHERE id = $1.
  5. A success message is returned once both operations complete.

Example

curl -X DELETE https://your-api.com/api/v1/admin/imagenes/7

Response

200 OK
{
  "mensaje": "Imagen eliminada del disco y de la base de datos"
}
mensaje
string
Confirmation that the file was removed from disk and the record was deleted from the database.

Error Cases

StatusCauseResponse body
400id path parameter is not a valid number{"mensaje": "El ID de imagen debe ser un número válido"}
404No image record found for the given ID{"mensaje": "Imagen no encontrada"}
500Database error while deleting the record{"mensaje": "Error al eliminar la imagen de la base de datos"}
This endpoint deletes the image independently of any product update. Alternatively, when you call PUT /api/v1/admin/productos/:id and supply a new imagenes array, the API automatically computes which old images are no longer referenced and removes their files from disk before persisting the new list. This means you generally only need this standalone endpoint when discarding an image that was uploaded but never attached to a product.

Build docs developers (and LLMs) love