Dispatch API (Route Optimization)

Use Dispatch to optimize routes across multiple vehicles and many stops. Dispatch returns an ordered route per vehicle with timing, distance, and assignment output for delivery routing, field service, courier operations, and fleet planning.

TrackRoad Dispatch API overview showing vehicles and stops flowing into optimized routes
Dispatch assigns stops across multiple vehicles and returns optimized routes with stop order, ETA, distance, and duration for each vehicle.

Need the full contract?

Use Swagger for REST models and WSDL for SOAP integration details.

View Swagger UI View SOAP WSDL API Reference Overview

Table of contents

  1. What Dispatch does
  2. Optima mode, Time Window & TimeWindowDepot
  3. Multiple pickups and deliveries
  4. Endpoints and base URLs
  5. Authentication
  6. Request schema
  7. Response schema
  8. Common errors
  9. Best practices
  10. Related endpoints
  11. FAQ

What Dispatch does#

Dispatch solves a multi-vehicle routing problem. It assigns stops to vehicles and orders each route using constraints such as time windows, capacity, priority, and start or finish locations.

LatLong is preferred. Each stop should include LatLong whenever possible. If LatLong is not provided, you must provide Address so the service can geocode the stop.

The Dispatch method accepts a list of vehicles and a list of stop locations. Each vehicle can include a start location and an optional finish location. Each location can contain a name, address fields, and latitude and longitude.

If latitude and longitude are present, TrackRoad uses them directly. Otherwise, the service geocodes the address to obtain coordinates.

Dispatch returns vehicle items. Each vehicle item contains the assigned route as an ordered list of stops, optimized by location, capacity, timing, and other routing factors.

When only one vehicle is available, Dispatch performs route optimization only. Dispatching modes primarily matter when there are multiple vehicles available.

If you are unsure which dispatching mode to use, start with Auto. For highly accurate single-vehicle optimization, use Optima.

Optima mode, Time Window & TimeWindowDepot#

In some languages it may not be possible to pass a null datetime. In that case, use 0001-01-01T00:00:00. Dates older than the system threshold are treated as null values.

For best results, use DispatchMode Optima.

Three variables affect time-window dispatching behavior:

  • CanArriveEarly
  • TimeConstraintArrival
  • TimeConstraintDeparture

Option 1: CanArriveEarly = true

When CanArriveEarly is true, the time window starts at the beginning of the day. If TimeConstraintArrival is null, the stop can be visited any time during the day. If TimeConstraintArrival is set, it defines the latest acceptable arrival time. Departure time is ignored.

Option 2: CanArriveEarly = false

When CanArriveEarly is false, arrival and departure define the allowed time window. If arrival is set and departure is null, the stop is treated like a precise appointment. If both are set, TrackRoad attempts to visit the stop within that time range.

Option 3: Two time windows

You can also specify a second time window using TimeConstraintArrival2 and TimeConstraintDeparture2. This is useful when a stop can only be visited during two separate periods, such as restricted downtown delivery hours. TimeWindowDepot follows the same logic but assumes vehicles start and finish from a common depot.

Breaks can be modeled with LocationType = Break. Multiple pickup and delivery chains support only one delivery time window at the delivery level, and that child time constraint cannot be tighter than the parent constraint.

Multiple pickups and deliveries#

Dispatch supports pickup and delivery chaining. This is useful for courier operations and workflows where one stop must be visited before another.

Use Midway for the first stop in a chain and Delivery to specify the next related location. Use DeliveryNonStop to determine whether the next linked delivery must happen immediately or can occur later in the same route.

For example, if a parcel is picked up at location B and delivered to location M, TrackRoad preserves the required relationship between the pickup and the delivery while still optimizing the route around the remaining stops.

DeliveryNonStop = true

When DeliveryNonStop is true, the linked delivery stop must be visited immediately after the pickup stop.

DeliveryNonStop = false

When DeliveryNonStop is false, the linked delivery must still occur after the pickup, but it does not need to happen immediately.

You can daisy-chain multiple deliveries, such as B → M → N, by setting Delivery and KeepSameOrder on each linked stop.

For round-trip jobs, define pickup, delivery, and return locations as a chain. A common recommendation is DeliveryNonStop = false and KeepSameOrder = true for more flexible optimization while preserving business order.

TrackRoad API round trip stops example
Example: Round trip stops.
TrackRoad API round trip route example
Example: Round trip route.

Endpoints and base URLs#

REST

Item Value
Base URL https://trackservice.trackroad.com
Endpoint POST /rest/dispatch
Full URL https://trackservice.trackroad.com/rest/dispatch
Content-Type application/json

SOAP

