Skip to main content
POST
/
rutas
/
crear
curl -X POST https://api.tesisrutas.com/rutas/crear \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Ruta Colonial del Centro Histórico",
    "descripcion": "Recorrido por los principales monumentos coloniales",
    "categoria": "Cultural",
    "pois": [
      {"poi_id": "507f1f77bcf86cd799439011"},
      {"poi_id": "507f1f77bcf86cd799439012"},
      {"poi_id": "507f1f77bcf86cd799439013"},
      {"poi_id": "507f1f77bcf86cd799439014"}
    ]
  }'
{
  "ruta_id": "507f1f77bcf86cd799439020"
}
Creates a new tourist route with specified POIs. The system automatically orders POIs based on geographic proximity using the Haversine distance formula, starting from the initial POI.

Authentication

Requires Editor role or higher.
nombre
string
required
Name of the tourist route
descripcion
string
Description of the route (optional)
categoria
string
Category classification (e.g., “Cultural”, “Historical”, “Natural”)
pois
array
required
Array of POI objects to include in the route. Must contain at least 2 POIs.
poi_id
string
required
ID of the POI to include in the route
order
integer
Optional order hint (the system will recalculate based on proximity)

AI-Powered Ordering

The route creation uses an intelligent ordering algorithm:
  1. Starting Point: The first POI in the array becomes the starting point
  2. Proximity Calculation: Uses Haversine formula to calculate distances between all POIs
  3. Optimal Path: Orders POIs by selecting the nearest unvisited POI at each step
  4. Automatic Optimization: Even if you provide an order field, the system recalculates for optimal routing
See crear_ruta_turistica.py:67-94 for implementation details.
ruta_id
string
The unique identifier of the created route
curl -X POST https://api.tesisrutas.com/rutas/crear \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Ruta Colonial del Centro Histórico",
    "descripcion": "Recorrido por los principales monumentos coloniales",
    "categoria": "Cultural",
    "pois": [
      {"poi_id": "507f1f77bcf86cd799439011"},
      {"poi_id": "507f1f77bcf86cd799439012"},
      {"poi_id": "507f1f77bcf86cd799439013"},
      {"poi_id": "507f1f77bcf86cd799439014"}
    ]
  }'
{
  "ruta_id": "507f1f77bcf86cd799439020"
}

Validation Rules

  • Minimum 2 POIs required
  • All POI IDs must exist in the database
  • First POI becomes the starting point
  • If punto_inicio_id is not in the POI list, it’s automatically added

Error Responses

detail
string
Error message describing what went wrong
  • 400 Bad Request: “Una ruta debe tener al menos 2 POIs.”
  • 400 Bad Request: “Uno o más POIs no existen.”
  • 401 Unauthorized: Missing or invalid authentication token
  • 403 Forbidden: User does not have Editor role

Build docs developers (and LLMs) love