Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/vanegasjoseignacio2-cyber/Eco-It/llms.txt

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

The /api/contact endpoint is the single entry point for all contact form submissions on the Eco-It platform. It is fully public — no authentication token is required — meaning both registered users and unauthenticated visitors (guests) can reach out to the Eco-It team. When a submission is received, the server validates the input, renders a branded HTML email template, and delivers it to the configured admin inbox via Gmail SMTP using Nodemailer. The response is intentionally simple: a success flag and a friendly message.
The endpoint identifies whether the sender is a registered user by the optional presence of a userId field in the request body. This distinction is reflected in the email as a coloured badge (“Usuario registrado” or “Invitado”) but does not affect validation or delivery.

POST /api/contact

Validates the form payload, builds a styled HTML email, and dispatches it to the admin address defined in the ADMIN_EMAIL environment variable (fallback: ecoit4167@gmail.com). The replyTo header of the email is set to the sender’s address so admins can reply directly from their inbox. Auth: None (public)
POST /api/contact
Content-Type: application/json

Request Body

name
string
required
Full name of the person sending the message. Must be a non-empty string after trimming whitespace. Displayed prominently in the email header.
email
string
required
Email address of the sender. Validated against the pattern \S+@\S+\.\S+. Used as the replyTo address so admins can respond directly. Must be non-empty.
subject
string
required
Category of the enquiry. One of the following keys:
KeyLabel displayed in email
generalConsulta general
supportSoporte técnico
suggestionSugerencia
partnershipColaboración
Any other non-empty string is also accepted and displayed as-is.
message
string
required
The body of the message. Must be a non-empty string. Rendered inside a styled blockquote in the email with white-space: pre-wrap so line breaks are preserved.
userId
string
Optional MongoDB ObjectId of the authenticated user submitting the form. When present, the email badge reads “Usuario registrado”; when absent, it reads “Invitado”. This field is not validated against the database — its presence alone signals registration status.

Responses

HTTP 200 — Success
success
boolean
true when the email was dispatched without error.
mensaje
string
"¡Mensaje enviado! Te responderemos pronto." — a user-friendly confirmation message suitable for displaying in a toast or alert component.
HTTP 400 — Validation Error
success
boolean
false.
mensaje
string
One of:
  • "Todos los campos son obligatorios." — when any required field is missing or blank.
  • "El formato del correo no es válido." — when the email field fails the regex check.
HTTP 500 — Server / SMTP Error
success
boolean
false.
mensaje
string
"Error al enviar el mensaje. Intenta de nuevo.".
error
string
The underlying Node.js / Nodemailer error message for debugging purposes.

cURL Example

curl -X POST https://api.eco-it.co/api/contact \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Valentina Rojas",
    "email": "valentina.rojas@example.com",
    "subject": "support",
    "message": "Hola, tengo un problema al registrarme en la plataforma. El botón de confirmación no responde en mi dispositivo móvil.",
    "userId": "665f1a2b3c4d5e6f7a8b9c0d"
  }'
Successful response
{
  "success": true,
  "mensaje": "¡Mensaje enviado! Te responderemos pronto."
}
Validation error response
{
  "success": false,
  "mensaje": "El formato del correo no es válido."
}

What the Admin Receives

When a message is successfully processed, the admin inbox receives a rich HTML email with the following layout:
  • Header — Eco-It green gradient banner with the 🌿 logo and the label “Nuevo mensaje de contacto”.
  • Badges — The subject category label and a coloured pill indicating “Usuario registrado” (blue) or “Invitado” (amber).
  • Sender block — The sender’s name and a mailto: link for their email address.
  • Message body — The full message text in a styled green-bordered blockquote.
  • Reply button — A pre-addressed “Responder a [name]” CTA that opens a reply draft with Re: [subject label] pre-filled.
  • Footer — The Colombia/Bogotá formatted timestamp of when the message was received.
The email subject line follows the pattern:
[Eco-It] {subject label} — {name}
For example: [Eco-It] Soporte técnico — Valentina Rojas.
Email delivery is handled by a Nodemailer transporter configured for Gmail SMTP, created directly inside the contact controller. The sending address and password are read from the EMAIL_USER and EMAIL_PASS environment variables at runtime. The destination admin address defaults to ecoit4167@gmail.com and can be overridden with the ADMIN_EMAIL environment variable.
Gmail SMTP requires either an App Password (if 2-Step Verification is enabled on the account) or a dedicated service account. Using a personal Gmail password directly will result in authentication failures. Store credentials in environment variables — never hard-code them in the repository.

Build docs developers (and LLMs) love