Skip to main content

Overview

Admin endpoints for comprehensive property management, including viewing all properties (regardless of status) and updating property statuses.
All endpoints on this page require admin role authentication via the requireAdmin middleware.

List All Properties

Retrieve a paginated list of all properties with full details, including inactive properties. Unlike the public properties endpoint, this shows properties with any status.

Query Parameters

page
number
default:"1"
Page number for pagination
limit
number
default:"10"
Number of properties per page

Response

success
boolean
required
Indicates if the request was successful
data
array
required
Array of property objects with full details
pagination
object
required
Pagination metadata
{
  "success": true,
  "data": [
    {
      "id": "123",
      "title": "Casa moderna en Palermo",
      "description": "Hermosa casa con jardín...",
      "price": 250000,
      "propertyType": "Casa",
      "listingType": "Venta",
      "status": "Activo",
      "address": {
        "street": "Av. Santa Fe 1234",
        "city": "Buenos Aires",
        "state": "CABA",
        "zipCode": "1425",
        "country": "Argentina"
      },
      "owner": "Juan Pérez",
      "createdAt": "2024-01-15T10:30:00.000Z",
      "viewsCount": 45,
      "images": [
        "https://example.com/image1.jpg",
        "https://example.com/image2.jpg"
      ],
      "imagesMeta": [
        {
          "id": 1,
          "url": "https://example.com/image1.jpg",
          "orderIndex": 0,
          "isMain": true
        },
        {
          "id": 2,
          "url": "https://example.com/image2.jpg",
          "orderIndex": 1,
          "isMain": false
        }
      ]
    }
  ],
  "pagination": {
    "currentPage": 1,
    "totalPages": 15,
    "totalItems": 150,
    "limit": 10
  }
}

Update Property Status

Update the status of a property. This endpoint supports multiple formats for specifying the status.

Path Parameters

id
number
required
Property ID to update

Request Body

You can provide the status in any of the following formats:
statusId
number
Status ID (preferred)
status_id
number
Alternative field name for status ID
status
string
Status name or slug. The system will look it up automatically.
The endpoint will automatically resolve the status from any of these fields. If status is provided as a name/slug, it will be looked up in the database.

Response

success
boolean
required
Indicates if the status was updated successfully
message
string
required
Success or error message
{
  "success": true,
  "message": "Property status updated successfully"
}

Request Examples

cURL - Using status ID
curl -X PUT https://api.example.com/api/admin/properties/123/status \
  -H "Content-Type: application/json" \
  -H "Cookie: session=..." \
  -d '{
    "statusId": 2
  }'
cURL - Using status name
curl -X PUT https://api.example.com/api/admin/properties/123/status \
  -H "Content-Type: application/json" \
  -H "Cookie: session=..." \
  -d '{
    "status": "pendiente"
  }'
JavaScript
const response = await fetch('/api/admin/properties/123/status', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
  },
  credentials: 'include',
  body: JSON.stringify({
    statusId: 2
  })
});

const data = await response.json();

Implementation Details

  • Updates the statusId and updatedAt fields
  • Validates property exists before updating
  • Supports multiple input formats for flexibility
  • Status lookup is case-insensitive when using status name/slug
  • Returns 400 for invalid input
  • Returns 404 if property not found
  • Returns 500 for server errors

Build docs developers (and LLMs) love