v1 POST

Spatial Queries

Spatial queries find records by geographic location. All spatial endpoints use POST with a JSON body and require at least read-only scope.


POST /v1/records/query/bbox

Find records within a bounding box (rectangle on the map).

Request Body

{
  "min_lng": -74.01,
  "min_lat": 40.70,
  "max_lng": -73.95,
  "max_lat": 40.80,
  "form_id": "frm_xyz",
  "limit": 100
}
Field Required Description
min_lng Yes West longitude
min_lat Yes South latitude
max_lng Yes East longitude
max_lat Yes North latitude
form_id No Filter by form
project_id No Filter by project
limit No Max results (default 50, max 500)

Example

curl -X POST \
  -H "X-API-Key: mk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"min_lng": -74.01, "min_lat": 40.70, "max_lng": -73.95, "max_lat": 40.80}' \
  "https://<ref>.supabase.co/functions/v1/api-gateway/v1/records/query/bbox"

POST /v1/records/query/radius

Find records within a radius (circle) from a center point.

Request Body

{
  "lng": -73.985,
  "lat": 40.758,
  "radius_meters": 500,
  "form_id": "frm_xyz"
}
Field Required Description
lng Yes Center longitude
lat Yes Center latitude
radius_meters Yes Search radius in meters
form_id No Filter by form
project_id No Filter by project
limit No Max results (default 50, max 500)

Example

curl -X POST \
  -H "X-API-Key: mk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"lng": -73.985, "lat": 40.758, "radius_meters": 500}' \
  "https://<ref>.supabase.co/functions/v1/api-gateway/v1/records/query/radius"

POST /v1/records/query/intersects

Find records that intersect with any GeoJSON geometry (polygon, line, etc.).

Request Body

{
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-73.99, 40.75],
      [-73.98, 40.75],
      [-73.98, 40.76],
      [-73.99, 40.76],
      [-73.99, 40.75]
    ]]
  },
  "form_id": "frm_xyz"
}
Field Required Description
geometry Yes GeoJSON geometry object
form_id No Filter by form
project_id No Filter by project
limit No Max results (default 50, max 500)

Example: Find Records in a Polygon

curl -X POST \
  -H "X-API-Key: mk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "geometry": {
      "type": "Polygon",
      "coordinates": [[[-73.99,40.75],[-73.98,40.75],[-73.98,40.76],[-73.99,40.76],[-73.99,40.75]]]
    }
  }' \
  "https://<ref>.supabase.co/functions/v1/api-gateway/v1/records/query/intersects"

Response (all spatial endpoints)

{
  "ok": true,
  "data": [
    {
      "id": "rec_abc123",
      "type": "record",
      "form_id": "frm_xyz",
      "properties": {"inspector_name": "Jane Smith"},
      "geometry": {"type": "Point", "coordinates": [-73.985, 40.758]},
      "created_at": "2026-02-15T14:30:00Z",
      "status": "active"
    }
  ]
}

Use Cases

  • Dashboard maps: Load records visible in the current map viewport using bounding box
  • Proximity alerts: Find inspections within 1km of a new work order using radius
  • Zone analysis: Find all records within a regulatory boundary polygon using intersects

Brauchen Sie Hilfe mit der API? Kontaktieren Sie unser Support-Team.

Kostenlos Starten