---
title: /solveODCostMatrix 
uid: travelCostMatrix-service-direct
description: "Find directions using the global route service available with ArcGIS Location Services."
context:
  requestType: "direct"
---

import TCMServiceDesc from "../../../shared/routing/snippets/_travelCostMatrix-service.mdx"
import Origins from "../../../shared/routing/snippets/request-parameters/_OD-origins.mdx"
import Destinations from "../../../shared/routing/snippets/request-parameters/_OD-destinations.mdx"
import Token from "../../../shared/routing/snippets/request-parameters/_Token.mdx"
import ResponseFormat from "../../../shared/routing/snippets/request-parameters/_ResponseFormat.mdx"
import Impedance from "../../../shared/routing/snippets/request-parameters/_Impedance-JDR-OnE.mdx"
import AttributeParameterValues from "../../../shared/routing/snippets/request-parameters/_AttributeParameterValues-JDR-OnE.mdx"
import AccumulateAttrNames from "../../../shared/routing/snippets/request-parameters/_AccumulateAttributeNames-DR-OnE.mdx"
import TravelModes from "../../../shared/routing/snippets/request-parameters/_TravelMode.mdx"
import Context from "../../../shared/routing/snippets/request-parameters/_Context.mdx"
import LineBarriers from "../../../shared/routing/snippets/request-parameters/_LineBarriers.mdx"
import LocateSettings from "../../../shared/routing/snippets/request-parameters/_LocateSettings.mdx"
import PointBarriers from "../../../shared/routing/snippets/request-parameters/_PointBarriers.mdx"
import PolygonBarriers from "../../../shared/routing/snippets/request-parameters/_PolygonBarriers.mdx"
import UTurnAtJunctions from "../../../shared/routing/snippets/request-parameters/_UTurnAtJunctions.mdx"
import Restrictions from "../../../shared/routing/snippets/request-parameters/_Restrictions-JDR-OnE.mdx"
import Overrides from "../../../shared/routing/snippets/request-parameters/_Overrides-JDR-OnE.mdx"
import IgnoreInvalidLocations from "../../../shared/routing/snippets/request-parameters/_IgnoreInvalidLocations-JDR-OnE.mdx"
import ImpedanceAttrName from "../../../shared/routing/snippets/request-parameters/_Impedance-JDR-OnE.mdx"
import TimeZoneForTimeOfDay from "../../../shared/routing/snippets/request-parameters/_TimeZoneForTimeOfDay-JR-OnE.mdx"
import LineBarrier from "../../../shared/routing/snippets/request-parameters/_LineBarriers.mdx"
import PolygonBarrier from "../../../shared/routing/snippets/request-parameters/_PolygonBarriers.mdx"
import PointBarrier from "../../../shared/routing/snippets/request-parameters/_PointBarriers.mdx"
import UseHierarchy from "../../../shared/routing/snippets/request-parameters/_OD-UseHierarchy.mdx"
import Cutoff from "../../../shared/routing/snippets/request-parameters/_OD-Cutoff.mdx"
import DestinationCount from "../../../shared/routing/snippets/request-parameters/_OD-DestinationCount.mdx"
import Contxt from "../../../shared/routing/snippets/request-parameters/_Context.mdx"
import GeometryPrecision from "../../../shared/routing/snippets/request-parameters/_GeometryPrecision.mdx"
import ReturnEmptyResults from "../../../shared/routing/snippets/request-parameters/_ReturnEmptyResults.mdx"
import RestrictUTurns from "../../../shared/routing/snippets/request-parameters/_UTurnAtJunctions.mdx"
import ODUsageLimits from "../../../shared/routing/snippets/request-parameters/_OD-UsageLimits.mdx"
import ReturnBarriers from "../../../shared/routing/snippets/request-parameters/_returnBarriers.mdx"
import ReturnPolygonBarriers from "../../../shared/routing/snippets/request-parameters/_returnPolygonBarriers.mdx"
import ReturnPolylineBarriers from "../../../shared/routing/snippets/request-parameters/_returnPolylineBarriers.mdx"
import TimeOfDay from "../../../shared/routing/snippets/request-parameters/_Direct-timeOfDay.mdx"
import TimeOfDayUTC from "../../../shared/routing/snippets/request-parameters/_Direct-timeOfDayIsUTC.mdx"
import ReturnZ from "../../../shared/routing/snippets/request-parameters/_returnZ.mdx"
import GeometryPrecisionZ from "../../../shared/routing/snippets/request-parameters/_GeometryPrecisionZ.mdx"
import ConfigureLimits from "../../../shared/routing/snippets/request-parameters/_configureLimits.mdx"

