Skip to main content

Assignments

9 API calls in this section.

List Assignments

Delivery & Last-Mile / Assignments
GET/delivery/assignments?page=1&limit=10&status=&driver_id=&delivery_id=&bulk_assignment_id=&sort_by=&sort_order=desc&column_filters=&tenant_id=&language=en

Get a list of delivery assignments with pagination, filtering, sorting and stats. Admin users can view all assignments; drivers can only view their own.

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request GET "$ONDI_BASE_URL/delivery/assignments?page=1&limit=10&status=&driver_id=&delivery_id=&bulk_assignment_id=&sort_by=&sort_order=desc&column_filters=&tenant_id=&language=en" \2  --header "Authorization: Bearer {{access_token}}"

Query parameters

pageOptional
query string

1

Page number for pagination

limitOptional
query string

10

Number of items per page

statusOptional
query string

Filter by assignment status (pending, accepted, rejected, completed)

driver_idOptional
query string

Filter by driver ID (Admin only; drivers always see their own assignments)

delivery_idOptional
query string

Filter by delivery ID

bulk_assignment_idOptional
query string

Filter by bulk assignment ID

sort_byOptional
query string

Column to sort by. Allowed: assignment_time. Defaults to assignment_time desc when not provided.

sort_orderOptional
query string

desc

Sort direction: asc or desc (default: desc)

column_filtersOptional
query string

JSON string of column filters. Supported keys: status, driver_id, vehicle_id, delivery_id, assigned_by, bulk_assignment_id, external_reference_id (string ILIKE), delivery_code (integer exact), assignment_time ({from?, to?} date range). Example: {"driver_id":"5c5cd7f0-2b31-402f-872d-81cf17058fe2","assigned_by":"e40f4705-361e-4fcf-a221-49857de4fa82"}

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Responses

Success Response200OK
Error - Invalid column_filters JSON400Bad Request
Error - Unauthorized403Forbidden

Create Assignment

Delivery & Last-Mile / Assignments
POST/delivery/assignments?tenant_id=&language=en

Create a new delivery assignment. Only users with 'manage:operations:tenant' permission can create assignments. The assignment row, driver capacity, and directly-assigned delivery status are committed atomically. Google route calculation runs after creation and stores route_details asynchronously, so route availability does not delay or determine assignment success. Zone Validation: - Uses pickup_zone_id / dropoff_zone_id from delivery_list_view (persisted on deliveries) and always validates driver zone access (no silent skip) - If driver has all_zones = true, they can be assigned to any delivery - If driver has all_zones = false, they must have the pickup zone and/or delivery zone assigned via delivery_zone_drivers table - Errors: driver_not_allowed_in_pickup_zone, driver_not_allowed_in_delivery_zone, driver_not_allowed_in_zones, delivery_zone_validation_unavailable (row missing from view). On view query failure: internal_server_error (500)

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request POST "$ONDI_BASE_URL/delivery/assignments?tenant_id=&language=en" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "delivery_id": "uuid",7  "driver_id": "uuid",8  "vehicle_id": "uuid",9  "estimated_pickup_time": "2023-08-01T13:00:00Z",10  "estimated_delivery_time": "2023-08-01T14:00:00Z",11  "sequence_number": 1,12  "notes": "Please deliver with care"13}'
Request body
json
1{2  "delivery_id": "uuid",3  "driver_id": "uuid",4  "vehicle_id": "uuid",5  "estimated_pickup_time": "2023-08-01T13:00:00Z",6  "estimated_delivery_time": "2023-08-01T14:00:00Z",7  "sequence_number": 1,8  "notes": "Please deliver with care"9}

Query parameters

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Request body fields

delivery_idExample
string

Example field from the request body.

driver_idExample
string

Example field from the request body.

vehicle_idExample
string

Example field from the request body.

estimated_pickup_timeExample
string

Example field from the request body.

estimated_delivery_timeExample
string

Example field from the request body.

sequence_numberExample
number

Example field from the request body.

notesExample
string

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Content-TypeOptional
header string

application/json

Responses

Success Response201Created
Error - Delivery Already Assigned400Bad Request
Error - Driver Not Found404Not Found
Error - Driver Not Allowed in Pickup Zone400Bad Request
Error - Driver Not Allowed in Delivery Zone400Bad Request

Create Bulk Assignments

Delivery & Last-Mile / Assignments
POST/delivery/assignments/bulk?tenant_id=&language=en

