Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nelrondon/backend-proyecto-estructuras/llms.txt

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

The POST /api/properties endpoint creates a new property listing and persists it to the properties table. Authentication is required — the request must include a valid token cookie issued at login. The server extracts the authenticated user’s ID from the decoded JWT and stores it as user_id on the new record, so you must not include user_id in the request body. The request body is validated against the full property schema using Zod; if any required field is missing or any value is of the wrong type, a 422 error is returned with the first failing validation message.

Endpoint

POST /api/properties

Authentication

Required. The request must include a valid token cookie obtained from a successful login. The middleware reads this cookie, verifies the JWT, and attaches the decoded user object to req.user before the controller runs.
ConditionStatusBody
No token cookie present401{ "message": "No Token, Unauthorized" }
token cookie present but invalid or expired403{ "message": "Invalid Token" }

Request Body

Send a JSON body with Content-Type: application/json.
Do not include user_id in the request body. The server sets this automatically from the authenticated user’s JWT payload (req.user.id). Any user_id value you send will be ignored.
title
string
required
Short descriptive title for the property listing. Must be a string.
description
string
Longer free-text description of the property. Must be a string if provided.
status
string
required
Listing availability status. Must be exactly one of:
  • Venta — For sale
  • Alquiler — For rent
  • Ambas — Available for both sale and rent
property_type
string
required
Category of the property. Must be exactly one of:
  • Casa — Residential house
  • Apartamento — Apartment or condominium unit
  • Terreno — Land or undeveloped plot
  • Comercial — Commercial property
address
string
required
Full street address of the property. Must be a string.
city
string
required
City where the property is located. Must be a string.
state
string
required
State or region where the property is located. Must be a string.
price
number
required
Listed price of the property. Must be a number (not a string).
bedrooms
number
Number of bedrooms. Must be a number if provided.
bathrooms
number
Number of bathrooms. Must be a number if provided.
square_feet
number
Total area of the property in square feet. Must be a number if provided.
parking_lots
number
Number of parking spaces. Must be a number if provided.
img_url
string
URL pointing to the primary image of the property. Optional. This field is accepted and stored by the model but is not present in the Zod schema — it is passed through to the database without validation.

Response

Success

HTTP 200 OK
{
  "message": "Datos Recibidos"
}
The property has been persisted to the database. A UUID is generated server-side and stored as the record’s id.

Error Responses

StatusBodyDescription
401{ "message": "No Token, Unauthorized" }No token cookie was present on the request.
403{ "message": "Invalid Token" }The token cookie was present but the JWT could not be verified (invalid signature or expired).
422{ "error": "<first validation message>" }Request body failed Zod schema validation. The message describes which field failed and why.
500{ "error": "<database error message>" }An unexpected database error occurred while inserting the record.

Example

Request

curl --request POST \
  --url https://your-api-domain.com/api/properties \
  --header 'Content-Type: application/json' \
  --cookie 'token=<your-jwt-token>' \
  --data '{
    "title": "Casa con piscina en La Lagunita",
    "description": "Espectacular casa de tres plantas con piscina y jardín privado.",
    "status": "Venta",
    "property_type": "Casa",
    "address": "Calle La Colina, Qta. Azul, La Lagunita Country Club",
    "city": "El Hatillo",
    "state": "Miranda",
    "price": 380000,
    "bedrooms": 5,
    "bathrooms": 4,
    "square_feet": 4200,
    "parking_lots": 3,
    "img_url": "https://example.com/images/casa-lagunita.jpg"
  }'

Success Response

{
  "message": "Datos Recibidos"
}

Validation Error Response

{
  "error": "El tipo de propiedad 'Villa' no es válido. Los tipos permitidos son: Casa, Apartamento, Terreno, Comercial."
}

Build docs developers (and LLMs) love