Routes API (Batch Route Calculation)

Use Routes to calculate multiple routes in one request. REST returns JSON, while SOAP uses CalculateRoutes for batch route calculation workflows and legacy integrations.

Illustration of TrackRoad Routes API calculating multiple routes in one request and returning distances and times.
Routes calculates multiple routes in one call, making it useful for bulk route planning, route comparison, and batch routing workflows.

Need the full API contract?

Swagger covers the REST models, while the SOAP WSDL supports legacy TrackService integrations.

View Swagger UI View SOAP WSDL API Reference Overview

Table of Contents

  1. What Routes does
  2. Endpoints and base URLs
  3. Authentication (REST & SOAP)
  4. Request schema
  5. Response schema
  6. Examples
  7. Common errors
  8. Best practices
  9. Related endpoints
  10. FAQ

What Routes does#

Routes calculates one or many routes in a single request. This makes it useful when you need batch route calculation instead of sending many single-route calls.

Each route uses an ordered list of Location inputs and optional RouteOptions. You can also define a global RoutesOptions object that applies defaults across the full request.

Tip: If you only need one route, use Route API . If you need to calculate multiple routes at once, use Routes.

Endpoints and base URLs#

REST (JSON)

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

SOAP (CalculateRoutes)

Item Value
SOAP URL https://trackservice.trackroad.com/TrackService.asmx
WSDL https://trackservice.trackroad.com/TrackService.asmx?WSDL
Method CalculateRoutes
SOAPAction http://TrackService.TrackRoad.com/CalculateRoutes
Content-Type text/xml; charset=utf-8

SOAP and REST share the same core routing concepts, such as RouteSpecification, RouteOptions, and Location. The main difference is transport: JSON for REST and SOAP envelope + SessionIDHeader for SOAP.

Authentication (REST & SOAP)#

REST authentication (X-API-Key)

Include your TrackServiceKey in the X-API-Key header on every REST request. See API Authentication .

SOAP authentication (SessionIDHeader)

SOAP requests use SessionIDHeader. Send your TrackServiceKey as SessionID for each CalculateRoutes call.

Recommended: use REST unless you need to integrate with an existing SOAP-only or legacy enterprise system.

Request schema#

The REST request body is a single batch object: RoutesSpecification, which contains a list of RouteSpecification items. SOAP uses the same logical structure inside the CalculateRoutes operation.

Shared models

Location, LatLong, and Address are shared across endpoints. See Dispatch API (shared models) .

RoutesSpecification (REST)

Property Type Required Description
Specifications RouteSpecification[] Yes* One item per route you want to calculate in the batch request.
RoutesOptions RouteOptions No Global defaults applied to every route unless overridden by per-route RouteOptions.

RouteSpecification

Property Type Required Description
Locations Location[] Yes* Stops for this route. Order may be optimized based on RouteOptions.
RouteOptions RouteOptions No Per-route overrides for routing engine, units, optimization mode, culture, and map options.

RouteOptions (summary)

RouteOptions fields such as RoutingService, DistanceUnit, RouteOptimize, Culture, and map-related settings are similar to the Route endpoint and can be applied globally or per route.

Response schema#

REST response (RoutesResult)

Property Type Description
Results RouteResult[] One result per input RouteSpecification.
Map string Optional map output depending on options. It may be empty.
Errors Error[] Optional warnings and errors returned by the service.
Status int (enum) 0=None, 1=Success, 2=Failed, 3=SuccessWithErrors.

SOAP response (CalculateRoutesResult)

SOAP wraps the same logical result structure inside CalculateRoutesResponse and CalculateRoutesResult.

Examples#

Use the examples below to understand how TrackRoad Routes works with both REST JSON and SOAP CalculateRoutes. The example code blocks should remain unchanged across languages.

REST request body (JSON)#

{
  "Locations": [
    { "Name": "Start", "LatLong": { "Latitude": 37.7946, "Longitude": -122.3950 }, "LocationType": 1 },
    { "Name": "Stop A", "LatLong": { "Latitude": 37.7897, "Longitude": -122.4011 }, "LocationType": 0 },
    { "Name": "Finish", "LatLong": { "Latitude": 37.7810, "Longitude": -122.4110 }, "LocationType": 2 }
  ],
  "RouteOptions": {
    "RoutingService": 2,
    "DistanceUnit": 0,
    "RouteOptimize": 0,
    "Culture": "en-US",
    "ZoomLevel": 0
  }
}