Item Value
Endpoint https://trackservice.trackroad.com/TrackService.asmx
WSDL https://trackservice.trackroad.com/TrackService.asmx?WSDL
Method Dispatch
SOAPAction http://trackservice.trackroad.com/Dispatch

SOAP uses the same DispatchSpecification and DispatchResult models. The main difference is the SOAP envelope and header-based authentication.

Authentication#

REST authentication (X-API-Key)

Include your TrackServiceKey in the X-API-Key header on every request. Generate the key in your TrackRoad account at API Authentication .

curl -X POST "https://trackservice.trackroad.com/rest/dispatch" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_TRACKSERVICEKEY" \
  -d '{ "RoutingService": 0, "DistanceUnit": 0, "RouteOptimize": 0, "Vehicles": [], "Locations": [] }'

Keep API keys server-side. Do not embed keys in browser or mobile client code.

SOAP authentication (SessionIDHeader)

For SOAP requests, send your TrackServiceKey in SessionIDHeader as SessionID. Legacy Login and Logout are not required when you use TrackServiceKey authentication.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <SessionIDHeader xmlns="http://trackservice.trackroad.com/">
      <SessionID>YOUR_TRACKSERVICEKEY</SessionID>
    </SessionIDHeader>
  </soap:Header>
  <soap:Body>
    <Dispatch xmlns="http://trackservice.trackroad.com/">
      <specification>
        <RoutingService>0</RoutingService>
        <DistanceUnit>0</DistanceUnit>
        <RouteOptimize>0</RouteOptimize>
        <Vehicles />
        <Locations />
      </specification>
    </Dispatch>
  </soap:Body>
</soap:Envelope>

SOAP namespaces and prefixes may vary depending on your tooling. A WSDL-generated client is usually the easiest option.

Request schema#

The request body is a single object: DispatchSpecification. At minimum, provide vehicles and locations.

DispatchSpecification

Property Type Required Description
RoutingServiceint (enum)NoRouting engine. 0 = NetRoad, 1 = TrackRoad, 2 = Bing. Recommended: 0 = NetRoad.
IsNeedMatchCodeboolNoIf true, includes geocoding match-quality codes where relevant.
CurrentTimestring (date-time)NoCurrent time reference used for time constraints in ISO 8601 format.
DispatchModeint (enum)NoOptimization strategy. For mode recommendations, see Dispatch Modes.
MinimumOptimizationintNoOptimization intensity threshold. Typical range: 1 to 10.
DistanceUnitint (enum)No0 = Mile, 1 = Kilometer.
RouteOptimizeint (enum)No0 = MinimizeTime, 1 = MinimizeDistance. Recommended: 0 = MinimizeTime.
VehiclesVehicle[]NoVehicles available for dispatch.
LocationsLocation[]YesStops to be assigned and ordered.

DispatchMode

Property Type Value Description
Autoint0Automatically selects a suitable dispatching strategy. Best default starting point.
EqualStopint1Attempts to distribute an equal number of stops across vehicles.
SingleRegionint2Useful when vehicles are geographically dispersed but serve stops in similar areas.
MultipleRegionint3Useful for vehicles operating in different cities or distant regions and for real-time field dispatch.
EqualHourint4Attempts to divide work into routes with similar total time.
EqualDistanceint5Attempts to divide work into routes with similar total distance.
TimeWindowint6Prioritizes appointment and delivery windows. Optimization may be reduced to meet timing constraints.
TimeWindowDepotint7Time-window mode that assumes a central depot shared by vehicles.
Optimaint8Highly accurate mode for a single vehicle, with or without time windows.
BalanceLocationint9Balances the number of assigned stops across multiple drivers.
BalanceTimeint10Balances route time across multiple drivers.
MinimumVehiclesint11Selects the minimum number of vehicles required to service all stops, taking routing factors into account.

Vehicle

Property Type Required Description
NamestringRecommendedVehicle identifier displayed in results.
EmailstringNoOptional driver or vehicle contact.
GroupstringNoOptional grouping field such as team, depot, or region.
SpeedintNoOptional speed override. If set to 0, default road speed is used.
MaxStopsintNoMaximum number of stops per route for the vehicle.
MaxWeightdoubleNoMaximum weight capacity for the vehicle.
MaxSkidsintNoMaximum skid capacity for the vehicle.
MaxVolumedoubleNoMaximum volume capacity for the vehicle.
MaxMinutesintNoMaximum route duration for the vehicle.
FuelCostdoubleNoOptional cost parameter used by some optimization modes.
OnTheRoadboolNoIf true, a multi-day route can continue from the prior day’s end location instead of returning to the original start point.
Tinstring (date-time)NoVehicle available-from timestamp.
Toutstring (date-time)NoVehicle available-until timestamp.
StartLocationLocationNoOptional start depot or start position for the vehicle.
FinishLocationLocationNoOptional finish depot or end position for the vehicle.
RolesstringNoOptional role string that can be matched against stop conditions.
TransportTypeint (enum)NoTransport mode such as car, truck, bus, motorcycle, pedestrian, scooter, or bicycle.
ExcludeTollsboolNoSpecifies whether toll roads should be avoided.
ExcludeHighwaysboolNoSpecifies whether highways should be avoided.
UseTruckRouteboolNoSpecifies whether truck routes should be preferred or allowed.
WidthfloatNoVehicle width in meters.
HeightfloatNoVehicle height in meters.
LengthfloatNoVehicle length in meters.
AxleLoadfloatNoVehicle axle load in metric tons.
AxleCountintNoNumber of axles.
TrackRoad API vehicle OnTheRoad feature example
Example: Daily route behavior with OnTheRoad enabled versus disabled.

