Skip to main content
PUT
/
destinos
/
{id}
curl -X PUT https://api.tesisrutas.com/destinos/507f1f77bcf86cd799439011 \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "importancia": "Principal templo católico del Perú, declarado Patrimonio Cultural",
    "funcion": "Templo religioso, museo y sede arquidiocesana"
  }'
{
  "message": "Destino actualizado correctamente"
}

Update Destination Data

id
string
required
MongoDB ObjectId of the destination to update

Authentication

Required Role: Admin

Request Body

All fields are optional. Only provided fields will be updated.
nombre
string
Name of the heritage site
ubicacion
string
Location or address of the site
importancia
string
Historical or cultural significance
coordenadas
object
Geographic coordinates
coordenadas.latitud
number
Latitude (-90 to 90)
coordenadas.longitud
number
Longitude (-180 to 180)
anio_construccion
array
Year(s) of construction (1 or 2 integer values)
arquitecto
string
Name of the architect
area_construccion
number
Construction area in square meters
funcion
string
Function of the site

Response

message
string
Success message
curl -X PUT https://api.tesisrutas.com/destinos/507f1f77bcf86cd799439011 \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "importancia": "Principal templo católico del Perú, declarado Patrimonio Cultural",
    "funcion": "Templo religioso, museo y sede arquidiocesana"
  }'
{
  "message": "Destino actualizado correctamente"
}

Toggle Destination Status

Endpoint: PUT /destinos/estado/{id} Toggle the active status of a destination between active and inactive.
id
string
required
MongoDB ObjectId of the destination

Authentication

Required Role: Editor (or higher)

Response

message
string
Success message indicating the new status
curl -X PUT https://api.tesisrutas.com/destinos/estado/507f1f77bcf86cd799439011 \
  -H "Authorization: Bearer YOUR_EDITOR_TOKEN"
{
  "message": "Destino desactivado correctamente"
}

Implementation Details

Update Data Endpoint

This endpoint (PUT /destinos/{id}):
  1. Validates that the destination exists and is active
  2. Filters out null values from the update data
  3. Properly handles nested coordenadas object updates
  4. Uses MongoDB $set operator to update only provided fields
  5. Returns error if validation fails (invalid coordinates, year format, etc.)
Source: destinos_router.py:36-44

Toggle Status Endpoint

This endpoint (PUT /destinos/estado/{id}):
  1. Retrieves the current activo status
  2. Toggles it to the opposite value (true → false or false → true)
  3. Updates the document regardless of current active state
  4. Returns a descriptive message indicating the new status
Permissions:
  • Editors can toggle status (useful for content moderation)
  • Admins can toggle status and fully update data
Source: destinos_router.py:46-54

Build docs developers (and LLMs) love