POST /v1/matrix

Distance Matrix API for many-to-many drive times

Pass a list of origins and destinations and get every road distance and drive time back in a single request — the building block for dispatch, delivery zones and nearest-driver matching.

Request and response

Copy, paste and run with your test key. The response below is an illustrative example.
curl -X POST "https://api.wayline.cloud/v1/matrix" \
  -H "Authorization: Bearer $WAYLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"origins":[{"lat":37.788,"lng":-122.4075},{"lat":37.8313,"lng":-122.2852}],"destinations":[{"lat":37.8044,"lng":-122.2712},{"lat":37.8716,"lng":-122.2727},{"lat":37.9358,"lng":-122.3478}],"units":"imperial"}'
Response (example)
{
  "request_id": "req_01JD8Q7H3W8R",
  "rows": [
    {
      "elements": [
        {
          "distance_meters": 19870,
          "duration_seconds": 1260,
          "status": "OK"
        },
        {
          "distance_meters": 6120,
          "duration_seconds": 840,
          "status": "OK"
        },
        {
          "distance_meters": 14210,
          "duration_seconds": 1290,
          "status": "OK"
        }
      ]
    },
    {
      "elements": [
        {
          "distance_meters": 11880,
          "duration_seconds": 1500,
          "status": "OK"
        },
        {
          "distance_meters": 3010,
          "duration_seconds": 420,
          "status": "OK"
        },
        {
          "distance_meters": 12840,
          "duration_seconds": 1080,
          "status": "OK"
        }
      ]
    }
  ],
  "origins": [
    "…"
  ],
  "destinations": [
    "…"
  ],
  "region": "us",
  "map_version": "20261121-2330",
  "units_charged": 6
}

What the Distance Matrix API gives you

  • Origins × destinations

    Rectangular matrices with origins and destinations, or a symmetric N × N matrix with points.

  • Choose your metrics

    Ask for distance, duration or both to keep payloads small.

  • Per-element status

    Each cell has its own status (OK or NO_ROUTE), so one unreachable pair never fails the whole request.

  • Billed per element

    Units charged = origins × destinations, shown in the X-Units-Charged header on every response.

When to use a distance matrix

Use the matrix when you need to compare many candidates at once: which driver is closest by drive time, which customers fall inside a 30-minute delivery radius, or the input cost matrix for a route optimizer.

Limits

The maximum number of elements per request depends on your rate-limit plan and is shown on this page and in your dashboard. Split larger jobs into tiles; each tile is billed by its element count only.

Frequently asked questions

Is the distance a straight line or a real road distance?

Always real road distance. Every result is computed along the OpenStreetMap road network with a driving profile, never as a straight-line (haversine) estimate.

Which areas do you cover?

Coverage is region-based. The Coverage page lists every enabled region with its map data date. Points outside an enabled region return an OUT_OF_COVERAGE error and are never billed.

How is a matrix request billed?

One unit per element: a 10 × 20 matrix is 200 units. Only successful (2xx) responses are billed. Elements with status NO_ROUTE are still part of the requested matrix.

Can I send addresses instead of coordinates?

The matrix takes coordinates. Where geocoding is available (Bangladesh today), turn addresses into lat,lng with the Geocoding API first, then send the coordinates; elsewhere, geocode with the provider of your choice.

Start building in minutes

Create an account, grab a test key and make your first request in under five minutes.