---
title: /solveClosestFacility 
uid: closestFacility-service-direct
description: "Find directions using the global route service available with ArcGIS Location Services."
context:
    requestType: "direct"
---
import Token from "../../../shared/routing/snippets/request-parameters/_Token.mdx"
import CFServiceDescription from "../../../shared/routing/snippets/_closestFacility-service.mdx"
import Incidents from "../../../shared/routing/snippets/request-parameters/_CF-incidents.mdx"
import Facilities from "../../../shared/routing/snippets/request-parameters/_CF-facilities.mdx"
import Cutoff from "../../../shared/routing/snippets/request-parameters/_CF-defaultCutoff.mdx"
import FacilityCount from "../../../shared/routing/snippets/request-parameters/_CF-TargetFacilityCount.mdx"
import TravelDirection from "../../../shared/routing/snippets/request-parameters/_CF-TravelDirection.mdx"
import Impedance from "../../../shared/routing/snippets/request-parameters/_Impedance-JDR-OnE.mdx"
import MeasurementUnits from "../../../shared/routing/snippets/request-parameters/_MeasurementUnits-JR-OnE.mdx"
import AttributeParameterValues from "../../../shared/routing/snippets/request-parameters/_AttributeParameterValues-JDR-OnE.mdx"
import TravelModes from "../../../shared/routing/snippets/request-parameters/_TravelMode.mdx"
import AnalysisRegion from "../../../shared/routing/snippets/request-parameters/_AnalysisRegion-JR-OnE.mdx"
import Context from "../../../shared/routing/snippets/request-parameters/_Context.mdx"
import DirectionsLanguage from "../../../shared/routing/snippets/request-parameters/_DirectionsLanguage-JDR-OnE.mdx"
import DistanceUnits from "../../../shared/routing/snippets/request-parameters/_DistanceUnits.mdx"
import LineBarriers from "../../../shared/routing/snippets/request-parameters/_LineBarriers.mdx"
import LocateSettings from "../../../shared/routing/snippets/request-parameters/_LocateSettings.mdx"
import OutputFormat from "../../../shared/routing/snippets/request-parameters/_OutputFormat-JR-OnE.mdx"
import PointBarriers from "../../../shared/routing/snippets/request-parameters/_PointBarriers.mdx"
import PolygonBarriers from "../../../shared/routing/snippets/request-parameters/_PolygonBarriers.mdx"
import SaveOutputNALayer from "../../../shared/routing/snippets/request-parameters/_SaveOutputNALayer-JR-OnE.mdx"
import SaveRouteData from "../../../shared/routing/snippets/request-parameters/_SaveRouteData-JR-OnE.mdx"
import TimeUnits from "../../../shared/routing/snippets/request-parameters/_TimeUnits.mdx"
import DirectionsStyleName from "../../../shared/routing/snippets/request-parameters/_DirectionsStyleName-JDR-OnE.mdx"
import DirectionsDistanceUnits from "../../../shared/routing/snippets/request-parameters/_DirectionsDistanceUnits-JDR-OnE.mdx"
import UseTimeWindows from "../../../shared/routing/snippets/request-parameters/_UseTimeWindows-JDR-OnE.mdx"
import PopulateDirectionsRoute from "../../../shared/routing/snippets/request-parameters/_PopulateDirections-JDR-OnE.mdx"
import UTurnAtJunctions from "../../../shared/routing/snippets/request-parameters/_UTurnAtJunctions.mdx"
import UseHierarchy from "../../../shared/routing/snippets/request-parameters/_CF-useHierarchy.mdx"
import Restrictions from "../../../shared/routing/snippets/request-parameters/_Restrictions-JDR-OnE.mdx"
import RtLineSimplificationTol from "../../../shared/routing/snippets/request-parameters/_RouteLineSimplificationTolerance-JR-OnE.mdx"
import Overrides from "../../../shared/routing/snippets/request-parameters/_Overrides-JDR-OnE.mdx"
import RouteShape from "../../../shared/routing/snippets/request-parameters/_RouteShape-JR-OnE.mdx"
import DistanceImpedance from "../../../shared/routing/snippets/request-parameters/_DistanceImpedance-JR-OnE.mdx"
import TimeImpedance from "../../../shared/routing/snippets/request-parameters/_TimeImpedance-JR-OnE.mdx"
import IgnoreInvalidLocations from "../../../shared/routing/snippets/request-parameters/_IgnoreInvalidLocations-JDR-OnE.mdx"
import TimeOfDay from "../../../shared/routing/snippets/request-parameters/_Direct-timeOfDay.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 CFUsageLimits from "../../../shared/routing/snippets/request-parameters/_CF-UsageLimits.mdx"
import AccumulateAttrNames from "../../../shared/routing/snippets/request-parameters/_AccumulateAttributeNames-DR-OnE.mdx"
import DirectionsOutputType from "../../../shared/routing/snippets/request-parameters/_DirectionsOutputType.mdx"
import ImpedanceAttrName from "../../../shared/routing/snippets/request-parameters/_Impedance-JDR-OnE.mdx"
import DirectionsTimeAttrName from "../../../shared/routing/snippets/request-parameters/_DirectionsTimeAttrName.mdx"
import OutputLine from "../../../shared/routing/snippets/request-parameters/_RouteShape-JR-OnE.mdx"
import TargetFacilityCount from "../../../shared/routing/snippets/request-parameters/_CF-TargetFacilityCount.mdx"
import DefaultCutoff from "../../../shared/routing/snippets/request-parameters/_CF-defaultCutoff.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 ReturnTraversedEdges from "../../../shared/routing/snippets/request-parameters/_returnTraversedEdges.mdx"
import ReturnTraversedJunctions from "../../../shared/routing/snippets/request-parameters/_returnTraversedJunctions.mdx"
import ReturnTraversedTurns from "../../../shared/routing/snippets/request-parameters/_returnTraversedTurns.mdx"
import ReturnZ from "../../../shared/routing/snippets/request-parameters/_returnZ.mdx"
import OutputGeometryPrecision from "../../../shared/routing/snippets/request-parameters/_RouteLineSimplificationTolerance-JR-OnE.mdx"
import OutputGeometryPrecisionUnits from "../../../shared/routing/snippets/request-parameters/_OutputGeometryPrecisionUnits.mdx"
import GeometryPrecision from "../../../shared/routing/snippets/request-parameters/_GeometryPrecision.mdx"
import GeometryPrecisionM from "../../../shared/routing/snippets/request-parameters/_GeometryPrecisionM.mdx"
import GeometryPrecisionZ from "../../../shared/routing/snippets/request-parameters/_GeometryPrecisionZ.mdx"
import PreserveObjectID from "../../../shared/routing/snippets/request-parameters/_PreserveObjectID.mdx"
import ReturnEmptyResults from "../../../shared/routing/snippets/request-parameters/_ReturnEmptyResults.mdx"
import LocateSetting from "../../../shared/routing/snippets/request-parameters/_LocateSettings.mdx"
import Contxt from "../../../shared/routing/snippets/request-parameters/_Context.mdx"
import ReturnFacility from "../../../shared/routing/snippets/request-parameters/_CF-returnFacilities.mdx"
import ReturnIncidents from "../../../shared/routing/snippets/request-parameters/_CF-returnIncidents.mdx"
import TimeOfDayUTC from "../../../shared/routing/snippets/request-parameters/_Direct-timeOfDayIsUTC.mdx"
import RestrictUTurns from "../../../shared/routing/snippets/request-parameters/_UTurnAtJunctions.mdx"
import ConfigureLimits from "../../../shared/routing/snippets/request-parameters/_configureLimits.mdx"

