Endpoint
PUT /api/v1/envios/actualizar-estado
Update the status of an existing shipment. This endpoint allows manual status transitions for shipment workflow management.
Request Body
ID of the shipment to update
New status for the shipment. Valid values:
PENDIENTE - Shipment pending/registered
EN_TRANSITO - In transit
DISPONIBLE - Available for pickup
ENTREGADO - Delivered
CANCELADO - Cancelled
Response
Success message indicating the status was updated
ID of the updated shipment
The new status that was applied
Example Request
curl -X PUT http://localhost:8080/api/v1/envios/actualizar-estado \
-H "Content-Type: application/json" \
-d '{
"envioId": 42,
"nuevoEstado": "EN_TRANSITO"
}'
Example Response
{
"mensaje": "Estado actualizado exitosamente a: EN_TRANSITO",
"envioId": "42",
"nuevoEstado": "EN_TRANSITO"
}
Error Response
If the shipment is not found:
{
"error": "EnvioNotFoundException",
"message": "Envío no encontrado con id: 42"
}
Ensure status transitions follow your business logic. Invalid transitions (e.g., from ENTREGADO to PENDIENTE) are not validated by this endpoint.
Alternative Status Update Endpoints
For specific status transitions, consider using these specialized endpoints:
- PUT /api/v1/envios//disponible - Mark as available for pickup
- PUT /api/v1/envios//cancelar - Cancel a shipment
- POST /api/v1/envios/retirar - Process delivery (sets to ENTREGADO)
Valid Status Transitions
Typical workflow:
PENDIENTE → Initial state when created
EN_TRANSITO → When assigned to a vehicle
DISPONIBLE → When arrived at destination
ENTREGADO → When picked up by recipient
Alternative:
CANCELADO → Can be set from any state before delivery
This endpoint provides flexibility for manual status updates. For automated workflows, use the specialized endpoints that include additional validations.