Create multiple delivery assignments in a single request for a single driver. Only users with 'manage:operations:tenant' permission can create bulk assignments. Request Format: - driver_id (required): Single driver ID for all deliveries - delivery_ids (required): Array of delivery IDs to assign Parent/Leg Assignment Contract: - A staged or hybrid parent delivery ID is accepted as dispatcher input. - The backend resolves each parent to its first active non-terminal child leg by sequence_plan order and creates the assignment on that leg, never on the parent. - A child leg in draft status is not available for assignment and returns no_active_child_leg (400). Warehouse receiving/execution must activate that leg first. - If a parent and its active leg are both submitted, the resolved duplicate is rejected. - Successful responses include resolved_deliveries when parent IDs were redirected. Each item contains requested_delivery_id and assigned_delivery_id. Frontends should navigate to or refresh the assigned child leg. Validation: - All resolved deliveries must be in 'pending' status - All resolved deliveries must be internal carrier type - Driver must be active and have a vehicle assigned - Total unit size of all resolved deliveries must fit in driver's vehicle capacity - Every resolved delivery must appear in delivery_list_view for the tenant; otherwise deliveries_zone_context_incomplete (400) with delivery_ids missing from the view - Driver must have access to all required zones (pickup_zone_id / dropoff_zone_id on the resolved delivery when present) unless driver has all_zones enabled; otherwise driver_not_allowed_in_zones and optional missing_zones - No duplicate submitted or resolved delivery IDs allowed Response: - Returns assignment IDs, count, total units, driver capacity used, and optional parent-to-leg resolutions - Creates a single bulk realtime notification record in delivery_realtime_assignments table with: - is_bulk: true - bulk_assignment_id: Unique ID for this bulk operation - assignment_count: Number of deliveries assigned - total_units: Total units consumed - Sends single bulk notification to driver (not individual notifications) - Individual assignments are created in delivery_assignments table for querying

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request POST "$ONDI_BASE_URL/delivery/assignments/bulk?tenant_id=&language=en" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "driver_id": "uuid",7  "delivery_ids": [8    "uuid1",9    "uuid2"10  ]11}'
Request body
json
1{2  "driver_id": "uuid",3  "delivery_ids": [4    "uuid1",5    "uuid2"6  ]7}

Query parameters

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Request body fields

driver_idExample
string

Example field from the request body.

delivery_idsExample
array<string>

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Content-TypeOptional
header string

application/json

Responses

Success Response201Created
Error - Some Deliveries Already Assigned400Bad Request
Error - Some Drivers Not Active400Bad Request

Bulk Accept/Reject Assignments

Delivery & Last-Mile / Assignments
PUT/delivery/assignments/bulk/:bulkAssignmentId?tenant_id=&language=en

Accept or reject all assignments in a bulk operation. Only the assigned driver can accept/reject their own bulk assignments. Request Format: - action (required): "accept" or "reject" Validation: - Driver must be active - All assignments must belong to the specified bulk_assignment_id - All assignments must belong to the authenticated driver - All assignments must be in 'pending' status Accept Action: - Updates all assignments to 'accepted' status - Updates all delivery statuses to 'assigned' - Sends notification to dispatchers Reject Action: - Updates all assignments to 'rejected' status - Frees up driver capacity (total units released) - Sends notification to dispatchers - Deliveries remain in 'pending' status (can be reassigned) Response: - Returns assignment IDs, count, and total units freed (if rejected)

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request PUT "$ONDI_BASE_URL/delivery/assignments/bulk/:bulkAssignmentId?tenant_id=&language=en" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "action": "accept"7}'
Request body
json
1{2  "action": "accept"3}

Path parameters

bulkAssignmentIdRequired
path string

uuid

Bulk assignment ID from bulk assignment creation

Query parameters

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Request body fields

actionExample
string

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Content-TypeOptional
header string

application/json

Responses

Success - Bulk Accept200OK
Success - Bulk Reject200OK
Error - Not All Assignments Pending400Bad Request
Error - Bulk Assignments Not Found404Not Found

Update Assignment

Delivery & Last-Mile / Assignments
PUT/delivery/assignments/:assignmentId?tenant_id=&language=en

Update an existing delivery assignment. Admin users can update any assignment. Drivers can only update their own assignments and are restricted to updating status, actual_pickup_time, actual_delivery_time, notes, and reason (supported as an alias for notes when self-unassigning). When the assignment status is updated, the related delivery status is also updated automatically. Driver change restriction: If the delivery already has route_id or route_session_id, changing driver_id is rejected with cannot_switch_driver_for_routed_delivery. Drivers are also blocked from self-unassigning routed deliveries with cannot_self_unassign_routed_delivery. Zone validation (admin changing driver_id): Same rules as create assignment; failures return delivery_zone_validation_unavailable or driver zone messages (driver_not_allowed_in_*). View load errors return internal_server_error (500).

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request PUT "$ONDI_BASE_URL/delivery/assignments/:assignmentId?tenant_id=&language=en" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "status": "in_progress",7  "actual_pickup_time": "2023-08-01T13:05:00Z",8  "actual_delivery_time": null,9  "notes": "Customer called, will be home in 10 minutes"10}'
Request body
json
1{2  "status": "in_progress",3  "actual_pickup_time": "2023-08-01T13:05:00Z",4  "actual_delivery_time": null,5  "notes": "Customer called, will be home in 10 minutes"6}

Path parameters

assignmentIdRequired
path string

uuid

ID of the assignment to update

Query parameters

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Request body fields

statusExample
string

Example field from the request body.

actual_pickup_timeExample
string