Location

Each location should include LatLong when possible. If coordinates are missing, Address is required so TrackRoad can geocode the stop.

Property Type Required Description
MatchCodeint (enum)NoGeocode match quality code.
NamestringNoStop label shown in results.
DeliverystringNoLinked delivery location name or customer label.
DeliveryNonStopboolNoDetermines whether the linked delivery must happen immediately after the current stop.
KeepSameOrderboolNoIf true, preserves the relative order defined in the request.
VehiclestringNoOptional pre-assignment to a specific vehicle by name.
DescriptionstringNoOptional notes or description.
PhonestringNoOptional contact phone number.
LatLongLatLongConditionalPreferred coordinate input. Required if Address is not provided.
AddressAddressConditionalAddress input used for geocoding when LatLong is not provided.
PriorityintNoPriority hint for optimization.
WaitintNoService time or wait time at the stop.
VolumedoubleNoVolume demand consumed from vehicle capacity.
WeightdoubleNoWeight demand consumed from vehicle capacity.
SkidsintNoSkid demand consumed from vehicle capacity.
TimeConstraintArrivalstring (date-time)NoPrimary time-window arrival value.
TimeConstraintDeparturestring (date-time)NoPrimary time-window departure value.
TimeConstraintArrival2string (date-time)NoOptional second time-window arrival value.
TimeConstraintDeparture2string (date-time)NoOptional second time-window departure value.
LocationTypeint (enum)No0 = Midway, 1 = Start, 2 = Finish, 3 = Delivery, 4 = MidwayDrop, 5 = Break.
CanArriveEarlyboolNoIf false, arrival before the allowed time window is not permitted.
ConditionsstringNoOptional business rule or role-matching condition.

LatLong

Property Type Required Description
LatitudedoubleYesLatitude in degrees (-90 to 90).
LongitudedoubleYesLongitude in degrees (-180 to 180).

Address

Property Type Required Description
StreetstringRecommendedStreet address.
CitystringRecommendedCity.
StatestringNoState or region.
PostalCodestringNoZIP or postal code.
CountrystringRecommendedCountry.

Response schema#

A successful response returns DispatchResult containing per-vehicle route items and optional errors or warnings.

DispatchResult

Property Type Description
ItemsVehicleItem[]Per-vehicle result items containing the assigned route.
ErrorsError[]Optional errors or warnings.
Statusint (enum)Operation status: 0 = None, 1 = Success, 2 = Failed, 3 = SuccessWithErrors.

VehicleItem

Property Type Description
VehicleVehicleThe vehicle associated with this route.
LocationsLocation[]Ordered locations assigned to that vehicle.

Error

Property Type Description
MessagestringHuman-readable error or warning message.

Examples#

Example request and response code blocks can remain unchanged and do not need localization.

{
  "RoutingService": 0,
  "DistanceUnit": 0,
  "RouteOptimize": 0,
  "DispatchMode": 0,
  "Vehicles": [
    {
      "Name": "Truck 1",
      "StartLocation": { "LatLong": { "Latitude": 37.7946, "Longitude": -122.3950 }, "LocationType": 1 },
      "FinishLocation": { "LatLong": { "Latitude": 37.7946, "Longitude": -122.3950 }, "LocationType": 2 }
    }
  ],
  "Locations": [
    { "Name": "Stop A", "LatLong": { "Latitude": 37.7897, "Longitude": -122.4011 }, "LocationType": 0 },
    { "Name": "Stop B", "LatLong": { "Latitude": 37.7810, "Longitude": -122.4110 }, "LocationType": 0 }
  ]
}

REST request examples (multiple languages)#

