Route Calculation
4 API calls in this section.
Endpoints for calculating optimized delivery routes using Google Maps Directions API.
Get Route - Basic
/route/for-driver/{{driver_id}}/delivery/{{delivery_id}}Calculate optimized route from driver's stored location to pickup and delivery locations.
Requires valid JWT token or API key
User must be system admin, dispatcher, tenant admin, or the driver themselves
Authorization
System Admins: Full access to all routes
Dispatchers/Tenant Admins: Access to routes within their tenant
Drivers: Access to their own assigned routes only
Path parameters
| Parameter | Type | Description |
|---|---|---|
driver_idRequired | string | UUID of the driver |
delivery_idRequired | string | UUID of the delivery |
Query parameters
| Parameter | Type | Description |
|---|---|---|
languageOptional | string | Preferred language for response messages (default: en) Example: |
Headers
| Parameter | Type | Description |
|---|---|---|
Authorization | string | JWT token for authentication Example: |
Content-Type | string | Example: |
1curl --globoff --request GET "https://staging-api.ondi.io/functions/v1/route/for-driver/${DRIVER_ID}/delivery/${DELIVERY_ID}?language=en" \2 --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}" \3 --header "Content-Type: application/json"Response examples
1{2 "success": true,3 "message": "Route calculated successfully",4 "route": {5 "encoded_polyline": "u{~vFvyys@fS]...",6 "total_distance_meters": 15420,7 "total_duration_seconds": 1800,8 "waypoints": [9 {10 "lat": 40.7128,11 "lng": -74.006,12 "type": "pickup"13 },14 {15 "lat": 40.7589,16 "lng": -73.9851,17 "type": "dropoff"18 }19 ]20 }21}Get Route - With Current Location
/route/for-driver/{{driver_id}}/delivery/{{delivery_id}}Calculate optimized route using driver's real-time location instead of stored location.
Requires valid JWT token or API key
User must be system admin, dispatcher, tenant admin, or the driver themselves
Use Case
When driver's real-time location is more accurate than stored location
For live route updates during delivery
When driver location hasn't been updated in the database recently
Path parameters
| Parameter | Type | Description |
|---|---|---|
driver_idRequired | string | UUID of the driver |
delivery_idRequired | string | UUID of the delivery |
Query parameters
| Parameter | Type | Description |
|---|---|---|
current_lat | string | Driver's current latitude (-90 to 90) Example: |
current_lng | string | Driver's current longitude (-180 to 180) Example: |
languageOptional | string | Preferred language for response messages (default: en) Example: |
Headers
| Parameter | Type | Description |
|---|---|---|
Authorization | string | JWT token for authentication Example: |
Content-Type | string | Example: |
1curl --globoff --request GET "https://staging-api.ondi.io/functions/v1/route/for-driver/${DRIVER_ID}/delivery/${DELIVERY_ID}?current_lat=${CURRENT_LAT}¤t_lng=${CURRENT_LNG}&language=en" \2 --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}" \3 --header "Content-Type: application/json"Response examples
1{2 "success": true,3 "message": "Route calculated successfully",4 "route": {5 "encoded_polyline": "u{~vFvyys@fS]...",6 "total_distance_meters": 12350,7 "total_duration_seconds": 1620,8 "waypoints": [9 {10 "lat": 40.7128,11 "lng": -74.006,12 "type": "pickup"13 },14 {15 "lat": 40.7589,16 "lng": -73.9851,17 "type": "dropoff"18 }19 ]20 }21}Get Route - Basic
/route/for-driver/{{driver_id}}/delivery/{{delivery_id}}Calculate optimized route from driver's stored location to pickup and delivery locations.
Requires valid JWT token or API key
User must be system admin, dispatcher, tenant admin, or the driver themselves
Authorization
System Admins: Full access to all routes
Dispatchers/Tenant Admins: Access to routes within their tenant
Drivers: Access to their own assigned routes only
Path parameters
| Parameter | Type | Description |
|---|---|---|
driver_idRequired | string | UUID of the driver |
delivery_idRequired | string | UUID of the delivery |
Query parameters
| Parameter | Type | Description |
|---|---|---|
languageOptional | string | Preferred language for response messages (default: en) Example: |
Headers
| Parameter | Type | Description |
|---|---|---|
Authorization | string | JWT token for authentication Example: |
Content-Type | string | Example: |
1curl --globoff --request GET "https://staging-api.ondi.io/functions/v1/route/for-driver/${DRIVER_ID}/delivery/${DELIVERY_ID}?language=en" \2 --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}" \3 --header "Content-Type: application/json"Response examples
1{2 "success": true,3 "message": "Route calculated successfully",4 "route": {5 "encoded_polyline": "u{~vFvyys@fS]...",6 "total_distance_meters": 15420,7 "total_duration_seconds": 1800,8 "waypoints": [9 {10 "lat": 40.7128,11 "lng": -74.006,12 "type": "pickup"13 },14 {15 "lat": 40.7589,16 "lng": -73.9851,17 "type": "dropoff"18 }19 ]20 }21}Get Route - With Current Location
/route/for-driver/{{driver_id}}/delivery/{{delivery_id}}Calculate optimized route using driver's real-time location instead of stored location.
Requires valid JWT token or API key
User must be system admin, dispatcher, tenant admin, or the driver themselves
Use Case
When driver's real-time location is more accurate than stored location
For live route updates during delivery
When driver location hasn't been updated in the database recently
Path parameters
| Parameter | Type | Description |
|---|---|---|
driver_idRequired | string | UUID of the driver |
delivery_idRequired | string | UUID of the delivery |
Query parameters
| Parameter | Type | Description |
|---|---|---|
current_lat | string | Driver's current latitude (-90 to 90) Example: |
current_lng | string | Driver's current longitude (-180 to 180) Example: |
languageOptional | string | Preferred language for response messages (default: en) Example: |
Headers
| Parameter | Type | Description |
|---|---|---|
Authorization | string | JWT token for authentication Example: |
Content-Type | string | Example: |
1curl --globoff --request GET "https://staging-api.ondi.io/functions/v1/route/for-driver/${DRIVER_ID}/delivery/${DELIVERY_ID}?current_lat=${CURRENT_LAT}¤t_lng=${CURRENT_LNG}&language=en" \2 --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}" \3 --header "Content-Type: application/json"Response examples
1{2 "success": true,3 "message": "Route calculated successfully",4 "route": {5 "encoded_polyline": "u{~vFvyys@fS]...",6 "total_distance_meters": 12350,7 "total_duration_seconds": 1620,8 "waypoints": [9 {10 "lat": 40.7128,11 "lng": -74.006,12 "type": "pickup"13 },14 {15 "lat": 40.7589,16 "lng": -73.9851,17 "type": "dropoff"18 }19 ]20 }21}