Overview
The Order Stops API provides read-only access to theorder_stops table, which contains stop-level data for customer orders with tracking status information.
Database Table: order_stops
Purpose:
- Query stops associated with orders (pickups, deliveries)
- Filter by tracking status (en_route, arrived, departed, etc.)
- Get stops with Terminal tracking enabled
order_stops- Customer-facing order datamovement_stops- Internal shipment/movement data (used by operations)
Get Order Stops
GET /api/order_stops/
Retrieve order stop records with optional filtering.Filter by company ID
Filter by order ID
Filter by Terminal vehicle ID
Filter by tracking status:
not_tracked, en_route, arrived, departed, delayed, exception- Query Database: Calls
get_order_stops()which queries theorder_stopstable - Filter Application: Applies provided filters using SQL
WHEREclauses withANDlogic - Ordering: Results are ordered by
order_id,order_sequencefor consistent ordering - Response Conversion: Converts SQLAlchemy rows to Pydantic response models
| Status | Description |
|---|---|
not_tracked | Stop is not being tracked via Terminal |
en_route | Vehicle is en route to this stop |
arrived | Vehicle has arrived at this stop |
departed | Vehicle has departed from this stop |
delayed | Vehicle is delayed (late ETA) |
exception | Exception occurred at this stop |
Get Tracked Order Stops
GET /api/order_stops/tracked
Retrieve all order stops with Terminal tracking enabled. Response:- Calls
get_tracked_order_stops()which queries withterminal_tracking_enabled = True - Returns only stops that are actively being tracked via Terminal API
Get Order Stops by Company
GET /api/order_stops/company/
Retrieve all order stops for a specific company.Company ID to filter by
- Calls
get_order_stops_by_company()with the specified company ID - Returns all stops for that company, ordered by
order_id,order_sequence - Returns empty array if company not found
Data Model
Order Stops Table Schema
| Column | Type | Description |
|---|---|---|
order_id | VARCHAR | Order ID (composite key part 1) |
order_sequence | INT | Stop sequence within order (composite key part 2) |
company_id | VARCHAR | Company ID |
stop_type | VARCHAR | Stop type (PU=Pickup, SO=Delivery) |
city_name | VARCHAR | City name |
state | VARCHAR | State code |
zip_code | VARCHAR | ZIP code |
address | VARCHAR | Street address |
location_name | VARCHAR | Location/facility name |
latitude | NUMERIC | GPS latitude |
longitude | NUMERIC | GPS longitude |
scheduled_arrival_early | TIMESTAMPTZ | Earliest scheduled arrival |
scheduled_arrival_late | TIMESTAMPTZ | Latest scheduled arrival |
actual_arrival | TIMESTAMPTZ | Actual arrival timestamp |
actual_departure | TIMESTAMPTZ | Actual departure timestamp |
tracking_status | VARCHAR | Current tracking status |
terminal_tracking_enabled | BOOLEAN | Whether Terminal tracking is active |
terminal_vehicle_id | VARCHAR | Assigned Terminal vehicle ID |