curl -X POST "https://trackservice.trackroad.com/rest/dispatch" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_TRACKSERVICEKEY" \
  -d '{
    "RoutingService": 0,
    "DistanceUnit": 0,
    "RouteOptimize": 0,
    "DispatchMode": 0,
    "Vehicles": [
      {
        "Name": "Truck 1",
        "StartLocation": { "LatLong": { "Latitude": 37.7946, "Longitude": -122.3950 }, "LocationType": 1 },
        "FinishLocation": { "LatLong": { "Latitude": 37.7946, "Longitude": -122.3950 }, "LocationType": 2 }
      }
    ],
    "Locations": [
      { "Name": "Stop A", "LatLong": { "Latitude": 37.7897, "Longitude": -122.4011 }, "LocationType": 0 },
      { "Name": "Stop B", "LatLong": { "Latitude": 37.7810, "Longitude": -122.4110 }, "LocationType": 0 }
    ]
  }'

SOAP request examples (multiple languages)#

SOAP uses the same DispatchSpecification model, but it’s wrapped in a SOAP envelope and authenticated via SessionIDHeader (SessionID = TrackServiceKey).

curl -X POST "https://trackservice.trackroad.com/TrackService.asmx" \
  -H "Content-Type: text/xml; charset=utf-8" \
  -H "SOAPAction: http://trackservice.trackroad.com/Dispatch" \
  -d @dispatch-soap.xml

SOAP: Raw request (Envelope + SessionIDHeader)#

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <SessionIDHeader xmlns="http://trackservice.trackroad.com/">
      <SessionID>YOUR_TRACKSERVICEKEY</SessionID>
    </SessionIDHeader>
  </soap:Header>
  <soap:Body>
    <Dispatch xmlns="http://trackservice.trackroad.com/">
      <specification>
        <RoutingService>0</RoutingService>
        <DistanceUnit>0</DistanceUnit>
        <RouteOptimize>0</RouteOptimize>
        <DispatchMode>0</DispatchMode>
        <Vehicles></Vehicles>
        <Locations></Locations>
      </specification>
    </Dispatch>
  </soap:Body>
</soap:Envelope>

JSON: Response example#

{
  "Items": [
    {
      "Vehicle": { "Name": "Truck 1" },
      "Locations": [
        { "Name": "Stop A", "LatLong": { "Latitude": 37.7897, "Longitude": -122.4011 } },
        { "Name": "Stop B", "LatLong": { "Latitude": 37.7810, "Longitude": -122.4110 } }
      ]
    }
  ],
  "Errors": [],
  "Status": 1
}

SOAP: Response example#

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <DispatchResponse xmlns="http://trackservice.trackroad.com/">
      <DispatchResult>
        <Status>1</Status>
        <Errors />

        <Items>
          <VehicleItem>
            <Vehicle>
              <Name>Truck 1</Name>
            </Vehicle>

            <Locations>
              <Location>
                <Name>Stop A</Name>
                <LocationType>0</LocationType>
                <LatLong>
                  <Latitude>37.7897</Latitude>
                  <Longitude>-122.4011</Longitude>
                </LatLong>
              </Location>

              <Location>
                <Name>Stop B</Name>
                <LocationType>0</LocationType>
                <LatLong>
                  <Latitude>37.7810</Latitude>
                  <Longitude>-122.4110</Longitude>
                </LatLong>
              </Location>
            </Locations>
          </VehicleItem>
        </Items>

      </DispatchResult>
    </DispatchResponse>
  </soap:Body>
</soap:Envelope>

Common errors#

  • REST 401 / Unauthorized: Missing or invalid X-API-Key.
  • REST 403 / Forbidden: Key is valid but blocked, expired, or lacks credit.
  • Validation errors: A stop is missing both LatLong and Address, or coordinates are invalid.
  • SOAP authentication errors: Missing or invalid SessionIDHeader or empty SessionID.

Best practices

  • Prefer LatLong to avoid geocoding ambiguity and improve routing consistency.
  • Use StartLocation and FinishLocation for depot-based routing and better ETAs.
  • Add capacity constraints such as weight, volume, and skids for more realistic route assignment.
  • Use time windows when stops must be visited within customer or operational schedules.
  • For SOAP, use TrackServiceKey in SessionIDHeader. Legacy login flow is not required.

FAQ#

What does the Dispatch API do?
Dispatch optimizes stops across multiple vehicles and returns ordered routes per vehicle with timing and distance outputs.
How do I authenticate to Dispatch REST and SOAP?
REST uses your TrackServiceKey in the X-API-Key header. SOAP uses the same TrackServiceKey in SessionIDHeader as SessionID.
Do I need LatLong or Address for stops?
LatLong is preferred. If LatLong is not provided, Address is required so TrackRoad can geocode the stop.

Ready to optimize routes?

Generate your API key, then start integrating Dispatch for multi-vehicle route optimization using REST or SOAP.

Get API Key SOAP WSDL Swagger UI