Overview
The Cities API (Ciudades) allows you to manage city records in the system. Cities are the lowest level of the geographic hierarchy: Country → State → City.
Cities can have postal codes and are linked to locations (Ubicaciones) within the Core Projects system.
Model Structure
Table: ciudades
Primary Key: id_ciudad
Fields
Unique identifier for the city
City name (max 120 characters)
Postal/ZIP code for the city (max 20 characters)
Foreign key reference to the parent state/department
Record creation timestamp
Record last update timestamp
Relationships
The parent state/department object with nested country data
Collection of locations (project sites) within this city
List All Cities
curl --request GET \
--url https://api.coreprojects.com/api/ciudades \
--header 'Authorization: Bearer YOUR_TOKEN'
{
"success" : true ,
"data" : [
{
"id_ciudad" : 1 ,
"nombre" : "Bogotá" ,
"codigo_postal" : "110111" ,
"id_departamento" : 1 ,
"created_at" : "2024-01-15T10:40:00.000000Z" ,
"updated_at" : "2024-01-15T10:40:00.000000Z" ,
"departamento" : {
"id_departamento" : 1 ,
"nombre" : "Cundinamarca" ,
"id_pais" : 1 ,
"created_at" : "2024-01-15T10:35:00.000000Z" ,
"updated_at" : "2024-01-15T10:35:00.000000Z" ,
"pais" : {
"id_pais" : 1 ,
"nombre" : "Colombia" ,
"created_at" : "2024-01-15T10:30:00.000000Z" ,
"updated_at" : "2024-01-15T10:30:00.000000Z"
}
},
"ubicaciones" : []
},
{
"id_ciudad" : 2 ,
"nombre" : "Medellín" ,
"codigo_postal" : "050001" ,
"id_departamento" : 2 ,
"created_at" : "2024-01-15T11:05:00.000000Z" ,
"updated_at" : "2024-01-15T11:05:00.000000Z" ,
"departamento" : {
"id_departamento" : 2 ,
"nombre" : "Antioquia" ,
"id_pais" : 1 ,
"created_at" : "2024-01-15T11:00:00.000000Z" ,
"updated_at" : "2024-01-15T11:00:00.000000Z" ,
"pais" : {
"id_pais" : 1 ,
"nombre" : "Colombia" ,
"created_at" : "2024-01-15T10:30:00.000000Z" ,
"updated_at" : "2024-01-15T10:30:00.000000Z"
}
},
"ubicaciones" : []
}
]
}
Endpoint
Response Fields
Indicates if the request was successful
Array of city objects with nested department, country, and locations data
Get Single City
curl --request GET \
--url https://api.coreprojects.com/api/ciudades/1 \
--header 'Authorization: Bearer YOUR_TOKEN'
200 - Success
404 - Not Found
{
"success" : true ,
"data" : {
"id_ciudad" : 1 ,
"nombre" : "Bogotá" ,
"codigo_postal" : "110111" ,
"id_departamento" : 1 ,
"created_at" : "2024-01-15T10:40:00.000000Z" ,
"updated_at" : "2024-01-15T10:40:00.000000Z" ,
"departamento" : {
"id_departamento" : 1 ,
"nombre" : "Cundinamarca" ,
"id_pais" : 1 ,
"created_at" : "2024-01-15T10:35:00.000000Z" ,
"updated_at" : "2024-01-15T10:35:00.000000Z" ,
"pais" : {
"id_pais" : 1 ,
"nombre" : "Colombia" ,
"created_at" : "2024-01-15T10:30:00.000000Z" ,
"updated_at" : "2024-01-15T10:30:00.000000Z"
}
},
"ubicaciones" : [
{
"id_ubicacion" : 1 ,
"direccion" : "Calle 100 #15-20" ,
"barrio" : "Chicó Norte" ,
"id_ciudad" : 1 ,
"created_at" : "2024-01-15T12:00:00.000000Z" ,
"updated_at" : "2024-01-15T12:00:00.000000Z"
}
]
}
}
Endpoint
Path Parameters
The unique identifier of the city
Create City
curl --request POST \
--url https://api.coreprojects.com/api/ciudades \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"nombre": "Bogotá",
"codigo_postal": "110111",
"id_departamento": 1
}'
201 - Created
422 - Validation Error
422 - Invalid Department
{
"success" : true ,
"message" : "Ciudad creada exitosamente" ,
"data" : {
"id_ciudad" : 1 ,
"nombre" : "Bogotá" ,
"codigo_postal" : "110111" ,
"id_departamento" : 1 ,
"created_at" : "2024-01-15T10:40:00.000000Z" ,
"updated_at" : "2024-01-15T10:40:00.000000Z" ,
"departamento" : {
"id_departamento" : 1 ,
"nombre" : "Cundinamarca" ,
"id_pais" : 1 ,
"created_at" : "2024-01-15T10:35:00.000000Z" ,
"updated_at" : "2024-01-15T10:35:00.000000Z" ,
"pais" : {
"id_pais" : 1 ,
"nombre" : "Colombia" ,
"created_at" : "2024-01-15T10:30:00.000000Z" ,
"updated_at" : "2024-01-15T10:30:00.000000Z"
}
}
}
}
Endpoint
Body Parameters
Name of the city (max 120 characters)
Postal/ZIP code for the city (max 20 characters)
ID of the parent state/department (must exist in the departamentos table)
Validation Rules
nombre: Required, string, maximum 120 characters
codigo_postal: Optional, string, maximum 20 characters
id_departamento: Required, must exist in the departamento table
Update City
curl --request PUT \
--url https://api.coreprojects.com/api/ciudades/1 \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"nombre": "Bogotá D.C.",
"codigo_postal": "110111",
"id_departamento": 1
}'
200 - Success
404 - Not Found
422 - Validation Error
{
"success" : true ,
"message" : "Ciudad actualizada exitosamente" ,
"data" : {
"id_ciudad" : 1 ,
"nombre" : "Bogotá D.C." ,
"codigo_postal" : "110111" ,
"id_departamento" : 1 ,
"created_at" : "2024-01-15T10:40:00.000000Z" ,
"updated_at" : "2024-01-15T14:20:00.000000Z" ,
"departamento" : {
"id_departamento" : 1 ,
"nombre" : "Cundinamarca" ,
"id_pais" : 1 ,
"created_at" : "2024-01-15T10:35:00.000000Z" ,
"updated_at" : "2024-01-15T10:35:00.000000Z" ,
"pais" : {
"id_pais" : 1 ,
"nombre" : "Colombia" ,
"created_at" : "2024-01-15T10:30:00.000000Z" ,
"updated_at" : "2024-01-15T10:30:00.000000Z"
}
}
}
}
Endpoint
Path Parameters
The unique identifier of the city to update
Body Parameters
Updated name of the city (max 120 characters)
Updated postal/ZIP code (max 20 characters)
Updated parent state/department ID (must exist in the departamentos table)
Delete City
curl --request DELETE \
--url https://api.coreprojects.com/api/ciudades/1 \
--header 'Authorization: Bearer YOUR_TOKEN'
200 - Success
404 - Not Found
409 - Conflict
{
"success" : true ,
"message" : "Ciudad eliminada exitosamente"
}
Endpoint
DELETE /api/ciudades/{id}
Path Parameters
The unique identifier of the city to delete
Business Rules
A city cannot be deleted if it has associated locations (Ubicaciones). You must first delete all locations before deleting the city.
Get Cities by State
curl --request GET \
--url https://api.coreprojects.com/api/departamentos/1/ciudades \
--header 'Authorization: Bearer YOUR_TOKEN'
{
"success" : true ,
"data" : [
{
"id_ciudad" : 1 ,
"nombre" : "Bogotá" ,
"codigo_postal" : "110111" ,
"id_departamento" : 1 ,
"created_at" : "2024-01-15T10:40:00.000000Z" ,
"updated_at" : "2024-01-15T10:40:00.000000Z" ,
"ubicaciones" : [
{
"id_ubicacion" : 1 ,
"direccion" : "Calle 100 #15-20" ,
"barrio" : "Chicó Norte" ,
"id_ciudad" : 1 ,
"created_at" : "2024-01-15T12:00:00.000000Z" ,
"updated_at" : "2024-01-15T12:00:00.000000Z"
}
]
},
{
"id_ciudad" : 3 ,
"nombre" : "Chía" ,
"codigo_postal" : "250001" ,
"id_departamento" : 1 ,
"created_at" : "2024-01-15T11:30:00.000000Z" ,
"updated_at" : "2024-01-15T11:30:00.000000Z" ,
"ubicaciones" : []
}
]
}
Endpoint
GET /api/departamentos/{id_departamento}/ciudades
Path Parameters
The unique identifier of the state/department
Description
Retrieve all cities that belong to a specific state/department. Each city includes its associated locations.
Get Cities by Postal Code
curl --request GET \
--url https://api.coreprojects.com/api/ciudades/codigo-postal/110111 \
--header 'Authorization: Bearer YOUR_TOKEN'
200 - Success
404 - Not Found
{
"success" : true ,
"data" : [
{
"id_ciudad" : 1 ,
"nombre" : "Bogotá" ,
"codigo_postal" : "110111" ,
"id_departamento" : 1 ,
"created_at" : "2024-01-15T10:40:00.000000Z" ,
"updated_at" : "2024-01-15T10:40:00.000000Z" ,
"departamento" : {
"id_departamento" : 1 ,
"nombre" : "Cundinamarca" ,
"id_pais" : 1 ,
"created_at" : "2024-01-15T10:35:00.000000Z" ,
"updated_at" : "2024-01-15T10:35:00.000000Z" ,
"pais" : {
"id_pais" : 1 ,
"nombre" : "Colombia" ,
"created_at" : "2024-01-15T10:30:00.000000Z" ,
"updated_at" : "2024-01-15T10:30:00.000000Z"
}
}
}
]
}
Endpoint
GET /api/ciudades/codigo-postal/{codigo_postal}
Path Parameters
The postal/ZIP code to search for
Description
Search for cities by their postal code. This endpoint returns all cities that match the provided postal code, including full department and country information.
Relationships
Parent Relationship
State/Department (Departamento) : Each city belongs to one state/department. See the States API for state management.
Country (País) : Through the state relationship, each city is indirectly associated with a country.
Child Relationships
Locations (Ubicaciones) : Each city can have multiple project locations. Use the following endpoint to get locations for a specific city:
GET /api/ciudades/{id_ciudad}/ubicaciones
Projects (Proyectos) : Projects can be filtered by city:
GET /api/ciudades/{id_ciudad}/proyectos
Geographic Hierarchy
The complete geographic hierarchy in Core Projects is:
Country (País) → Countries API
State/Department (Departamento) → States API
City (Ciudad) → Current API
Location (Ubicación) → Locations API
This hierarchy ensures proper organization of construction projects across different geographic regions.