---
title: "Capacity-constrained clustering (see module docs)."
method: POST
path: "/v1/cluster"
tags: ["routing"]
---

# Capacity-constrained clustering (see module docs).

`POST /v1/cluster`

## Request

- Base URL: `https://api.mapmap.ai`
- URL: `https://api.mapmap.ai/v1/cluster`
- Auth: one of:
  - HTTP bearer
  - API key in query parameter `api_key`

## Request body

- object

## Response `200`

`clusters[]` with `id`, member `locations` (your ids), `count`, summed `load`, `centroid` and the `territory` each belongs to; `parameters` echoing the seed, the cluster count, the iterations run and whether it converged; `balance` naming the constraint applied and whether it had to be relaxed; and a `basis` stating that this is straight-line clustering, with the pointer to `POST /optimise` for road-network order

- object

## Other responses

- `400`: Invalid request: neither or both sizing fields, a duplicate or empty location id, an invalid coordinate or load, an invalid territory, more clusters than locations, or a ceiling no clustering could satisfy
- `401`: Missing or invalid API key
- `422`: More than 5,000 locations, or a `locations x clusters` assignment larger than 500,000
- `429`: Quota or rate limit exceeded

---

[API](https://skmtc.dev/mapmap/apis/sn-gateway.md) · [All operations](https://skmtc.dev/mapmap/apis/sn-gateway/llms.txt) · [OpenAPI document](https://skmtc.dev/mapmap/apis/sn-gateway/revisions/2293be8b4c38?raw)