import OutputRoute from "../../../shared/routing/snippets/output-parameters/_CF-outputRoutes.mdx"
import OutputFacilities from "../../../shared/routing/snippets/output-parameters/_CF-outputCFandFacilities.mdx"
import OutputIncidents from "../../../shared/routing/snippets/output-parameters/_CF-outputIncidents.mdx"

import Directions from "../../../shared/routing/snippets/output-parameters/_outputDirections.mdx"
import ResultFile from "../../../shared/routing/snippets/output-parameters/_resultFile.mdx"
import OutputNetworkAnalysisLayer from "../../../shared/routing/snippets/output-parameters/_outputNetworkAnalysisLayer.mdx"
import OutputRouteData from "../../../shared/routing/snippets/output-parameters/_outRouteData.mdx"
import CostUsage from "../../../shared/routing/snippets/output-parameters/_UsageCost.mdx"
import Direction from "../../../shared/routing/snippets/output-parameters/_outputDirections.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"

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 /solveClosestFacility 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/ClosestFacility/solveClosestFacility`}</CodeBlock>
<CodeBlock language="curl" label="POST">{`POST https://{{machineName}}/{{serverWebAdaptorName}}/rest/services/{{folderName}}/NetworkAnalysis/NAServer/ClosestFacility/solveClosestFacility`}</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 /solveClosestFacility direct request. The `{{serviceName}}` represents the name of the routing services published from ArcGIS Pro. The `{{layerName}}` is the closest facility 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}}/solveClosestFacility`}</CodeBlock>
<CodeBlock language="curl" label="POST">{`POST https://{{machineName}}/{{serverWebAdaptorName}}/rest/services/{{serviceName}}/NAServer/{{layerName}}/solveClosestFacility`}</CodeBlock>
</CodeSwitcher>
</Tab>

