# Drawn shapes A Premium search or map can be limited to a shape the visitor draws: `location.shape` in the body of `POST /v1/listings/search` or `POST /v1/listings/map`. It combines with every other filter (AND). A key on a Basic account gets `403 tier_insufficient` with `capability: "shapes"`, before anything else about the request is judged. ```json { "status": ["active"], "price": { "max": 600000 }, "location": { "shape": { "type": "Polygon", "coordinates": [[[-75.32, 39.99], [-75.28, 39.99], [-75.28, 40.03], [-75.32, 40.03], [-75.32, 39.99]]] } } } ``` ## What is accepted - a GeoJSON `Polygon` with exactly **one ring** (no holes); - every position exactly `[longitude, latitude]`: two numbers, inside ±180 and ±90; - the ring **closed**: its last position repeats its first; - **3 to 200 corners**. The closing repeat isn't a corner, and a position that repeats the one before it is dropped; - the ring doesn't cross or touch itself. Either winding order is fine; - at most **5,000 km²**. The largest county in the region is about 4,035 km²; for a whole city or county, search its place with `location.placeIds` instead. Edges are straight lines in longitude and latitude, as a web map draws them. A drawn shape is `POST` only: in a query string, `location.shape` is `400 validation_failed`. One shape per request. To reuse a shape, [save it](../reference/saved-shapes.md) and send its `location.shapeId`, which also works in the `GET` forms. ## What it finds Listings whose point lies inside the shape or on its edge, and that pass the other filters. A listing whose address is withheld, a listing with no coordinates and a listing whose point lies outside the seven jurisdictions are **never** found or counted by a shape, however it is drawn: they are found through their city, ZIP code, subdivision and place memberships (see [hidden addresses](hidden-addresses.md)). On the map, clusters are laid on a grid sized from the request's `bbox` if it has one, else from the shape's own bounding box. ## Errors A shape that isn't acceptable is refused with one of two codes, each with the field it came in (`location.shape`, or `geometry` when [saving](../reference/saved-shapes.md)) and a `reason`: | Code | `reason` | What was wrong | | --- | --- | --- | | [`shape_invalid`](../errors/shape_invalid.md) | `not_a_polygon` | not an object of `type: "Polygon"` with `coordinates` (a `MultiPolygon`, a `Feature`, a string) | | | `holes_not_allowed` | more than one ring | | | `bad_coordinate` | a position that isn't exactly two numbers in range (a third number, an elevation, is refused too) | | | `not_closed` | the last position doesn't repeat the first | | | `too_few_vertices` | fewer than three corners | | | `self_intersecting` | the ring crosses or touches itself | | [`shape_too_large`](../errors/shape_too_large.md) | `too_many_vertices` | more than 200 corners; the error carries `vertices` and `maxVertices` | | | `area_too_large` | more than 5,000 km²; the error carries `areaSqKm` and `maxAreaSqKm` | ```json { "error": { "code": "shape_invalid", "message": "The ring crosses or touches itself.", "fix": "…", "docs": "…/errors/shape_invalid", "requestId": "req_…", "fields": [ { "path": "location.shape", "problem": "self_intersecting", "expected": "…" } ], "field": "location.shape", "reason": "self_intersecting" } } ``` An error never repeats a coordinate. A body over 64 KiB is `400 validation_failed` naming the size, whatever it holds. ## A drawn shape is never kept The API doesn't store a drawn shape, write it to a log, or put it in a cursor or an error. Only a shape the consumer chooses to save is stored. A page cursor is bound to the shape it was made for: sent with another shape, it is `400 validation_failed` on `cursor`.