Asynchronous Matrix Submission
Purpose
This endpoint enables the submission of a new matrix job for asynchronous processing. It responds with a unique job id which can be used to check the job status and download its result when available.
API Limitations
- The Freemium and Pay as you grow pricing plans support up to 2500 items (the number of origins multiplied by the number of destinations) in a single matrix.
- The Enterprise pricing plan supports up to 100M items in a single matrix.
- Matrices don't need to be square.
Max matrix size | Max number of origins | Max number of destinations | Additional limits |
---|---|---|---|
|
|
|
|
|
|
|
|
Check our Pricing and Contact Sales for quotas tailored based on your needs.
Types
The following data table describes the complex data types that can be used in the Matrix Routing v2 service.
Type | Description |
---|---|
| Latitude, longitude pair (in EPSG:4326 projection), with the following constraints:
Example: |
| A date and time specified in
RFC 3339
format with an optional time zone offset.
|
Request data
HTTPS method: POST
- Constants and parameters enclosed in curly brackets { } must be replaced with their values.
- Please see the following Request parameters section with the required and optional parameters tables for their values. The generic request format is as follows.
URL request format
All of the following parameters are required:
https://{baseURL}/routing/matrix/{versionNumber}/async?key={Your_API_Key}
Example
https://api.tomtom.com/routing/matrix/2/async?key={Your_API_Key}
curl command request format
curl -XPOST 'https://{baseURL}/routing/matrix/{versionNumber}/async?key={Your_API_Key}'
Request headers
The following table describes HTTP request headers of particular interest to Matrix Routing v2 service clients.
Required header | Description |
---|---|
Content-Type | Specifies the MIME type of the body of the request. |
Optional headers | Description |
---|---|
Tracking-ID | Specifies an identifier for the request. It can be used to trace a call.
Value: An |
Request parameters
The following table describes the request parameters.
- Required parameters must be used or the call will fail.
- A parameter's data type is beneath its name.
Required parameters | Description |
---|---|
| Base URL for calling the API.
|
| Service version. |
| An API Key valid for the requested service. |
POST request body - JSON
The POST body of a matrix request should contain a set of items which will be used to calculate a matrix of route summaries.
1{2 "origins": [3 {4 "point": {"latitude": latitudeValue,"longitude": longitudeValue}5 },6 ...,7 {8 "point": {"latitude": latitudeValue,"longitude": longitudeValue}9 }10 ],11 "destinations": [12 {13 "point": {"latitude": latitudeValue,"longitude": longitudeValue}14 },15 ...,16 {17 "point": {"latitude": latitudeValue,"longitude": longitudeValue}18 }19 ],20 "options": {21 "departAt": dateTime | "any" | "now",22 "arriveAt": dateTime | "any",23 "routeType": "fastest" | "shortest",24 "traffic": "historical" | "live",25 "travelMode": "car" | "truck" | "pedestrian",26 "vehicleMaxSpeed": integer,27 "vehicleWeight": integer,28 "vehicleAxleWeight": integer,29 "vehicleLength": float,30 "vehicleWidth": float,31 "vehicleHeight": float,32 "vehicleCommercial": boolean,33 "vehicleLoadType": [ string, ... ],34 "vehicleAdrTunnelRestrictionCode": string,35 "avoid": [ string, ... ]36 }37}
POST request body fields
This section contains the detailed description of allowed fields in the POST body.
Required fields | Description |
---|---|
| A non-empty list of origin locations represented by points. |
| A non-empty list of destination locations represented by points. |
Mutually exclusive fields | Description |
---|---|
| The date and time of departure from the origin point.
Default value:
|
| The date and time of arrival at the destination point.
Values:
|
| Decides how traffic is considered for computing routes.
|
Optional fields | Description |
---|---|
| The type of route requested.
|
| The mode of travel for the requested route. |
| Maximum speed of the vehicle in kilometers/hour.
Default value: |
| Weight of the vehicle in kilograms. A value of |
| Weight per axle of the vehicle in kilograms. A value of |
| Length of the vehicle in meters. A value of |
| Width of the vehicle in meters. A value of |
| Height of the vehicle in meters. A value of |
| Vehicle is used for commercial purposes and thus may not be allowed to
drive on some roads. |
| Specifies types of cargo that may be classified as hazardous materials
and are restricted from some roads.
Use these values for routing in the USA:
Use these values for routing in all other countries:
Notes:
|
| If
Note: The
|
| Specifies something that the route calculation should try to avoid when
determining the route.
|
POST request body example
1{2 "origins": [3 {4 "point": { "latitude": 45.458545, "longitude": 9.15049 }5 },6 {7 "point": { "latitude": 45.403337, "longitude": 11.050541 }8 }9 ],10 "destinations": [11 {12 "point": { "latitude": 48.149853, "longitude": 11.499931 }13 },14 {15 "point": { "latitude": 50.033688, "longitude": 14.538226 }16 }17 ],18 "options": {19 "departAt": "2022-12-19T16:39:57",20 "routeType": "fastest",21 "traffic": "historical",22 "travelMode": "truck",23 "vehicleMaxSpeed": 90,24 "vehicleWeight": 12000,25 "vehicleAxleWeight": 4000,26 "vehicleLength": 13.6,27 "vehicleWidth": 2.42,28 "vehicleHeight": 2.4,29 "vehicleCommercial": true,30 "vehicleLoadType": ["otherHazmatExplosive", "otherHazmatGeneral"],31 "vehicleAdrTunnelRestrictionCode": "C",32 "avoid": ["unpavedRoads"]33 }34}
Response data
Matrix Submission response
On a successful matrix request submission, the Matrix Routing v2 service responds with an HTTP 202
.
The response contains a matrix job ID which can be used to check the matrix job status using the Asynchronous Matrix Status endpoint and download the result of the matrix processing after its completion using the Asynchronous Matrix Download endpoint. The response also contains the current status of the matrix job.
HTTP status codes
Code | Meaning and possible causes |
---|---|
202 | Accepted: Request successful, information about the matrix job's Id and current status will be returned to the client. |
400 | Bad Request: Request cannot be processed correctly, e.g., due to invalid header values. |
403 | Forbidden: The API Key is missing, inactive, invalid, not entitled to use Matrix Routing v2 API, or exceeded the available quota. This can also occur when using HTTP instead of HTTPS. |
404 | Not Found: The requested resource could not be found, but it may be available again in the future. |
405 | Method Not Allowed: The client used an HTTP method other than POST. |
414 | Requested URI is too long: Indicates that the URI requested by the client is longer than the server is willing to interpret. |
415 | Unsupported Media Type: The client used an unsupported media type. |
429 | Too Many Requests: Quota was exceeded for the API Key. |
500 | An error occurred while processing the request. Please try again later. |
502 | Internal network connectivity issue. Please try again later. |
503 | Service currently unavailable. Please try again later. |
504 | Internal network connectivity issue or a request that has taken too long to complete. Please try again later. |
596 | Service not found. Request contains an incorrect FQDN and/or path. |
Response headers
The following table lists HTTP response headers of particular interest to the Matrix Routing v2 service clients.
Header | Description |
---|---|
Access-Control-Expose-Headers | A comma separated list of HTTP header names that browsers are allowed to
access. |
Access-Control-Allow-Origin | A header instructing browsers to allow customer websites to contact the
Matrix Routing v2 service. |
Content-Encoding | The Matrix Routing v2 service applies gzip compression to the response
if it is requested by the client with the Accept-Encoding
header. |
Content-Type | The format of the response. |
Tracking-ID | An identifier for the request.
Value:* An |
Successful response format
1HTTP 200 OK2{3 "jobId": "unique matrix job id",4 "state": "Submitted"5}
Successful response example
1HTTP 200 OK2{3 "jobId": "00-00000000-0000-0000-0000-000000000000-0000",4 "state": "Submitted"5}
Successful response fields
Primary fields | Description |
---|---|
| The matrix job ID which can be used to check the matrix job status using the Asynchronous Matrix Status endpoint and download the result of the matrix processing after its completion using the Asynchronous Matrix Download endpoint. The response also contains the current status of the matrix job. |
| Current state of the matrix job. |
Error response example
1{2 "detailedError": {3 "code": "BAD_REQUEST",4 "message": "Bad Request",5 "details": [6 {7 "code": "BAD_ARGUMENT",8 "message": "Tracking-ID must match ^[a-zA-Z0-9-]{1,100}$ pattern.",9 "target": "trackingId",10 "innerError": {11 "code": "INVALID_PARAMETER_VALUE"12 }13 }14 ]15 }16}
Error response fields
Primary fields | |
---|---|
Field | Description |
| Detailed information about the error. |
detailedError object | |
Field | Description |
| One of the defined error codes. |
| A human-readable description of the error code. It is intended as an aid to developers and is not suitable for exposure to end users. |
| Optional. Target of the particular error. For example, a parameter name, a path to a JSON property, and others. Contents of this field may change over time. |
| Optional. An array of root causes (more detailed errors)
that led to this error. |
| Optional. A higher level of details about this error. |
innerError object | |
Field | Description |
| One of the defined error codes. |
| Optional. A human-readable representation of the error code. It is intended as an aid to developers and is not suitable for exposure to end users. |
| Optional. A higher level of details about this error. |
Error code hierarchy
List of predefined, hierarchical, human-readable error codes.
- Top level codes relate to HTTP error codes.
- They may be refined by error codes in
details
orinnerError
. - Further levels of refinement are possible by nesting
innerError
insideinnerError
.
In the future, the list may be extended with additional codes. New or existing codes may be introduced as children of codes already present in the hierarchy. The application must be ready for the occurrence of an unknown error code (e.g., by stopping error processing at the last understood level of detail).
Error code | Description |
---|---|
NOT_FOUND | Top level code for requests which failed with an HTTP |
BAD_REQUEST | Top level code for requests which failed with an HTTP |
INTERNAL_SERVER_ERROR | Top level code for requests which failed with an HTTP |
SERVICE_UNAVAILABLE | Top level code for requests which failed with an HTTP |
FORBIDDEN | Top level code for requests which failed with an HTTP |
BAD_ARGUMENT | One of the request parameters did not pass validation. The optional
target field may contain the name of the related parameter, or
the location inside the JSON object in the request POST body. |
MISSING_REQUIRED_PARAMETER | One of the required parameters was not provided. |
INVALID_PARAMETER_VALUE | The value of one of the parameters is invalid. |
OVER_TRANSACTION_LIMIT | Client has exceeded the transaction limit. |
OUT_OF_REGION | The distance between the given origin and destination pair is too long
to calculate the route, considering other requested options. |