</Tabs>

<CFServiceDescription />

## 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">[incidents](#incidents)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">locations | feature | layer</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">

   One or more locations from which the nearby locations are searched. 

    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[facilities](#facilities)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">locations | feature | layer</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">

   One or more locations that are searched for when finding the closest location.

    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnCFRoutes](#returncfroutes)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">

   Return routes.

    </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">[defaultTargetFacilityCount](#defaulttargetfacilitycount)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The number of closest facilities to find per incident.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[travelDirection](#traveldirection)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `esriNATravelDirectionToFacility`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Search for the closest facility as measured from the incident to the facility or from the facility to the incident.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[defaultCutoff](#defaultcutoff)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">number</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `null`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The travel time or travel distance value at which to stop searching for facilities for a given incident.
    </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 or arrive at incidents or facilities.
    </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">[timeOfDayUsage](#timeofdayusage)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `esriNATimeOfDayUseAsStartTime`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Specifies whether the `timeOfDay` parameter value represents the arrival or departure time for the routes. 
    </StyledTableCell>
  </StyledTableRow> 
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[restrictUTurns](#restrictuturns)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `esriNFSBAtDeadEndsAndIntersections`
    </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 the shortest paths.
    </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">
      Type of impedance.
    </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">[returnDirections](#returndirections)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Generates the driving directions for each route.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[directionsLanguage](#directionslanguage)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `en`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The language used when generating driving directions.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[directionsOutputType](#directionsoutputtypes)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `esriDOTStandard`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The content and length of the driving directions. Used if `returnDirections=true`.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[directionsStyleName](#directionsstylename)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `NA Desktop`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The formatting style for the directions. Used if `returnDirections=true`.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[directionsLengthUnits](#directionslengthunits)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `esriNAUMiles`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The units to display the travel distance in driving directions. Used if`returnDirections=true`.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[directionsTimeAttributeName](#directionstimeattributename)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `TravelTime`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The time-based impedance attribute to display the duration of a maneuver.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[outputLines](#outputlines)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `esriNAOutputLineTrueShape`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The type of route features that are returned.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnFacilities](#returnfacilities)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `true`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Returns facilities.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnIncidents](#returnincidents)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `true`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Returns incidents.
    </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">[returnTraversedEdges](#returntraversededges)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Returns traversed edges.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnTraversedJunctions](#returntraversedjunctions)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Returns traversed junctions.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[returnTraversedTurns](#returntraversedturns)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Returns traversed turns.
    </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">[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">[outputGeometryPrecision](#outputgeometryprecision)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">number</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `10`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Simplifies route geometry.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[outputGeometryPrecisionUnits](#outputgeometryprecisionunits)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">string</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `esriMeters`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      The units for the value in the `outputGeometryPrecision` parameter.
    </StyledTableCell>
  </StyledTableRow>
  <StyledTableRow>
    <StyledTableCell cellStyle="code">[geometryPrecision](#geometryprecision)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">integer</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">[geometryPrecisionM](#geometryprecisionm)</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 m-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">[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">[preserveObjectID](#preserveobjectid)</StyledTableCell>
    <StyledTableCell cellStyle="check" checked={false}></StyledTableCell>
    <StyledTableCell cellStyle="code_italic">boolean</StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      `false`
    </StyledTableCell>
    <StyledTableCell cellStyle="markdown">
      Preserves the object IDs from input locations when the input locations are returned as output.
    </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>

### incidents

<Incidents />

</Box>

<Box>

### facilities

<Facilities />

</Box>


## Optional parameters

<Box>

### returnCFRoutes

<ParamMetadata types={[{name:"boolean"}]} defaultValue="false" />

Specify whether the request will return routes.

-   `true`—Routes are returned. The routes are available in the [`routes`](#routes) property of the JSON response. The shape of the routes depends on the value for the `outputLines`  parameter.
-   `false`—Routes are not returned. 

<Note type={"caution"}>
 To return the best routes between the incident and the closest facilities, specify `true`  for this parameter. If you also want the request to return the point features representing the closest facilities from the incidents, specify the `returnFacilities`  parameter as `true`.
</Note>

<Note type={"tip"}>

If you don't want to return routes because the application has to display only the driving directions between the stops, you can set the `returnDirections` parameter to `true`  and the `returnCFRoutes` parameter to `false`. In this case, returning the routes will not provide any additional information and will increase the overall response size.

</Note>

</Box>

<Box>

### travelMode

<TravelModes />

</Box>

<Box>

### travelDirection 

<TravelDirection />

</Box>

<Box>
 
### defaultTargetFacilityCount

<TargetFacilityCount />

</Box>

<Box>

### defaultCutoff

<DefaultCutoff />

</Box>

<Box>

### timeOfDay 

<TimeOfDay closestFacility/>

</Box>

<Box>

### timeOfDayIsUTC

<TimeOfDayUTC />

</Box>

<Box>

### timeOfDayUsage

{/* <p class="space-x-2"><span class="font-sm text-color-3">type:enum</span><span class="font-bold text-[#6d29cc]">default:`esriNATimeOfDayUseAsStartTime`</span></p> */}

<ParamMetadata types={[{name:"string"}]}  defaultValue="esriNATimeOfDayUseAsStartTime" />

**Allowed values:** `esriNATimeOfDayUseAsStartTime`, `esriNATimeOfDayUseAsEndTime`

The `timeOfDayUsage` parameter value represents the arrival or departure time for the routes. This parameter can be specified using the following values:

-   `esriNATimeOfDayUseAsStartTime`—The request finds the best route considering the `timeOfDay` parameter value as the departure time from the facility or incident.
-   `esriNATimeOfDayUseAsEndTime`—The request considers the `timeOfDay` parameter value as the arrival time at the facility or incident. This value is useful if you want to know what time to depart from a location so that you arrive at the destination at the time specified in `timeOfDay`.

The parameter value is ignored if the `timeOfDay` parameter value is `none`.

</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 CF/>

</Box>

<Box>

### polylineBarriers

<LineBarrier CF/>

</Box>

<Box>

### polygonBarriers

<PolygonBarrier CF/>

</Box>

<Box>

### returnDirections

<PopulateDirectionsRoute route/>

</Box>

<Box>

### directionsLanguage

<DirectionsLanguage />

</Box>

<Box>

### directionsOutputType

<DirectionsOutputType />

</Box>

<Box>

### directionsStyleName

<DirectionsStyleName />

</Box>

<Box>

### directionsLengthUnits

<DirectionsDistanceUnits />

</Box>

<Box>

### directionsTimeAttributeName

<DirectionsTimeAttrName />

</Box>

<Box>

### outputLines

<OutputLine closestFacility/>

</Box>

<Box>

### returnFacilities

<ReturnFacility />

</Box>

<Box>

### returnIncidents

<ReturnIncidents />

</Box>

<Box>

### returnBarriers

<ReturnBarriers />

</Box>

<Box>

### returnPolylineBarriers

<ReturnPolylineBarriers />

</Box>

<Box>

### returnPolygonBarriers

<ReturnPolygonBarriers />

</Box>

<Box>

### returnTraversedEdges

<ReturnTraversedEdges />

</Box>

<Box>

### returnTraversedJunctions

<ReturnTraversedJunctions />

</Box>

<Box>

### returnTraversedTurns

<ReturnTraversedTurns />

</Box>

<Box>

### returnZ

<ReturnZ />

</Box>

<Box>

### ignoreInvalidLocations

<IgnoreInvalidLocations />

</Box>

<Box>

### outSR

<Contxt />

</Box>

<Box>

### outputGeometryPrecision

<OutputGeometryPrecision />

</Box>

<Box>

### outputGeometryPrecisionUnits

<OutputGeometryPrecisionUnits />

</Box>

<Box>

### geometryPrecision 

<GeometryPrecision />

</Box>

<Box>

### geometryPrecisionM 

<GeometryPrecisionM />

</Box>

<Box>

### geometryPrecisionZ 

<GeometryPrecisionZ />

</Box>

<Box>

### overrides

<Overrides />

</Box>

<Box>

### preserveObjectID

<PreserveObjectID closestFacility />

</Box>

<Box>

### returnEmptyResults

<ReturnEmptyResults />

</Box>

<Box>

### locateSettings

<LocateSetting CF/>

</Box>

## Response objects 

The JSON response from the closest facility request is based on the following syntax. The actual properties returned in the response depend upon the request parameters. For example, the routes property is returned only if the `returnCFRoutes` 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/CF-JSON_response_direct.json" group="json" maxLines={20} expandable/>

On successful completion, the request returns the best route and travel directions between the incident and the chosen facility and the status indicating whether the analysis was successful using the following response objects:

<Box>

### routes

<OutputRoute />

</Box>

<Box>

### facilities

<OutputFacilities />

</Box>

<Box>

### incidents

<OutputIncidents />

</Box>

<Box>

### barriers

<OutputBarriers />

</Box>

<Box>

### polylineBarriers

<OutputPolylineBarriers />

</Box>

<Box>

### polygonBarriers

<OutputPolygonBarriers />

</Box>

<Box>

### traversedEdges 

<TraversedEdges />

</Box>

<Box>

### traversedJunctions 

<TraversedJunctions />

</Box>

<Box>

### traversedTurns 

<TraversedTurns />

</Box>

<Box>

### directions

<Direction />

</Box>

<Box>

### directionPoints

<DirectionPoint CF/>

</Box>

<Box>

### directionLines

<DirectionLine />

</Box>

## Examples

<Note type={"mapping-guide"}>

To build client application [see API reference examples](DEVSITE/documentation/mapping-and-location-services/routing-and-directions/closest-facility-routing/#direct-find-closest-grocery-stores)

</Note>

Below is an  example of the request on how to find the closest facility near an incident.

<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>

### Find closest facility fire stations

This example shows how to find the two fire stations that can provide the quickest response to a fire at a given incident location within three minutes. You will also generate routes and driving directions for the firefighters.

<MoreInfo>

Specify the four fire stations in the area as the `facilities`  parameter. Use the JSON structure to specify the facilities parameter, as you want to specify the name of the fire station that can be used by the request when generating driving directions for the routes from the fire stations. The geometries are in the default spatial reference WGS84. Therefore, the spatialReference property is not specified. 

Specify the longitude and latitude value for the fire location as the `incidents`  parameter. 

Since you need to find the two closest fire stations, specify `2` as the value for the `defaultTargetFacilityCount`  parameter. To model the fire engines traveling from the stations to the fire (incident), specify `esriNATravelDirectionFromFacility` as the value for the `travelDirection` parameter. You need to search for fire stations that are within three minutes of the fire, so specify `3`  as the value for the `defaultCutoff` parameter. Any fire stations outside the cutoff time are ignored by the request.

Because you need to generate driving directions and report the distance information within the directions in miles, specify the `returnDirections`  parameter as `true`  and the `directionsLengthUnits`  parameter as `esriNAUMiles`. To get the route geometries, specify the `returnCFRoutes` parameter as `true`. Specify `102100` as the value for the `outSR` parameter so that the output routes are returned in the Web Mercator spatial reference and can be displayed on top of an ArcGIS Online basemap. 

</MoreInfo>

<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/CF_submit_job_ent_direct.http" group="HTTP" maxLines={20} expandable/>

</Tab>

<Tab>

The response contains two route features representing the best route to travel from the two closest fire stations to the incident. The response includes the `routes`  and `directions`  properties because the `returnCFRoutes`  and `returnDirections`  parameters are set to `true`  in the request. 

<Note type={"note"}>

Because the response is quite verbose, the repeated elements within the response are abbreviated for clarity.

</Note>

<CodeBlock language="json" source="../../../shared/routing/code-samples/responseExample/direct/CF-JSONExample1.json" group="json" maxLines={20} expandable/>


</Tab>

</Tabs>

</Box>

## Service limits

<CFUsageLimits />

<ConfigureLimits />