REST call examples#

curl -X POST "https://trackservice.trackroad.com/rest/Route" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_TRACKSERVICEKEY" \
  -d @route-request.json

SOAP request (CalculateRoute)#

SOAP requires SessionIDHeader. Replace YOUR_SESSION_ID with the session id returned from SOAP Login.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <SessionIDHeader xmlns="http://TrackService.TrackRoad.com/">
      <SessionID>YOUR_SESSION_ID</SessionID>
    </SessionIDHeader>
  </soap:Header>

  <soap:Body>
    <CalculateRoute xmlns="http://TrackService.TrackRoad.com/">
      <specification>
        <Locations>
          <Location>
            <Name>Start</Name>
            <LatLong><Latitude>37.7946</Latitude><Longitude>-122.3950</Longitude></LatLong>
            <LocationType>Start</LocationType>
          </Location>

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

          <Location>
            <Name>Finish</Name>
            <LatLong><Latitude>37.7810</Latitude><Longitude>-122.4110</Longitude></LatLong>
            <LocationType>Finish</LocationType>
          </Location>
        </Locations>

        <RouteOptions>
          <RoutingService>Bing</RoutingService>
          <DistanceUnit>Mile</DistanceUnit>
          <RouteOptimize>MinimizeTime</RouteOptimize>
          <Culture>en-US</Culture>
          <ZoomLevel>0</ZoomLevel>
        </RouteOptions>
      </specification>
    </CalculateRoute>
  </soap:Body>
</soap:Envelope>

SOAP call examples#

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

Response example (REST JSON)#

{
  "Route": {
    "Distance": 5.42,
    "Time": 1180,
    "RouteLegs": [
      {
        "Distance": 2.10,
        "Time": 480,
        "Itinerary": {
          "Items": [
            {
              "Distance": 0.2,
              "Time": 40,
              "Text": "Head north on ...",
              "LatLong": { "Latitude": 37.79, "Longitude": -122.39 }
            }
          ]
        }
      }
    ],
    "Points": [
      { "Latitude": 37.7946, "Longitude": -122.3950 },
      { "Latitude": 37.7897, "Longitude": -122.4011 }
    ],
    "Map": null
  },
  "Errors": [],
  "Status": 1
}

Common errors#

  • REST 401 / Unauthorized: Missing or invalid X-API-Key.
  • REST 403 / Forbidden: Key is valid but blocked, expired, or lacks available credit.
  • SOAP authentication failure: Missing or invalid SessionIDHeader. SessionID must be your TrackServiceKey.
  • Validation errors: Missing Locations, invalid coordinates, or invalid enum values.

Best practices#

  • Batch smartly: Put multiple route calculations into one Routes call to reduce request overhead.
  • Prefer LatLong: Provide coordinates whenever possible to reduce geocoding ambiguity and improve performance.
  • Use global RoutesOptions: Set shared defaults once and override only where necessary per route.
  • Keep options consistent: Mixing routing engines, units, or optimization modes across routes can make comparisons harder.

FAQ#

What does the Routes API do?
Routes API calculates one or many routes in a single request. Each result can include ordered locations, distance, time, and optional map output depending on options.
How do I authenticate to Routes (REST and SOAP)?
REST requests send TrackServiceKey in the X-API-Key header. SOAP CalculateRoutes requests send TrackServiceKey in SessionIDHeader as SessionID.
When should I use Routes vs Route?
Use Route when you need to calculate a single route. Use Routes when you want to calculate multiple routes in one batch request.
What are the most common Routes API errors?
Common errors include missing or invalid X-API-Key, SOAP SessionIDHeader authentication failures, missing Locations, invalid coordinates, and invalid enum values.

Next step: optimize across vehicles

If you need to assign stops to multiple vehicles and optimize stop order for each vehicle, continue with Dispatch API.

Go to Dispatch Swagger UI