import OriginDestinationLines from "../../../shared/routing/snippets/output-parameters/_OD-output-origin-destination-lines.mdx"
import OutputOrigins from "../../../shared/routing/snippets/output-parameters/_OD-output-origins.mdx"
import OutputDestinations from "../../../shared/routing/snippets/output-parameters/_OD-output-destinations.mdx"
import DirectionLine from "../../../shared/routing/snippets/output-parameters/_outputDirectionLines.mdx"
import DirectionPoint from "../../../shared/routing/snippets/output-parameters/_outputDirectionPoints.mdx"
import OutputBarriers from "../../../shared/routing/snippets/output-parameters/_barriers.mdx"
import OutputPolylineBarriers from "../../../shared/routing/snippets/output-parameters/_polylineBarriers.mdx"
import OutputPolygonBarriers from "../../../shared/routing/snippets/output-parameters/_polygonBarriers.mdx"
import TraversedEdges from "../../../shared/routing/snippets/output-parameters/_traversedEdges.mdx"
import TraversedJunctions from "../../../shared/routing/snippets/output-parameters/_traversedJunctions.mdx"
import TraversedTurns from "../../../shared/routing/snippets/output-parameters/_traversedTurns.mdx"
import SolveSucceeded from "../../../shared/routing/snippets/output-parameters/_SolveSucceeded.mdx"
import UsageCost from "../../../shared/routing/snippets/output-parameters/_UsageCost.mdx"

import SharedContent from "../../../shared/content/_required-params.mdx"

import ParamMetadata from "../../../shared/components/param-metatdata" 

<Tabs>
<TabNav slot="tab-nav">
  <TabTitle is-active>Publish using publish routing services</TabTitle>
  <TabTitle>Publish using ArcGIS Pro</TabTitle>
</TabNav>

