---
title: "Routes Matrix"
method: POST
path: "/api/v1/routes/matrix"
tags: ["grandline"]
---

# Routes Matrix

`POST /api/v1/routes/matrix`

## Request

- Base URL: `https://grandline.luzomi.com`
- URL: `https://grandline.luzomi.com/api/v1/routes/matrix`
- Auth: none declared

Bulk distance grid: every origin × every destination in one call.

A cell is metered like an individual lookup, so a 12×30 matrix consumes 360
calls against the monthly quota — same total cost as 360 single calls, far
fewer round-trips. `variant` omitted returns the recommended (primary)
distance per cell; set it to force a specific routing. Cells with no cached
pair come back `distance_nm: null`, `availability: "route_not_in_cache"`.

## Request body

- MatrixRequest
  - `origins` integer[], required: Origin port_ids.
  - `destinations` integer[], required: Destination port_ids.
  - `variant` string, nullable: One of primary/via_suez/via_panama/via_cape. Omit for the recommended (primary) distance per cell.

## Response `200`

Successful Response

- MatrixResponse
  - `variant` string, nullable, required
  - `cell_count` integer, required
  - `cells` MatrixCell[], required
    - `origin_port_id` integer, required
    - `destination_port_id` integer, required
    - `distance_nm` number, nullable, required
    - `recommended_variant` string, nullable, required
    - `availability` string, required

## Other responses

- `400`: Validation error with extra context
- `404`: Resource not found
- `422`: Validation Error
- `429`: Rate-limit exceeded — see X-RateLimit-* headers

---

[API](https://skmtc.dev/luzomi/apis/grandline-api.md) · [All operations](https://skmtc.dev/luzomi/apis/grandline-api/llms.txt) · [OpenAPI document](https://skmtc.dev/luzomi/apis/grandline-api/revisions/4ce06aea012b?raw)
