Routes API (Batch Route Calculation)

Use Routes to calculate multiple routes in one request. REST returns JSON. SOAP uses CalculateRoutes.

Illustration of TrackRoad Routes API calculating multiple routes in one request and returning distances and times.
Routes calculates multiple routes in one call—useful for matrix-style comparisons, bulk planning, and faster batch workflows.

Need the full contract?

Swagger includes REST models. SOAP is available via the WSDL.

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 (REST JSON + SOAP)
  7. Common errors
  8. Best practices
  9. Related endpoints

What Routes does#

Routes calculates one or many routes in a single request. Each route uses an ordered list of Location inputs and optional RouteOptions. You can also set a global RoutesOptions applied to all routes.

Tip: If you only need one route, use Route API. If you need multiple routes at once (batch), use this Routes API.

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 conceptual models (RouteSpecification, RouteOptions, Location). The transport differs (JSON vs SOAP envelope + SessionIDHeader).

Authentication (REST & SOAP)#

REST authentication (X-API-Key)#

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

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

SOAP authentication (SessionIDHeader)#

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

Recommended: use REST unless you must integrate with an existing SOAP-only system.

Request schema#

REST request body is a single object (batch): RoutesSpecification with a list of RouteSpecification. SOAP uses the same logical specification inside <CalculateRoutes>.

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 (batch).
RoutesOptions RouteOptions No Global defaults applied to each 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 (routing engine, units, optimize mode, map options).

RouteOptions (summary)#

RouteOptions fields (RoutingService / DistanceUnit / RouteOptimize / Culture / Map options) are similar to the Route endpoint.

Response schema#

REST response (RoutesResult)#

Property Type Description
Results RouteResult[] One result per input RouteSpecification.
Map string Optional map output (depends on options; can be empty).
Errors Error[] Optional warnings/errors.
Status int (enum) 0=None, 1=Success, 2=Failed, 3=SuccessWithErrors.

SOAP response (CalculateRoutesResult)#

SOAP response wraps the same logical shape under <CalculateRoutesResponse>.

Examples (REST JSON + SOAP)#

REST JSON request example (batch)#

This example calculates two routes in one request. Each route has its own Locations list.

{
  "Specifications": [
    {
      "Locations": [
        { "Name": "A", "LatLong": { "Latitude": 37.7946, "Longitude": -122.3950 }, "LocationType": 1 },
        { "Name": "B", "LatLong": { "Latitude": 37.7897, "Longitude": -122.4011 }, "LocationType": 0 },
        { "Name": "C", "LatLong": { "Latitude": 37.7810, "Longitude": -122.4110 }, "LocationType": 2 }
      ],
      "RouteOptions": { "RoutingService": 0, "DistanceUnit": 0, "RouteOptimize": 0 }
    },
    {
      "Locations": [
        { "Name": "Start", "LatLong": { "Latitude": 34.0522, "Longitude": -118.2437 }, "LocationType": 1 },
        { "Name": "Stop 1", "LatLong": { "Latitude": 34.0407, "Longitude": -118.2468 }, "LocationType": 0 },
        { "Name": "Finish", "LatLong": { "Latitude": 34.0522, "Longitude": -118.2437 }, "LocationType": 2 }
      ]
    }
  ],
  "RoutesOptions": { "RoutingService": 0, "DistanceUnit": 0, "RouteOptimize": 0 }
}

REST request examples (multiple languages)#

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

REST JSON response example (shape)#

{
  "Results": [
    {
      "Route": {
        "Distance": 12.34,
        "Time": 1880,
        "Locations": [
          { "Name": "A", "LatLong": { "Latitude": 37.7946, "Longitude": -122.3950 } },
          { "Name": "B", "LatLong": { "Latitude": 37.7897, "Longitude": -122.4011 } },
          { "Name": "C", "LatLong": { "Latitude": 37.7810, "Longitude": -122.4110 } }
        ]
      }
    }
  ],
  "Map": "",
  "Errors": [],
  "Status": 1
}

SOAP request example (CalculateRoutes) — raw XML#

SOAP uses SessionIDHeader with SessionID = TrackServiceKey and SOAPAction http://TrackService.TrackRoad.com/CalculateRoutes.

<!-- POST https://trackservice.trackroad.com/TrackService.asmx -->
<!-- Content-Type: text/xml; charset=utf-8 -->
<!-- SOAPAction: "http://TrackService.TrackRoad.com/CalculateRoutes" -->

<?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>
    <CalculateRoutes xmlns="http://TrackService.TrackRoad.com/">
      <specification>
        <Specifications>
          <RouteSpecification>
            <Locations>
              <Location>
                <Name>A</Name>
                <LocationType>Start</LocationType>
                <LatLong><Latitude>37.7946</Latitude><Longitude>-122.3950</Longitude></LatLong>
              </Location>
              <Location>
                <Name>B</Name>
                <LocationType>Midway</LocationType>
                <LatLong><Latitude>37.7897</Latitude><Longitude>-122.4011</Longitude></LatLong>
              </Location>
              <Location>
                <Name>C</Name>
                <LocationType>Finish</LocationType>
                <LatLong><Latitude>37.7810</Latitude><Longitude>-122.4110</Longitude></LatLong>
              </Location>
            </Locations>

            <RouteOptions>
              <RoutingService>NetRoad</RoutingService>
              <DistanceUnit>Mile</DistanceUnit>
              <RouteOptimize>MinimizeTime</RouteOptimize>
            </RouteOptions>
          </RouteSpecification>
        </Specifications>

        <RoutesOptions>
          <RoutingService>NetRoad</RoutingService>
          <DistanceUnit>Mile</DistanceUnit>
          <RouteOptimize>MinimizeTime</RouteOptimize>
        </RoutesOptions>
      </specification>
    </CalculateRoutes>
  </soap:Body>
</soap:Envelope>

SOAP request examples (multiple languages)#

Place this block right below the “SOAP request example (CalculateRoutes) — raw XML” section above. Each language example sends the same SOAP envelope.

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

SOAP response example (shape)#

Place this below your REST JSON response example.

<?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:Body>
    <CalculateRoutesResponse xmlns="http://TrackService.TrackRoad.com/">
      <CalculateRoutesResult>
        <Results>
          <RouteResult>
            <Route>
              <Distance>12.34</Distance>
              <Time>1880</Time>
              <Locations>
                <Location>
                  <Name>A</Name>
                  <LatLong><Latitude>37.7946</Latitude><Longitude>-122.3950</Longitude></LatLong>
                </Location>
                <Location>
                  <Name>B</Name>
                  <LatLong><Latitude>37.7897</Latitude><Longitude>-122.4011</Longitude></LatLong>
                </Location>
                <Location>
                  <Name>C</Name>
                  <LatLong><Latitude>37.7810</Latitude><Longitude>-122.4110</Longitude></LatLong>
                </Location>
              </Locations>
            </Route>
          </RouteResult>
        </Results>
        <Map></Map>
      </CalculateRoutesResult>
    </CalculateRoutesResponse>
  </soap:Body>
</soap:Envelope>

Common errors#

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

Best practices#

  • Batch smartly: Put multiple route calculations into one Routes call to reduce overhead.
  • Prefer LatLong: Provide coordinates to avoid geocoding ambiguity/cost.
  • Use global RoutesOptions: Set defaults once, override only when needed per route.
  • Keep options consistent: Mixing units/engines across routes can make comparisons harder.

Next step: optimize across vehicles

If you need to assign stops to multiple vehicles and optimize stop order per vehicle, use Dispatch.

Go to Dispatch Swagger UI