Route - Post Route Matrix
Applies to: see pricing tiers.
The Route Matrix
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 a sync 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. For example, a food delivery company has 20 drivers and they need to find the closest driver to pick up the delivery from the restaurant. To solve this use case, they can call the Route Matrix API and use the travel cost to sort the drivers by their actual travel distance or time from the restaurant.
Route Matrices are used in several different types of applications, most commonly to solve the Travelling 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 sync request it's 2500 (the number of origins multiplied by the number of destinations).
Submit Synchronous Route Matrix Request
If your scenario requires synchronous requests and the maximum size of the matrix is less than or equal to 2500, you might want to make synchronous request. The maximum size of a matrix for this API is 2500 (the number of origins multiplied by the number of destinations). With that constraint in mind, examples of possible matrix dimensions are: 50x50, 60x40, 90x20 (it does not need to be square).
API Limitations
The synchronous processing of matrix is best suited for fast, small matrices of route calculation. To calculate larger matrices and heavy route calculation, use the asynchronous endpoint. The following limitation is applicable to the synchronous 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 |
---|---|---|---|
100 | 100 | 100 | N/A |
200 | 200 | 200 | 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. |
2500 | 1000 | 1000 | - departAt or arriveAt must be any.- traffic must be historical.- travelMode must be either driving or truck- No other parameters can be used explicitly |
Examples:
Request of 10x20 matrix with
traffic=live
: This request will be processed with a bounding box limit, as it matches a limit of up to 200, which includes bounding box restrictions.Request of 10x20 matrix with default parameters (
traffic=historical
): This request will be processed without a bounding box limit, as it matches a limit of up to 2500, which does not impose bounding box restrictions.
POST https://atlas.microsoft.com/route/matrix?api-version=2024-07-01-preview
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
api-version
|
query | True |
string |
Version number of Azure Maps API. |
Request Header
Media Types: "application/geo+json"
Name | Required | Type | Description |
---|---|---|---|
x-ms-client-id |
string |
Specifies which account is intended for usage in conjunction with the Microsoft Entra ID security model. It represents a unique ID for the Azure Maps account and can be retrieved from the Azure Maps management plane Account API. To use Microsoft Entra ID security in Azure Maps see the following articles for guidance. |
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":"fastest " |
||
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 |
---|---|---|
200 OK |
OK Media Types: "application/geo+json" |
|
Other Status Codes |
An unexpected error occurred. Media Types: "application/geo+json" Headers x-ms-error-code: string |
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.
To 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.
Note
- 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. - The
Authorization URL
is specific to the Azure public cloud instance. Sovereign clouds have unique Authorization URLs and Microsoft Entra ID configurations. - The Azure role-based access control is configured from the Azure management plane via Azure portal, PowerShell, CLI, Azure SDKs, or REST APIs.
- Usage of the Azure Maps Web SDK allows for configuration based setup of an application for multiple use cases.
- 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 | https://atlas.microsoft.com/.default |
subscription-key
This is a shared key that is provisioned when creating an Azure Maps resource through the Azure management plane via Azure portal, PowerShell, CLI, Azure SDKs, or REST APIs.
With this key, any application is authorized to access all REST APIs. In other words, these can currently be treated as master keys to the account which they are issued for.
For publicly exposed applications, our recommendation is to use server-to-server access of Azure Maps REST APIs where this 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.
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.
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
Successfully retrieve a route matrix with additional parameters in the body
Sample request
POST https://atlas.microsoft.com/route/matrix?api-version=2024-07-01-preview
{
"type": "FeatureCollection",
"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"
}
}
],
"departAt": "2022-12-19T16:39:57+01:00",
"optimizeRoute": "fastest",
"traffic": "historical",
"travelMode": "truck",
"avoid": [
"unpavedRoads"
]
}
Sample response
{
"type": "Feature",
"geometry": null,
"properties": {
"summary": {
"totalCount": 4,
"successfulCount": 4
},
"matrix": [
{
"statusCode": 200,
"originIndex": 0,
"destinationIndex": 0,
"durationTrafficInSeconds": 21007,
"durationInSeconds": 21007,
"distanceInMeters": 492466,
"departureTime": "2022-12-19T16:39:57+01:00",
"arrivalTime": "2022-12-19T22:30:03+01:00"
},
{
"statusCode": 200,
"originIndex": 0,
"destinationIndex": 1,
"durationTrafficInSeconds": 33623,
"durationInSeconds": 33623,
"distanceInMeters": 877028,
"departureTime": "2022-12-19T16:39:57+01:00",
"arrivalTime": "2022-12-20T02:00:19+01:00"
},
{
"statusCode": 200,
"originIndex": 1,
"destinationIndex": 0,
"durationTrafficInSeconds": 19520,
"durationInSeconds": 19520,
"distanceInMeters": 427769,
"departureTime": "2022-12-19T16:39:57+01:00",
"arrivalTime": "2022-12-19T22:05:16+01:00"
},
{
"statusCode": 200,
"originIndex": 1,
"destinationIndex": 1,
"durationTrafficInSeconds": 32070,
"durationInSeconds": 32070,
"distanceInMeters": 836080,
"departureTime": "2022-12-19T16:39:57+01:00",
"arrivalTime": "2022-12-20T01:34:27+01:00"
}
]
}
}
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. |
Error |
The resource management error additional info. |
Error |
The error detail. |
Features |
Specifies the |
Feature |
Specifies the |
Geo |
A valid |
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 driving instructions and additional properties for each maneuver point in the route Leg. |
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 |
Route Matrix properties. |
Route |
Route Matrix item result |
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":"fastest " |
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 |
This object is returned from a successful call. |
Route |
Summary for the route matrix request |
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. |
Route |
Type of asynchronous operation |
Vehicle |
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. |
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.
Name | Type | Description |
---|---|---|
B |
string |
Vehicles with code B are restricted from roads with ADR tunnel categories B, C, D, and E. |
C |
string |
Vehicles with code C are restricted from roads with ADR tunnel categories C, D, and E |
D |
string |
Vehicles with code D are restricted from roads with ADR tunnel categories D and E. |
E |
string |
Vehicles with code E are restricted from roads with ADR tunnel category E. |
ErrorAdditionalInfo
The resource management error additional info.
Name | Type | Description |
---|---|---|
info |
object |
The additional info. |
type |
string |
The additional info type. |
ErrorDetail
The error detail.
Name | Type | Description |
---|---|---|
additionalInfo |
The error additional info. |
|
code |
string |
The error code. |
details |
The error details. |
|
message |
string |
The error message. |
target |
string |
The error target. |
FeaturesItemTypeEnum
Specifies the GeoJSON
type. The only supported object type is Feature. For more information, see RFC 7946.
Name | Type | Description |
---|---|---|
Feature |
string |
Specifies the |
FeatureTypeEnum
Specifies the GeoJSON
type. The only supported object type is FeatureCollection
. For more information, see RFC 7946.
Name | Type | Description |
---|---|---|
FeatureCollection |
string |
Specifies the |
GeoJsonMultiPoint
A valid GeoJSON MultiPoint
geometry type. Please refer to RFC 7946 for details.
Name | Type | Description |
---|---|---|
coordinates |
number[] |
Coordinates for the |
type |
string:
Multi |
Specifies the |
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. |
RouteMatrixAsyncResponse
Specifies the driving instructions and additional properties for each maneuver point in the route Leg.
Name | Type | Description |
---|---|---|
geometry |
object |
The geometry object is null |
kind |
string:
Route |
Type of asynchronous operation |
properties |
Route Matrix properties. |
|
type |
Specifies the |
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.
Name | Type | Description |
---|---|---|
tollRoads |
string |
Avoids the use of toll roads in the route. |
unpavedRoads |
string |
Avoids unpaved roads in the route. |
RouteMatrixFeatureProperties
Route Matrix properties.
Name | Type | Description |
---|---|---|
matrix |
The matrix of route results. |
|
summary |
Summary for the route matrix request |
RouteMatrixItemResult
Route Matrix item result
Name | Type | Description |
---|---|---|
arrivalTime |
|
The estimated arrival time, which takes into account the traffic conditions, is formatted as a |
departureTime |
|
The estimated departure time, which takes into account the traffic conditions, is formatted as a |
destinationIndex |
integer |
Index of the destination point |
distanceInMeters |
number |
Length In Meters property |
durationInSeconds |
integer |
Estimated travel time in seconds that does not include delays on the route due to traffic conditions. |
durationTrafficInSeconds |
integer |
The time that it takes, in seconds, to travel a corresponding |
error |
The error detail. |
|
originIndex |
integer |
Index of the origin point |
statusCode |
integer |
The HTTP status code of the current cell. |
RouteMatrixOptimizeRouteEnum
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":"fastest "
Name | Type | Description |
---|---|---|
fastest |
string |
Finds the fastest route to optimize route by travel time. Only |
RouteMatrixRequest
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":"fastest " |
|
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. |
RouteMatrixResponse
This object is returned from a successful call.
Name | Type | Description |
---|---|---|
geometry |
object |
The geometry object is null |
properties |
Route Matrix properties. |
|
type |
Specifies the |
RouteMatrixSummary
Summary for the route matrix request
Name | Type | Description |
---|---|---|
successfulCount |
integer |
Number of successful routes within this matrix. |
totalCount |
integer |
Total number of routes within this matrix. |
RouteMatrixTrafficEnum
Specifies how traffic is considered for computing routes.
Default value: historical
Name | Type | Description |
---|---|---|
historical |
string |
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 |
string |
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"
Name | Type | Description |
---|---|---|
driving |
string |
Routing profile suitable for cars are used for route matrix calculation. |
truck |
string |
Routing profile suitable for commercial vehicles like trucks are used for route matrix calculation. |
walking |
string |
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.
Name | Type | Description |
---|---|---|
destinations |
string |
MultiPoint features that define the destination locations in the input matrix. |
origins |
string |
MultiPoint features that define the origin 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 |
0 |
Weight per axle of the vehicle in kg. A value of 0 means that weight restrictions per axle are not considered. |
height |
number |
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 |
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 |
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 |
0 |
Weight of the vehicle in kilograms. A value of 0 means that weight restrictions are not considered. |
width |
number |
0 |
Width of the vehicle in meters. A value of 0 means that width restrictions are not considered. |
RouteOperationKindEnum
Type of asynchronous operation
Name | Type | Description |
---|---|---|
RouteMatrix |
string |
Route matrix asynchronous job. |
VehicleLoadTypeEnum
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.
Name | Type | Description |
---|---|---|
USHazmatClass1 |
string |
Explosives |
USHazmatClass2 |
string |
Compressed gas |
USHazmatClass3 |
string |
Flammable liquids |
USHazmatClass4 |
string |
Flammable solids |
USHazmatClass5 |
string |
Oxidizers |
USHazmatClass6 |
string |
Poisons |
USHazmatClass7 |
string |
Radioactive |
USHazmatClass8 |
string |
Corrosives |
USHazmatClass9 |
string |
Miscellaneous |
otherHazmatExplosive |
string |
Explosives |
otherHazmatGeneral |
string |
Miscellaneous |
otherHazmatHarmfulToWater |
string |
Harmful to water |