Updating Properties
Update existing property information using the PATCH /api/propiedades/{id} endpoint. This endpoint supports partial updates - you only need to send the fields you want to change.
Endpoint
PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/{id}
Key Concepts
Partial Updates
You only need to send the fields you want to update. All fields are optional in a PATCH request:
# Update only the price
curl -X PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001 \
-u admin:password \
-H "Content-Type: application/json" \
-d '{"precio": 125000}'
Immutable ID
The codigo_id cannot be changed after creation. Any attempt to modify it will result in a 400 Bad Request error.
# This will fail
curl -X PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001 \
-u admin:password \
-H "Content-Type: application/json" \
-d '{"codigo_id": "NEW123"}'
# Error response
{
"success" : false ,
"error" : "No está permitido modificar el código identificador de la propiedad."
}
Source: Backend/src/controllers/propiedades.controller.ts:105-110
Basic Example
curl -X PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001 \
-u admin:password \
-H "Content-Type: application/json" \
-d '{
"precio": 125000,
"estado": "Reservado"
}'
Success Response
Status Code: 200 OK
{
"success" : true ,
"message" : "Propiedad actualizada"
}
Common Update Scenarios
Update Property Status
Mark a property as reserved, rented, or sold:
# Mark as reserved
curl -X PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001 \
-u admin:password \
-H "Content-Type: application/json" \
-d '{"estado": "Reservado"}'
# Mark as rented
curl -X PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001 \
-u admin:password \
-H "Content-Type: application/json" \
-d '{"estado": "Alquilado"}'
# Mark as sold
curl -X PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001 \
-u admin:password \
-H "Content-Type: application/json" \
-d '{"estado": "Vendido"}'
Update Price
curl -X PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001 \
-u admin:password \
-H "Content-Type: application/json" \
-d '{"precio": 135000}'
Update Description
curl -X PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001 \
-u admin:password \
-H "Content-Type: application/json" \
-d '{
"descripcion": "Hermosa vista al río. Recientemente renovada con cocina nueva."
}'
Update Multiple Fields
curl -X PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001 \
-u admin:password \
-H "Content-Type: application/json" \
-d '{
"precio": 140000,
"descripcion": "Precio actualizado. Excelente oportunidad.",
"estado": "Disponible"
}'
Change Contract Type
# Change from rental to sale
curl -X PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001 \
-u admin:password \
-H "Content-Type: application/json" \
-d '{
"tipo_contratacion": "Venta",
"precio": 2500000,
"estado": "Disponible"
}'
Updatable Fields
All fields except codigo_id can be updated:
Field Type Example pais string ”Argentina” ciudad string ”Buenos Aires” direccion string ”Av. Corrientes 1234” ambientes number 3 metros_cuadrados number 85.5 precio number 125000 tipo_contratacion enum ”Alquiler” or “Venta” estado enum ”Disponible”, “Reservado”, “Alquilado”, “Vendido” descripcion string ”Casa con vista al río”
codigo_id is immutable and cannot be updated.
Error Responses
400 Bad Request - Attempting to Change ID
{
"success" : false ,
"error" : "No está permitido modificar el código identificador de la propiedad."
}
400 Bad Request - Validation Error
{
"success" : false ,
"error" : "Invalid input: estado must be one of Disponible, Reservado, Alquilado, Vendido"
}
401 Unauthorized
{
"error" : "Unauthorized"
}
404 Not Found
Returned when the property ID doesn’t exist:
{
"success" : false ,
"error" : "Propiedad no encontrada"
}
Implementation Details
The update logic uses COALESCE to only update provided fields (from Backend/src/controllers/propiedades.controller.ts:99-153):
export const updatePropiedad = async ( c : Context ) => {
const id = c . req . param ( 'id' );
const body = await c . req . json ();
// Prevent ID modification
if ( body . codigo_id && body . codigo_id !== id ) {
return c . json ({
success: false ,
error: "No está permitido modificar el código identificador de la propiedad."
}, 400 );
}
// Validate with partial schema (all fields optional)
const validated = PropiedadSchema . partial (). parse ( body );
// Update only provided fields using COALESCE
const result = await c . env . DB . prepare ( `
UPDATE propiedades SET
pais = COALESCE(?, pais),
ciudad = COALESCE(?, ciudad),
precio = COALESCE(?, precio),
estado = COALESCE(?, estado),
// ... other fields
WHERE codigo_id = ?
` ). bind ( ... values , id ). run ();
if ( result . meta . changes === 0 ) {
return c . json ({ success: false , error: "Propiedad no encontrada" }, 404 );
}
return c . json ({ success: true , message: 'Propiedad actualizada' });
};
Validation Rules
The same validation rules apply as when creating properties:
estado must be: “Disponible”, “Reservado”, “Alquilado”, or “Vendido”
tipo_contratacion must be: “Alquiler” or “Venta”
Numbers must be sent as numbers, not strings
All enum values are case-sensitive
See Validation Rules for complete details.
Best Practices
Send only changed fields
Only include fields you’re actually updating to minimize payload size and clarify intent.
Verify property exists first
Use GET /api/propiedades/{id} to confirm the property exists before updating.
Update status atomically
When marking a property as sold/rented, consider updating the price or description at the same time.
Handle 404 errors
If you get a 404, the property may have been deleted. Don’t retry the request.
Validate locally
Check enum values and data types before sending to avoid validation errors.
Workflow Example
Complete workflow for updating a property:
Fetch current property
curl https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001
Determine changes
Review current values and decide what needs updating.
Send PATCH request
curl -X PATCH https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001 \
-u admin:password \
-H "Content-Type: application/json" \
-d '{"precio": 125000, "estado": "Reservado"}'
Verify update
curl https://idforideas-1.jamrdev.com.ar/api/propiedades/ZN1001
Confirm the fields were updated correctly.
Next Steps
Query Properties Learn how to retrieve property information
Creating Properties Guide on creating new properties
Error Handling Handle API errors gracefully
API Reference Complete API reference for this endpoint