Route - Post Route Matrix Async
The Route Matrix Async API is an HTTP POST request that allows calculation
of a matrix of route summaries for a set of routes defined by origin and
destination locations by using an asynchronous (async) request. For every given
origin, the service calculates the cost of routing from that origin to every
given destination. The set of origins and the set of destinations can be
thought of as the column and row headers of a table and each cell in the table
contains the costs of routing from the origin to the destination for that cell.
Route Matrices can be calculated for driving, walking and truck routes.
Route Matrices are used in several different types of applications, most commonly to solve the Traveling Salesman Problem (TSP) and Vehicle Routing Problem (VRP). For each origin-destination pair in the matrix, the travel time and distance are returned. You can use the computed costs to determine which detailed routes to calculate using the Route Directions API.
The maximum size of a matrix for async request is 50000 (the number of origins multiplied by the number of destinations).
Submit Asynchronous Route Matrix Request
The Asynchronous API is appropriate for processing big volumes of relatively
complex routing requests. When you make a request by using async request, by
default the service returns a 202 response code along a URL in the
operation-Location field of the response header with the Azure Maps geography
endpoint {geography}.atlas.microsoft.com. This URL should be checked
periodically until the status is Succeeded.
The maximum size of a matrix for this API is 50000 (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 500x100, 100x100, 280x170. 100x50 (it does not need to be square).
The asynchronous responses are stored for 24 hours. The redirect URL returns a 404 response if used after the expiration period.
POST
https://atlas.microsoft.com/route/matrix:async?api-version=2025-01-01&subscription-key={subscription-key}
Here's a typical sequence of asynchronous operations:
Client sends a Route Matrix POST request to Azure Maps
The server will respond with one of the following:
HTTP
202 Accepted- Route Matrix request has been accepted.
HTTP
Error- There was an error processing your Route Matrix request. This could either be a 400 Bad Request or any other Error status code.
- If the Matrix Route request was accepted successfully, the
operation-locationheader in the response contains the URL to get the status of the request. This status URI looks like the following:
GET
https://atlas.microsoft.com/route/operations/{id}?api-version=2025-01-01?subscription-key={subscription-key}
- Client issues a GET request on the resultUrl obtained in Step 3 to get the results
GET
https://atlas.microsoft.com/route/operations/{id}/result?api-version=2025-01-01?subscription-key={subscription-key}
API Limitations
The asynchronous processing of matrix is best suited for larger matrices that require heavy route calculation. The following limitation is applicable to the asynchronous requests. If none of the rows in the following table match the request's parameters, the request does not meet the requirements and will not be processed.
| Max matrix size | Max number of origins | Max number of destinations | Additional limits |
|------------------|-----------------------|-----------------------------|-------------------|
| 2500 | 1000 | 1000 | All
origins and destinations should be contained in an axis-aligned 400 km x 400 km
bounding box. Otherwise some matrix cells will be resolved as OUT_OF_REGION. |
| 50,000 | 10,000 | 10,000 | -
departAt or arriveAt must be any.
- traffic must be historical.
-
optimizeRoute must be fastest.
- travelMode must be
either driving or truck.
- No other parameters can be used explicitly. |
POST {endpoint}/route/matrix:async?api-version=2025-01-01
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
endpoint
|
path | True |
string |
|
|
api-version
|
query | True |
string minLength: 1 |
The API version to use for this operation. |
Request Header
Media Types: "application/geo+json"
| Name | Required | Type | Description |
|---|---|---|---|
| x-ms-client-id |
string |
Indicates the account intended for use with the Microsoft Entra ID security model. This unique ID for the Azure Maps account can be obtained from the Azure Maps management plane Account API. For more information on using Microsoft Entra ID security in Azure Maps, see Manage authentication in Azure Maps. |
Request Body
Media Types: "application/geo+json"
| Name | Required | Type | Description |
|---|---|---|---|
| features | True |
A set of origin and destination points passed as GeoJSON MultiPoint features for the input matrix. Refer to RFC 7946 for details on the GeoJSON format. |
|
| type | True |
Specifies the |
|
| arriveAt |
string |
The date and time of arrival at the destination point formatted as a The The Default value: Example: "arriveAt": "2024-12-01T09:30:00.000-07:00" |
|
| avoid |
Specifies restrictions that the route calculation should honor when determining the route. Avoid supports multiple values in a request and is only supported for the driving and truck travelMode. |
||
| departAt |
string |
The date and time of departure from the origin point formatted as a The The
Default value: Example: "departAt": "2024-12-01T09:30:00.000-07:00" |
|
| optimizeRoute |
Specifies the parameter to use to optimize the route. If not defined, the default is "fastest" which returns the route to minimize the travel time. Example: "optimizeRoute":"shortest" |
||
| traffic |
Specifies how traffic is considered for computing routes. Default value: |
||
| travelMode |
Specifies the travel profile to consider when calculating the matrix. If not specified, the default value is "driving". Example: "travelMode":"driving" |
||
| vehicleSpec |
Specifies the vehicle attributes such as vehicle height, weight, max speed, type of cargo, etc. to consider when calculating the route matrix. This helps avoid low bridge clearances, road restrictions, difficult right turns to provide the optimized route based on the vehicle specifications. Vehicle attributes are specified within the vehicleSpec property. |
Responses
| Name | Type | Description |
|---|---|---|
| 202 Accepted |
The request has been accepted for processing, but processing has not yet completed. Headers Operation-Location: string |
|
| Other Status Codes |
An unexpected error response. |
Security
AadToken
These are the Microsoft Entra OAuth 2.0 Flows. When paired with Azure role-based access control it can be used to control access to Azure Maps REST APIs. Azure role-based access controls are used to designate access to one or more Azure Maps resource account or sub-resources. Any user, group, or service principal can be granted access via a built-in role or a custom role composed of one or more permissions to Azure Maps REST APIs.\n\nTo implement scenarios, we recommend viewing authentication concepts. In summary, this security definition provides a solution for modeling application(s) via objects capable of access control on specific APIs and scopes.\n\n#### Notes\n* This security definition requires the use of the x-ms-client-id header to indicate which Azure Maps resource the application is requesting access to. This can be acquired from the Maps management API.\n* \nThe Authorization URL is specific to the Azure public cloud instance. Sovereign clouds have unique Authorization URLs and Microsoft Entra ID configurations. \n* \nThe Azure role-based access control is configured from the Azure management plane via Azure portal, PowerShell, CLI, Azure SDKs, or REST APIs.\n* \nUsage of the Azure Maps Web SDK allows for configuration based setup of an application for multiple use cases.\n* For more information on Microsoft identity platform, see Microsoft identity platform overview.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name | Description |
|---|---|
| https://atlas.microsoft.com/.default |
subscription-key
This is a shared key that is provisioned when you Create an Azure Maps account in the Azure portal or using PowerShell, CLI, Azure SDKs, or REST API.\n\n With this key, any application can access all REST API. In other words, this key can be used as a master key in the account that they are issued in.\n\n For publicly exposed applications, our recommendation is to use the confidential client applications approach to access Azure Maps REST APIs so your key can be securely stored.
Type:
apiKey
In:
header
SAS Token
This is a shared access signature token is created from the List SAS operation on the Azure Maps resource through the Azure management plane via Azure portal, PowerShell, CLI, Azure SDKs, or REST APIs.\n\n With this token, any application is authorized to access with Azure role-based access controls and fine-grain control to the expiration, rate, and region(s) of use for the particular token. In other words, the SAS Token can be used to allow applications to control access in a more secured way than the shared key.\n\n For publicly exposed applications, our recommendation is to configure a specific list of allowed origins on the Map account resource to limit rendering abuse and regularly renew the SAS Token.
Type:
apiKey
In:
header
Examples
Submit an asynchronous request for matrix
Sample request
POST {endpoint}/route/matrix:async?api-version=2025-01-01
{
"type": "FeatureCollection",
"avoid": [
"unpavedRoads"
],
"departAt": "2022-12-19T16:39:57+01:00",
"features": [
{
"type": "Feature",
"geometry": {
"type": "MultiPoint",
"coordinates": [
[
9.15049,
45.458545
],
[
11.050541,
45.403337
]
]
},
"properties": {
"pointType": "origins"
}
},
{
"type": "Feature",
"geometry": {
"type": "MultiPoint",
"coordinates": [
[
11.499931,
48.149853
],
[
14.538226,
50.033688
]
]
},
"properties": {
"pointType": "destinations"
}
}
],
"optimizeRoute": "fastest",
"traffic": "historical",
"travelMode": "truck"
}
Sample response
Operation-Location: https://atlas.microsoft.com/route/operations/bc3f9365-3ee0-4564-aa27-825016325557?api-version=2025-01-01
Definitions
| Name | Description |
|---|---|
|
Adr |
The ADR tunnel restriction code. ADR is a European agreement concerning the international carriage of dangerous goods by road. The ADR tunnel restriction code is used to determine whether a vehicle is allowed to pass through a tunnel with restrictions on the carriage of dangerous goods. |
|
Features |
Specifies the |
|
Feature |
Specifies the |
|
Geo |
A valid |
|
Geo |
Specifies the |
|
Input |
Specifies the input origin and destination points and additional properties for
the |
|
Input |
Specifies the properties object for the input matrix. |
|
Maps |
The error detail. |
|
Maps |
Common error response for Azure Maps APIs to return error details for failed operations. |
|
Maps |
An object containing more specific information than the current object about the error. |
|
Route |
Specifies the parameter to use to optimize the route. If not defined, the default is "fastest" which returns the route to minimize the travel time. Example: "optimizeRoute":"shortest" |
|
Route |
Use to get a route matrix showing the travel time and distance for all possible
pairs in a list of origins and destination. |
|
Route |
Specifies restrictions that the route calculation should honor when determining the route. Avoid supports multiple values in a request and is only supported for the driving and truck travelMode. |
|
Route |
Specifies how traffic is considered for computing routes. Default value: |
|
Route |
Specifies the travel profile to consider when calculating the matrix. If not specified, the default value is "driving". Example: "travelMode":"driving" |
|
Route |
Specifies the origin MultiPoint type and destination MultiPoint type for the input matrix. |
|
Route |
Specifies the vehicle attributes such as vehicle height, weight, max speed, type of cargo, etc. to consider when calculating the route matrix. This helps avoid low bridge clearances, road restrictions, difficult right turns to provide the optimized route based on the vehicle specifications. Vehicle attributes are specified within the vehicleSpec property. |
|
Vehicle |
Types of cargo that may be classified as hazardous materials and restricted from some roads. |
AdrTunnelRestrictionCodeEnum
The ADR tunnel restriction code. ADR is a European agreement concerning the international carriage of dangerous goods by road. The ADR tunnel restriction code is used to determine whether a vehicle is allowed to pass through a tunnel with restrictions on the carriage of dangerous goods.
| Value | Description |
|---|---|
| B |
Vehicles with code B are restricted from roads with ADR tunnel categories B, C, D, and E. |
| C |
Vehicles with code C are restricted from roads with ADR tunnel categories C, D, and E |
| D |
Vehicles with code D are restricted from roads with ADR tunnel categories D and E. |
| E |
Vehicles with code E are restricted from roads with ADR tunnel category E. |
FeaturesItemTypeEnum
Specifies the GeoJSON type. The only supported object type is Feature. For
more information, see RFC 7946.
| Value | Description |
|---|---|
| Feature |
Specifies the |
FeatureTypeEnum
Specifies the GeoJSON type. The only supported object type is
FeatureCollection. For more information, see RFC
7946.
| Value | Description |
|---|---|
| FeatureCollection |
Specifies the |
GeoJsonMultiPoint
A valid GeoJSON MultiPoint geometry type. Please refer to RFC
7946 for details.
| Name | Type | Description |
|---|---|---|
| coordinates |
number[] (double) |
Coordinates for the |
| type |
string:
Multi |
Specifies the |
GeoJsonObjectType
Specifies the GeoJSON type. Must be one of the nine valid GeoJSON object
types - Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon,
GeometryCollection, Feature and FeatureCollection.
| Value | Description |
|---|---|
| Point |
|
| MultiPoint |
|
| LineString |
|
| MultiLineString |
|
| Polygon |
|
| MultiPolygon |
|
| GeometryCollection |
|
| Feature |
|
| FeatureCollection |
|
InputRouteMatrixFeaturesItem
Specifies the input origin and destination points and additional properties for
the GeoJSON MultiPoint feature object. Refer to RFC
7946 for details.
| Name | Type | Description |
|---|---|---|
| geometry |
A valid |
|
| properties |
MultiPoint feature properties object which specifies the origin features and destination features for the input matrix. |
|
| type |
Specifies the |
InputRouteMatrixProperties
Specifies the properties object for the input matrix.
| Name | Type | Description |
|---|---|---|
| pointType |
Specifies the origin MultiPoint type and destination MultiPoint type for the input matrix. |
MapsErrorDetail
The error detail.
| Name | Type | Description |
|---|---|---|
| code |
string |
One of a server-defined set of error codes. |
| details |
An array of details about specific errors that led to this reported error. |
|
| innererror |
An object containing more specific information than the current object about the error. |
|
| message |
string |
A human-readable representation of the error. |
| target |
string |
The target of the error. |
MapsErrorResponse
Common error response for Azure Maps APIs to return error details for failed operations.
| Name | Type | Description |
|---|---|---|
| error |
The error detail. |
MapsInnerError
An object containing more specific information than the current object about the error.
| Name | Type | Description |
|---|---|---|
| code |
string |
The error code. |
| innererror |
An object containing more specific information than the current object about the error. |
RouteMatrixAsyncOptimizeRouteEnum
Specifies the parameter to use to optimize the route. If not defined, the default is "fastest" which returns the route to minimize the travel time.
Example: "optimizeRoute":"shortest"
| Value | Description |
|---|---|
| shortest |
Finds the shortest route to optimize route by travel distance. |
| fastest |
Finds the fastest route to optimize route by travel time. |
RouteMatrixAsyncRequest
Use to get a route matrix showing the travel time and distance for all possible
pairs in a list of origins and destination. GeoJSON feature object and
additional properties. Refer to RFC
7946 for details.
| Name | Type | Default value | Description |
|---|---|---|---|
| arriveAt |
string |
The date and time of arrival at the destination point formatted as a The The Default value: Example: "arriveAt": "2024-12-01T09:30:00.000-07:00" |
|
| avoid |
Specifies restrictions that the route calculation should honor when determining the route. Avoid supports multiple values in a request and is only supported for the driving and truck travelMode. |
||
| departAt |
string |
The date and time of departure from the origin point formatted as a The The
Default value: Example: "departAt": "2024-12-01T09:30:00.000-07:00" |
|
| features |
A set of origin and destination points passed as GeoJSON MultiPoint features for the input matrix. Refer to RFC 7946 for details on the GeoJSON format. |
||
| optimizeRoute | fastest |
Specifies the parameter to use to optimize the route. If not defined, the default is "fastest" which returns the route to minimize the travel time. Example: "optimizeRoute":"shortest" |
|
| traffic | historical |
Specifies how traffic is considered for computing routes. Default value: |
|
| travelMode | driving |
Specifies the travel profile to consider when calculating the matrix. If not specified, the default value is "driving". Example: "travelMode":"driving" |
|
| type |
Specifies the |
||
| vehicleSpec |
Specifies the vehicle attributes such as vehicle height, weight, max speed, type of cargo, etc. to consider when calculating the route matrix. This helps avoid low bridge clearances, road restrictions, difficult right turns to provide the optimized route based on the vehicle specifications. Vehicle attributes are specified within the vehicleSpec property. |
RouteMatrixAvoidEnum
Specifies restrictions that the route calculation should honor when determining the route. Avoid supports multiple values in a request and is only supported for the driving and truck travelMode.
| Value | Description |
|---|---|
| tollRoads |
Avoids the use of toll roads in the route. |
| unpavedRoads |
Avoids unpaved roads in the route. |
RouteMatrixTrafficEnum
Specifies how traffic is considered for computing routes.
Default value: historical
| Value | Description |
|---|---|
| historical |
Route calculation considers historical travel times and long term closures. Traffic jams and short-term closures during the travel time window do not influence routing or travel time. |
| live |
In addition to historical travel times, route calculation considers traffic jams and short- and long-term closures during the travel time window.
|
RouteMatrixTravelModeEnum
Specifies the travel profile to consider when calculating the matrix. If not specified, the default value is "driving".
Example: "travelMode":"driving"
| Value | Description |
|---|---|
| driving |
Routing profile suitable for cars are used for route matrix calculation. |
| truck |
Routing profile suitable for commercial vehicles like trucks are used for route matrix calculation. |
| walking |
The returned routes are optimized for pedestrians, including the use of sidewalks. |
RouteMatrixTypeEnum
Specifies the origin MultiPoint type and destination MultiPoint type for the input matrix.
| Value | Description |
|---|---|
| origins |
MultiPoint features that define the origin locations in the input matrix. |
| destinations |
MultiPoint features that define the destination locations in the input matrix. |
RouteMatrixVehicleSpec
Specifies the vehicle attributes such as vehicle height, weight, max speed, type of cargo, etc. to consider when calculating the route matrix. This helps avoid low bridge clearances, road restrictions, difficult right turns to provide the optimized route based on the vehicle specifications. Vehicle attributes are specified within the vehicleSpec property.
| Name | Type | Default value | Description |
|---|---|---|---|
| adrTunnelRestrictionCode |
The ADR tunnel restriction code. ADR is a European agreement concerning the international carriage of dangerous goods by road. The ADR tunnel restriction code is used to determine whether a vehicle is allowed to pass through a tunnel with restrictions on the carriage of dangerous goods. |
||
| axleWeight |
integer (int64) minimum: 0maximum: 1000000 |
0 |
Weight per axle of the vehicle in kg. A value of 0 means that weight restrictions per axle are not considered. |
| height |
number (double) minimum: 0maximum: 1000000 |
0 |
Height of the vehicle in meters. A value of 0 means that height restrictions are not considered. |
| isVehicleCommercial |
boolean |
False |
Whether the vehicle is used for commercial purposes. Commercial vehicles may not be allowed to drive on some roads. |
| length |
number (double) minimum: 0maximum: 1000000 |
0 |
Length of the vehicle in meters. A value of 0 means that length restrictions are not considered. |
| loadType |
Types of cargo that may be classified as hazardous materials and restricted from some roads. Available vehicleLoadType values are US Hazmat classes 1 through 9, plus generic classifications for use in other countries. Values beginning with USHazmat are for US routing while otherHazmat should be used for all other countries. vehicleLoadType supports multiple values in a request. |
||
| maxSpeed |
integer (int64) minimum: 0maximum: 250 |
0 |
Maximum speed of the vehicle in km/hour. The max speed in the vehicle profile is used to check whether a vehicle is allowed on motorways. A value of 0 means that an appropriate value for the vehicle will be determined and applied during route planning. A non-zero value may be overridden during route planning. For example, the current traffic flow is 60 km/hour. If the vehicle maximum speed is set to 50 km/hour, the routing engine will consider 60 km/hour as this is the current situation. If the maximum speed of the vehicle is provided as 80 km/hour but the current traffic flow is 60 km/hour, then routing engine will again use 60 km/hour. |
| weight |
integer (int64) minimum: 0maximum: 1000000 |
0 |
Weight of the vehicle in kilograms. A value of 0 means that weight restrictions are not considered. |
| width |
number (double) minimum: 0maximum: 1000000 |
0 |
Width of the vehicle in meters. A value of 0 means that width restrictions are not considered. |
VehicleLoadTypeEnum
Types of cargo that may be classified as hazardous materials and restricted from some roads.
| Value | Description |
|---|---|
| USHazmatClass1 |
Explosives |
| USHazmatClass2 |
Compressed gas |
| USHazmatClass3 |
Flammable liquids |
| USHazmatClass4 |
Flammable solids |
| USHazmatClass5 |
Oxidizers |
| USHazmatClass6 |
Poisons |
| USHazmatClass7 |
Radioactive |
| USHazmatClass8 |
Corrosives |
| USHazmatClass9 |
Miscellaneous |
| otherHazmatExplosive |
Explosives |
| otherHazmatGeneral |
Miscellaneous |
| otherHazmatHarmfulToWater |
Harmful to water |