Example field from the request body.

actual_delivery_timeExample
null

Example field from the request body.

notesExample
string

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Content-TypeOptional
header string

application/json

Responses

Success Response200OK
Error - Invalid Status Transition400Bad Request
Error - Delivery Already In Route409Conflict
Error - Self Unassign Blocked For Routed Delivery409Conflict

Unassign Assignment (Dispatcher)

Delivery & Last-Mile / Assignments
POST/delivery/assignments/:assignmentId/unassign?tenant_id=&language=en

Dispatcher-only. Unassign the current driver from an assignment. If tenant setting assignment_change_settings.enabled is false, the request is rejected. If the assignment is post-pickup and allow_unassign_after_pickup is false, the request is rejected.

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request POST "$ONDI_BASE_URL/delivery/assignments/:assignmentId/unassign?tenant_id=&language=en" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "reason": "Operational change"7}'
Request body
json
1{2  "reason": "Operational change"3}

Path parameters

assignmentIdRequired
path string

uuid

Assignment ID

Query parameters

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Request body fields

reasonExample
string

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Content-TypeOptional
header string

application/json

Responses

Success Response200OK

Switch Assignment Driver (Dispatcher)

Delivery & Last-Mile / Assignments
POST/delivery/assignments/:assignmentId/switch-driver?tenant_id=&language=en

Dispatcher-only. Switch the driver on an assignment using the same assignment record. Respects assignment_change_settings and validates driver zones, capacity, and primary vehicle. If the delivery already has route_id or route_session_id, the switch is rejected with cannot_switch_driver_for_routed_delivery.

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request POST "$ONDI_BASE_URL/delivery/assignments/:assignmentId/switch-driver?tenant_id=&language=en" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "driver_id": "uuid",7  "reason": "Driver changed"8}'
Request body
json
1{2  "driver_id": "uuid",3  "reason": "Driver changed"4}

Path parameters

assignmentIdRequired
path string

uuid

Assignment ID

Query parameters

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Request body fields

driver_idExample
string

Example field from the request body.

reasonExample
string

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Content-TypeOptional
header string

application/json

Responses

Success Response200OK
Error - Delivery Already In Route409Conflict

Update Assignment Route

Delivery & Last-Mile / Assignments
POST/delivery/assignments/:assignmentId/route?tenant_id=&language=en

Update the route details for an existing assignment. Admin users can update any assignment's route. Drivers can only update routes for their own assignments.

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request POST "$ONDI_BASE_URL/delivery/assignments/:assignmentId/route?tenant_id=&language=en" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "route_details": {7    "distance": 18.5,8    "duration": 55,9    "polyline": "updated_encoded_polyline_string",10    "stops": [11      {12        "location": {13          "latitude": 37.7749,14          "longitude": -122.419415        },16        "sequence": 1,17        "estimated_arrival": "2023-08-01T13:00:00Z"18      },19      {20        "location": {21          "latitude": 37.7694,22          "longitude": -122.486223        },24        "sequence": 2,25        "estimated_arrival": "2023-08-01T13:30:00Z"26      }27    ]28  }29}'
Request body
json
1{2  "route_details": {3    "distance": 18.5,4    "duration": 55,5    "polyline": "updated_encoded_polyline_string",6    "stops": [7      {8        "location": {9          "latitude": 37.7749,10          "longitude": -122.419411        },12        "sequence": 1,13        "estimated_arrival": "2023-08-01T13:00:00Z"14      },15      {16        "location": {17          "latitude": 37.7694,18          "longitude": -122.486219        },20        "sequence": 2,21        "estimated_arrival": "2023-08-01T13:30:00Z"22      }23    ]24  }25}

Path parameters

assignmentIdRequired
path string

uuid

ID of the assignment to update route for

Query parameters

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Request body fields

route_detailsExample
object

Example field from the request body.

route_details.distanceExample
number

Example field from the request body.

route_details.durationExample
number

Example field from the request body.

route_details.polylineExample
string

Example field from the request body.

route_details.stopsExample
array<object>

Example field from the request body.

route_details.stops.locationExample
object

Example field from the request body.

route_details.stops.sequenceExample
number

Example field from the request body.

route_details.stops.estimated_arrivalExample
string

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Content-TypeOptional
header string

application/json

Responses

Success Response200OK
Error - Route Details Required400Bad Request

Get Assignment

Delivery & Last-Mile / Assignments
GET/delivery/assignments/:assignmentId?tenant_id=&language=en

Get details for a specific delivery assignment. Admin users can view any assignment, while drivers can only view their own assignments.

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request GET "$ONDI_BASE_URL/delivery/assignments/:assignmentId?tenant_id=&language=en" \2  --header "Authorization: Bearer {{access_token}}"

Path parameters

assignmentIdRequired
path string

uuid

ID of the assignment to retrieve

Query parameters

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Responses

Success Response200OK
Error - Assignment Not Found404Not Found
Error - Unauthorized403Forbidden
Error - Tenant Not Found404Not Found