> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solvice.io/llms.txt
> Use this file to discover all available pages before exploring further.

# External Distance Matrices

> Use pre-computed distance matrices from external services with time-of-day traffic patterns

# External Distance Matrices

Upload pre-computed distance matrices to [routing.solvice.io/table/upload](https://maps.solvice.io/table/upload-table) and reference them by ID in your VRP requests for faster processing and custom traffic patterns.

## Basic Configuration

Configure different distance matrices for different times of day:

```json theme={null}
{
  "jobs": [
    {"name": "delivery-1", "location": {"latitude": 51.1279, "longitude": 17.0485}},
    {"name": "delivery-2", "location": {"latitude": 51.1350, "longitude": 17.0600}}
  ],
  "resources": [{
    "name": "driver-1",
    "category": "CAR",
    "shift": {
      "from": "2025-01-01T08:00:00Z",
      "to": "2025-01-01T18:00:00Z"
    }
  }],
  "customDistanceMatrices": {
    "profileMatrices": {
      "CAR": {
        "8": "matrix-car-morning-rush",    // 8 AM matrix ID
        "12": "matrix-car-midday",        // 12 PM matrix ID
        "16": "matrix-car-evening-rush"   // 4 PM matrix ID
      }
    }
  }
}
```

## Matrix Upload

Upload your distance matrix to get an ID:

```json theme={null}
{
  "coordinates": [
    [4.9, 50.2],   // [longitude, latitude]
    [4.8, 50.4]
  ],
  "durations": [
    [0, 1976.1],
    [2010.2, 0]
  ],
  "vehicleType": "CAR",
  "departureTime": "2025-01-01T08:00:00"
}
```

Then reference the returned matrix ID:

```json theme={null}
{
  "customDistanceMatrices": {
    "profileMatrices": {
      "CAR": {
        "8": "matrix-id-from-upload-response"
      }
    }
  }
}
```

## Multi-Vehicle Configuration

Different vehicle types can use different routing matrices:

```json theme={null}
{
  "customDistanceMatrices": {
    "profileMatrices": {
      "CAR": {
        "6": "car-early-commute",
        "9": "car-midday-traffic",
        "16": "car-evening-rush"
      },
      "TRUCK": {
        "6": "truck-early-delivery",
        "12": "truck-midday-routes"
      }
    }
  }
}
```

## API Reference

<ParamField body="profileMatrices" type="object" required>
  Map of vehicle profiles to time-based matrix configurations. Keys are vehicle categories (CAR, TRUCK, BIKE, etc.)
</ParamField>

<ParamField body="matrixServiceUrl" type="string">
  Optional URL for custom matrix service endpoint
</ParamField>
