Base URL
All branch office endpoints are available at:
http://localhost:8080/api/v1/sucursales
Available Endpoints
The Branch Office Service provides functionality for managing branch locations:
Branch Operations
- GET /api/v1/sucursales - List all branch offices
- GET /api/v1/sucursales/ - Get branch office by ID
- POST /api/v1/sucursales - Create a new branch office
Branch Office Object Structure
Branch offices are represented with the following fields:
{
"id": 1,
"codigoSucursal": "LIM-001",
"nombreSucursal": "Lima Centro",
"direccion": "Av. Abancay 123",
"ciudad": "Lima"
}
Unique branch identifier (auto-generated)
Branch code (e.g., “LIM-001”, “CUS-001”)
Physical address of the branch
City where the branch is located
Usage in Shipments
Branch offices are referenced in shipment creation:
- sucursalOrigenId - Origin branch where the package is dropped off
- sucursalDestinoId - Destination branch where the package will be picked up
Example: List All Branches
curl -X GET http://localhost:8080/api/v1/sucursales
Response:
[
{
"id": 1,
"codigoSucursal": "LIM-001",
"nombreSucursal": "Lima Centro",
"direccion": "Av. Abancay 123",
"ciudad": "Lima"
},
{
"id": 2,
"codigoSucursal": "CUS-001",
"nombreSucursal": "Cusco Principal",
"direccion": "Av. El Sol 456",
"ciudad": "Cusco"
},
{
"id": 3,
"codigoSucursal": "AQP-001",
"nombreSucursal": "Arequipa Centro",
"direccion": "Calle Mercaderes 789",
"ciudad": "Arequipa"
}
]
Example: Get Branch by ID
curl -X GET http://localhost:8080/api/v1/sucursales/1
Response:
{
"id": 1,
"codigoSucursal": "LIM-001",
"nombreSucursal": "Lima Centro",
"direccion": "Av. Abancay 123",
"ciudad": "Lima"
}
Example: Create Branch Office
curl -X POST http://localhost:8080/api/v1/sucursales \
-H "Content-Type: application/json" \
-d '{
"codigoSucursal": "TRU-001",
"nombreSucursal": "Trujillo Norte",
"direccion": "Av. España 321",
"ciudad": "Trujillo"
}'
Response:
{
"id": 4,
"codigoSucursal": "TRU-001",
"nombreSucursal": "Trujillo Norte",
"direccion": "Av. España 321",
"ciudad": "Trujillo"
}
Branch offices must be created before they can be used as origin or destination in shipments.
Branch Code Convention
Branch codes typically follow the pattern: {CITY}-{NUMBER}
LIM-001 - Lima, branch 1
CUS-001 - Cusco, branch 1
AQP-001 - Arequipa, branch 1
This convention helps with quick identification of branch locations.