<Tab is-active>
If you publish routing services using [configure routing services](https://enterprise.arcgis.com/en/portal/latest/administer/windows/configure-routing-services.htm) dialog box from ArcGIS Enterprise portal website, or publish using [publish routing services](https://enterprise.arcgis.com/en/server/latest/develop/windows/publishing-routing-services.htm) command line utility, use the following endpoint to access the /solveODCostMatrix direct request. The `{{folderName}}` represents the folder in which the services are being published.

<CodeSwitcher>
<CodeBlock language="curl" label="GET">{`GET https://{{machineName}}/{{serverWebAdaptorName}}/rest/services/{{folderName}}/NetworkAnalysis/NAServer/OriginDestinationCostMatrix/solveODCostMatrix`}</CodeBlock>
<CodeBlock language="curl" label="POST">{`POST https://{{machineName}}/{{serverWebAdaptorName}}/rest/services/{{folderName}}/NetworkAnalysis/NAServer/OriginDestinationCostMatrix/solveODCostMatrix`}</CodeBlock>
</CodeSwitcher>
</Tab>

<Tab is-active>
If you publish routing services using [ArcGIS Pro](https://pro.arcgis.com/en/pro-app/latest/help/analysis/networks/publish-standard-routing-services.htm), use the following endpoint to access the /solveODCostMatrix direct request. The `{{serviceName}}` represents the name of the routing services published from ArcGIS Pro. The `{{layerName}}` is the origin destination cost matrix layer's name in the map used to publish the routing service.

<CodeSwitcher>
<CodeBlock language="curl" label="GET">{`GET https://{{machineName}}/{{serverWebAdaptorName}}/rest/services/{{serviceName}}/NAServer/{{layerName}}/solveODCostMatrix`}</CodeBlock>
<CodeBlock language="curl" label="POST">{`POST https://{{machineName}}/{{serverWebAdaptorName}}/rest/services/{{serviceName}}/NAServer/{{layerName}}/solveODCostMatrix`}</CodeBlock>
</CodeSwitcher>
</Tab>

</Tabs>

<TCMServiceDesc />

## Parameters 

<StyledTable headers="Name, Required, Type, Default, Description">
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[f](#f)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown"></StyledTableCell>
    <StyledTableCell cellStyle="markdown">

    The request response format, either `json` or `pjson`

    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[token](#token)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">

    An access token with the [required privileges](#token).

    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[origins](#origins)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">locations | feature | layer</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">

   Locations that function as starting points in generating the paths to destinations.

    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[destinations](#destinations)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">locations | feature | layer</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">

   Locations that function as ending points in generating the paths from origins.

    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[travelMode](#travelmode)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">object</StyledTableCell>
    <StyledTableCell cellStyle="markdown"> 
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The mode of transportation for the analysis provided as a JSON object.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[defaultCutoff](#defaultcutoff)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The travel time or travel distance value at which to stop searching for destinations from a given origin.  
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[defaultTargetDestinationCount](#defaulttargetdestinationcount)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">integer</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The maximum number of destinations to find per origin. 
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[outputType](#outputtype)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `esriNAODOutputNoLines`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The type of route features that are output by the request.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[timeOfDay](#timeofday)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The time and date to depart from the origins.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[timeOfDayIsUTC](#timeofdayisutc)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The time zone or zones of the `timeOfDay` parameter.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[restrictUTurns](#restrictuturns)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `esriNFSBAllowBacktrack`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Restricts or allows a route to make U-turns at junctions.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[useHierarchy](#usehierarchy)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `true`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Hierarchy used when finding destinations.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[impedanceAttributeName](#impedanceattributename)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `TravelTime`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The type of impedence, such as `Minutes` or `Miles`.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[accumulateAttributeNames](#accumulateattributenames)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `Miles,Kilometers`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Accumulates values other than the value set in the `impedanceAttributeName` parameter.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[restrictionAttributeNames](#restrictionattributenames)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The restrictions that should be honored.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[attributeParameterValues](#attributeparametervalues)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">[object]</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Additional values required by an attribute or restriction.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[barriers](#barriers)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">locations | feature | layer</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      One or more points that act as temporary restrictions, additional time, or distance.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[polylineBarriers](#polylinebarriers)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">feature | layer</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      One ore more lines that prohibit travel anywhere the lines intersect the streets.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[polygonBarriers](#polygonbarriers)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">feature | layer</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Polygons that either prohibit travel or proportionately scale the time or distance required to travel on the streets.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnOrigins](#returnorigins)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Returns origins.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnDestinations](#returndestinations)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Returns destinations.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnBarriers](#returnbarriers)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Returns barriers.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnPolylineBarriers](#returnpolylinebarriers)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Returns polyline barriers.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnPolygonBarriers](#returnpolygonbarriers)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Returns polygon barriers.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[ignoreInvalidLocations](#ignoreinvalidlocations)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `true`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Ignores invalid input locations.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[context](#context)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Additional settings that affect task operation
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[geometryPrecision](#geometryprecision)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The number of decimal places in the response geometries. Applies to x and y values only.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[geometryPrecisionZ](#geometryprecisionz)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The number of decimal places in the response geometries. Applies to z-values only.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnZ](#returnz)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Include the z-values for the returned geometries if supported by the underlying network.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[overrides](#overrides)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      For internal use only.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnEmptyResults](#returnemptyresults)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Returns empty results instead of the error property when a request fails.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[locateSettings](#locatesettings)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">object</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Determines how input data are located.
    </StyledTableCell>
  </StyledTableRow>
</StyledTable>

<Note type={"tip"}>
All the default parameter values mentioned above are assuming that the routing service is published with default settings. If you publish routing services using [ArcGIS Pro](https://pro.arcgis.com/en/pro-app/latest/help/analysis/networks/publish-standard-routing-services.htm#ESRI_SECTION1_61BF401948C74301AF09F7D5D0E6FA35), you can change the default on the network analysis layer before publishing the service. If you publish routing services using [configure routing services](https://enterprise.arcgis.com/en/portal/latest/administer/windows/configure-routing-services.htm) dialog box from ArcGIS Enterprise portal website, or publish using [publish routing services](https://enterprise.arcgis.com/en/server/latest/develop/windows/publishing-routing-services.htm) command line utility, the default values can be changed through the publish routing services [configuration file](https://enterprise.arcgis.com/en/portal/latest/administer/windows/configure-routing-service-config-file.htm), and you can apply the configuration file while publishing the routing services.
</Note>

## Required parameters

<Box>

### f

<SharedContent f/>

</Box>

<Box>

### token

<Token />

</Box>

<Box>

### origins

<Origins />

</Box>

<Box>

### destinations

<Destinations />

</Box>

## Optional parameters

<Box>

### travelMode

<TravelModes />

</Box>

<Box>

### locateSettings

<LocateSettings OD/>

</Box>

<Box>

### defaultTargetDestinationCount 

<DestinationCount />

</Box>

<Box>

### defaultCutoff

<Cutoff />

</Box>

<Box>

### outputType

{/* <p class="space-x-2"><span class="font-sm text-color-3">type:enum</span><span class="font-bold text-[#6d29cc]">default:`esriNAODOutputNoLines`</span></p> */}

<ParamMetadata types={[{name:"string"}]}  defaultValue="esriNAODOutputNoLines" />

**Allowed values:** `esriNAODOutputSparseMatrix`, `esriNAODOutputStraightLines`, `esriNAODOutputNoLines`

Specify the type of route features that are output by the request. The `outputType`parameter can have one of the following values:

-   `esriNAODOutputSparseMatrix`—Return the cost between origin and destination using a sparse matrix format.
-   `esriNAODOutputStraightLines`—Return a straight line between the origin and the destination.
-   `esriNAODOutputNoLines`—Do not return any shapes for the result.

</Box>

<Box>

### timeOfDay 

<TimeOfDay costMatrix/>

</Box>

<Box>

### timeOfDayIsUTC

<TimeOfDayUTC />

</Box>

<Box>

### useHierarchy

<UseHierarchy />

</Box>

<Box>

### restrictUTurns

<RestrictUTurns />

</Box>

<Box>

### impedanceAttributeName

<ImpedanceAttrName />

</Box>

<Box>

### accumulateAttributeNames

<AccumulateAttrNames />

</Box>

<Box>

### restrictionAttributeNames

<Restrictions />

</Box>

<Box>

### attributeParameterValues

<AttributeParameterValues />

</Box>

<Box>

### barriers

<PointBarrier OD/>

</Box>

<Box>

### polylineBarriers

<LineBarrier OD/>

</Box>

<Box>

### polygonBarriers

<PolygonBarrier OD/>

</Box>

<Box>

### returnOrigins

{/* <p class="space-x-2"><span class="font-sm text-color-3">type:enum</span><span class="font-bold text-[#6d29cc]">default:`false`</span></p> */}

<ParamMetadata types={[{name:"boolean"}]}  defaultValue="false" />

Specify whether origins will be returned.

-   `true`—The origins used as input will be returned as part of the `origins` property in the JSON response.
-   `false`—The origins will not be returned.

</Box>

<Box>

### returnDestinations

{/* <p class="space-x-2"><span class="font-sm text-color-3">type:enum</span><span class="font-bold text-[#6d29cc]">default:`false`</span></p> */}

<ParamMetadata types={[{name:"boolean"}]}  defaultValue="false" />

Specify whether destinations will be returned. 

-   `true`—The destinations used as input will be returned as part of the `destinations` property in the JSON response.
-   `false`—The destinations will not be returned.

</Box>

<Box>

### returnBarriers

<ReturnBarriers />

</Box>

<Box>

### returnPolylineBarriers

<ReturnPolylineBarriers />

</Box>

<Box>

### returnPolygonBarriers

<ReturnPolygonBarriers />

</Box>

<Box>

### geometryPrecision 

<GeometryPrecision />

</Box>

<Box>

### geometryPrecisionZ

<GeometryPrecisionZ />

</Box>

<Box>

### returnZ

<ReturnZ />

</Box>

<Box>

### ignoreInvalidLocations

<IgnoreInvalidLocations />

</Box>

<Box>

### context

<Contxt />

</Box>

<Box>

### overrides

<Overrides />

</Box>

<Box>

### returnEmptyResults

<ReturnEmptyResults />

</Box>

## Response objects 

The JSON response from the OD cost matrix request is based on the following syntax when `outputType` is `esriNAODOutputSparseMatrix`. The properties returned in the response are based on the request parameters. For example, the origins property is returned only if the `returnOrigins` parameter is set to `true`. If a request fails, the JSON response only contains the error property. 

For a list of error codes and details, go to [Direct request error codes](/naserver-error-codes)

The examples in the subsequent section illustrate the response returned with specific request parameters.

<CodeBlock language="json" source="../../../shared/routing/code-samples/responseSyntax/direct/ODCostMatrix-JSON_response_direct.json" group="json" maxLines={20} expandable/>

On successful completion, the request returns the lines connecting each origin-destination pair, the output origins, the output destinations, and the status indicating whether the analysis was successful. 


<Box>

### odLines

<OriginDestinationLines />

</Box>

<Box>

### odCostMatrix

When the `outputType` is `esriNAODOutputSparseMatrix`, the output is a JSON object that contains an array identified by `costAttributeNames`  to know what cost attributes are in the matrix and in what index. It then has an associative array of origins (identified by their ObjectID) each of which has an associative array of destinations (identified by their ObjectID) containing an array of costs that are in the same order as the `costAttributeNames` array. 

In the example below, `TravelTime` is the impedance attribute; and `Miles` and `Kilometers` are the accumulate attributes used in the analysis. In the returned matrix that contains the time and distance between origin-destination pair, each nested JSON is composed of origin ObjectID, destination ObjectID, and the costs from origin to destination in the order defined in the `costAttributeNames`. In the example below, travel from origin ObjectID 1 to destination ObjectID 1 takes 62.88 miles. 

**Example**

<CodeBlock language="json" source="../../../shared/routing/code-samples/travelCostMatrix/examples/outputs/odCostMatrix_ex.json" group="json" maxLines={20} expandable/>

</Box>

<Box>

### origins

<OutputOrigins />

</Box>

<Box>

### destinations

<OutputDestinations />

</Box>

<Box>

### barriers

<OutputBarriers />

</Box>

<Box>

### polylineBarriers

<OutputPolylineBarriers />

</Box>

<Box>

### polygonBarriers

<OutputPolygonBarriers />

</Box>

## Examples

<Note type={"mapping-guide"}>

To build client application [see API reference examples](DEVSITE/documentation/mapping-and-location-services/routing-and-directions/travel-cost-matrix/#direct-create-time-distance-matrix)

</Note>

Below is an example of the request showing how to calculate total travel time and distance between two cities.

<Note type={"caution"}>
If you copy and paste the request URL from the examples into a web browser, you need to replace `<yourToken>`  with a valid token. See [Security and authentication](DEVSITE/documentation/security-and-authentication/) to learn more.
</Note>

<Box>

### Calculate total travel time and distance between two cities 

This example shows how to calculate total travel time and distance between two cities (San Diego and Los Angeles), a typical travel cost matrix problem.

Specify the same two cities as the origins and destinations parameter to get travel time and distance traveling between these two cities. Use the JSON structure to specify the origins and destinations parameter, to specify the `Name`  and `ObjectID`  of the cities that will be included in the output.

<Tabs>
<TabNav slot="tab-nav">
  <TabTitle is-active>Request</TabTitle>
  <TabTitle>Response</TabTitle>
</TabNav>

<Tab is-active>

<CodeBlock language="http" source="../../../shared/routing/code-samples/responseExample/direct/OD_submit_job_ent_direct.http" group="HTTP" maxLines={20} expandable/>

</Tab>

<Tab>

The default `outputType` is `esriNAODOutputSparseMatrix`, therefore the response is a matrix format. The default `impedanceAttributeName` is `TravelTime` , and the default `accumulateAttributeNames` are `Miles` and `Kilometers` in the example below. The response contains the travel time, travel distance in miles, and travel distance in kilometers between San Diego and Los Angeles. Within the `odCostMatrix` property, each nested JSON is composed of origin ObjectID, destination ObjectID, and the costs from origin to destination in the order defined in the `costAttributeNames`.

<CodeBlock language="json" source="../../../shared/routing/code-samples/responseExample/direct/ODCostMatrix-JSONExample1.json" group="json" maxLines={20} expandable/>
</Tab>

</Tabs>

</Box>

## Service limits

<ODUsageLimits />

<ConfigureLimits />