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.

Images must be uploaded to the server before they can be associated with a product. This endpoint accepts a single file via multipart/form-data, saves it to disk, and returns a public URL path. That URL is then passed inside the imagenes array when calling the create or update product endpoints.

Request

PropertyValue
MethodPOST
Path/api/v1/admin/imagenes/subir
Content-Typemultipart/form-data

Body

imagen
file
required
The image file to upload. Must be sent as a form field named exactly imagen.

Constraints

  • Maximum file size: 5 MB. Requests exceeding this limit are rejected with a 400 error.
  • Accepted MIME types: image/jpeg, image/png, image/webp, image/gif. Any other MIME type is rejected with a 400 error.
  • Storage location: Files are saved to the server’s local filesystem under /src/public/recursos/imagenes/productos/.
  • Filename sanitization: Spaces in the original filename are replaced with underscores (_), and a Unix millisecond timestamp is prepended (e.g., 1700000000000_remera_blanca.webp).

Example

curl -X POST https://your-api.com/api/v1/admin/imagenes/subir \
  --form "imagen=@/path/to/remera.webp"

Response

201 Created
{
  "mensaje": "Imagen subida exitosamente",
  "url": "/recursos/imagenes/productos/1700000000000_remera.webp",
  "filename": "1700000000000_remera.webp"
}
mensaje
string
Human-readable confirmation message.
url
string
The public URL path for this image. Store this value and include it in the imagenes array when creating or updating a product.
filename
string
The sanitized filename as saved on disk, including the timestamp prefix.

Error Cases

StatusCauseResponse body
400File exceeds 5 MB (LIMIT_FILE_SIZE){"mensaje": "El archivo supera el límite de 5 MB"}
400MIME type not in the allowed list (TIPO_INVALIDO){"mensaje": "Solo se aceptan imágenes (jpg, png, webp, gif)"}
400No file field received in the request{"mensaje": "No se recibió ningún archivo"}
Ephemeral disk on Vercel. This endpoint writes files to the local filesystem (/src/public/recursos/imagenes/productos/). Vercel’s serverless runtime uses an ephemeral filesystem — files written during one request are not guaranteed to persist across function invocations or deployments. For production use, replace the Multer disk storage configuration with a cloud storage provider such as Cloudinary, AWS S3, or Supabase Storage, and store the resulting CDN URL instead.

Typical Workflow

1

Upload the image

Send a POST request to /api/v1/admin/imagenes/subir with the image file attached as the imagen form field. The server saves the file and returns a url such as /recursos/imagenes/productos/1700000000000_remera.webp.
2

Copy the returned URL

Save the url value from the response. You will need it in the next step.
3

Include the URL in a product request

Pass the URL inside the imagenes array when calling POST /api/v1/admin/productos (create) or PUT /api/v1/admin/productos/:id (update):
{
  "nombre": "Remera Blanca Guardapampa",
  "precio": 30000,
  "categoria_id": 2,
  "imagenes": [
    { "url": "/recursos/imagenes/productos/1700000000000_remera.webp", "orden": 1 }
  ]
}

Build docs developers (and LLMs) love