Skip to main content

POST /api/propiedades

Create a new property in the database. This endpoint requires admin authentication using HTTP Basic Auth.
This endpoint requires authentication. Include the Authorization header with Basic Auth credentials.

Request

codigo_id
string
Optional unique 6-character property identifier. If not provided, one will be automatically generated. Must be exactly 6 characters if provided.
pais
string
required
Country where the property is located (e.g., “Argentina”)
ciudad
string
required
City where the property is located (e.g., “Tigre”)
direccion
string
required
Street address of the property (e.g., “Av. Cazón 123”)
ambientes
number
required
Number of rooms in the property
metros_cuadrados
number
required
Property size in square meters
precio
number
required
Property price in local currency
tipo_contratacion
enum
required
Type of contract. Must be one of: Alquiler (Rent) or Venta (Sale)
estado
enum
required
Current status of the property. Must be one of: Disponible (Available), Reservado (Reserved), Alquilado (Rented), Vendido (Sold)
descripcion
string
Optional description or additional details about the property

Example Request

curl -X POST https://idforideas-1.jamrdev.com.ar/api/propiedades \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic <base64-credentials>" \
  -d '{
    "pais": "Argentina",
    "ciudad": "Tigre",
    "direccion": "Av. Cazón 123",
    "ambientes": 3,
    "metros_cuadrados": 75.5,
    "precio": 120000,
    "tipo_contratacion": "Venta",
    "estado": "Disponible",
    "descripcion": "Hermosa vista al río"
  }'

Response

success
boolean
required
Indicates whether the operation was successful
message
string
required
Human-readable message describing the result
id
string
The unique identifier assigned to the newly created property (returned on success)
error
string
Error message describing what went wrong (returned on failure)

Example Response

Success (201)
{
  "success": true,
  "message": "Propiedad creada correctamente",
  "id": "ZN1001"
}
Validation Error (400)
{
  "success": false,
  "error": "Invalid tipo_contratacion. Expected 'Alquiler' or 'Venta'"
}
Conflict (409)
{
  "success": false,
  "error": "El código ZN1001 ya existe."
}
Unauthorized (401)
{
  "error": "Unauthorized"
}

Status Codes

201
Created
Property created successfully
400
Bad Request
Invalid data or validation error in request body
401
Unauthorized
Authentication required or credentials invalid
409
Conflict
Property with the specified codigo_id already exists

Notes

  • If codigo_id is not provided, the system will automatically generate a unique 6-character code using alphanumeric characters (excluding O, 0, I, L for clarity)
  • If a custom codigo_id is provided and already exists, the request will fail with a 409 Conflict error
  • The system will attempt up to 5 times to generate a unique ID if collisions occur (extremely rare)
  • All required fields must be provided and pass validation according to the property schema

Build docs developers (and LLMs) love