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

# POST /v1/distance

> Find nearest reference features within a radius.

Discovery endpoint for proximity queries. Send a polygon (or point)
and a `[min_distance_m, max_distance_m]` window; get back features
inside that ring, sorted by distance ascending.

## Request

```json theme={null}
{
  "input": {
    "geometry": { "type": "Point", "coordinates": [-59.5, -2.5] },
    "min_distance_m": 0,
    "max_distance_m": 5000
  },
  "reference_areas_source": "icmbio_ucs_federais",
  "reference_areas_country_iso3": "BRA"
}
```

| Field                          | Required | Notes                              |
| ------------------------------ | -------- | ---------------------------------- |
| `input.geometry`               | yes      | GeoJSON.                           |
| `input.max_distance_m`         | yes      | Inclusive upper bound, in meters.  |
| `input.min_distance_m`         | no       | Inclusive lower bound. Default: 0. |
| `input.crs`                    | no       | Source CRS. Default: `EPSG:4326`.  |
| `reference_areas_source`       | no       | Restrict to one source.            |
| `reference_areas_country_iso3` | no       | Filter sources by country.         |

## Response

```json theme={null}
{
  "data": {
    "hits": [
      {
        "reference_area": {
          "source_name": "icmbio_ucs_federais",
          "source_id": "uc-042",
          "name": "Parque Nacional da Amazônia",
          "country_iso3": "BRA",
          "properties": { ... }
        },
        "distance_m": 423.7
      }
    ],
    "reference_areas_check": "ok"
  },
  "meta": { "request_id": "..." },
  "errors": []
}
```

`hits` are sorted by `distance_m` ascending. Distances are ellipsoidal
(WGS84) in meters.

See the **OpenAPI** tab in the sidebar for the complete request/response
schema.
