Skip to content

50,000 free calls a month, card-free. Get an API key →

Documentation menu
docs / api / post-v1-cluster
routing

POST/v1/cluster

API key required, sent as Authorization: Bearer snk_… or ?api_key=snk_….

Call it

bash
curl -fsS -X POST "https://api.mapmap.ai/v1/cluster" \
  -H "Authorization: Bearer $MAPMAP_KEY" \
  -H "Content-Type: application/json" \
  -d @request.json

Request body

application/json

locations ([{id, lat, lon, load?}], ids unique, at most 5,000), plus EXACTLY ONE of clusters (how many groups to produce, balanced by stop count) or max_cluster_size ({"locations": n} or {"load": x}, a per-cluster ceiling from which the count is derived). Optional territories ([{id, polygon}], GeoJSON [lon, lat] rings, same shape as on POST /optimise) keeps clusters from straddling a round: each territory is clustered on its own, and so are the stops inside none of them. Optional seed (default 42) drives the k-means++ seeding; the same request with the same seed always returns the same clusters

The OpenAPI document declares this body as a free-form JSON object with no field list, so there is nothing here to generate a table from. The prose above is what the gateway states about it; the raw document is the authority.

Responses

200clusters[] 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
400Invalid 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
401Missing or invalid API key
422More than 5,000 locations, or a locations x clusters assignment larger than 500,000
429Quota or rate limit exceeded

Error bodies follow the shared problem model documented on API conventions.

Also under routing

Generated from https://api.mapmap.ai/openapi.json on 2026-09-17 · operationId post_cluster