v5
latestSwagger 2.02026-07-1310125222.6 KBThe 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-location header 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.<br>- traffic must be historical.<br/>- optimizeRoute must be fastest.<br/>- travelMode must be either driving or truck. <br/>- No other parameters can be used explicitly. |
Query parameters
The API version to use for this operation.
Headers
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.
Response
The request has been accepted for processing, but processing has not yet completed.