# Relynk buildings

Listing the tenant's buildings and their ids, the starting point for most other Relynk calls.

Each function is a POST to the path shown, relative to the connector's base URL, with its body as JSON; the response is JSON. The types below are JSDoc.

Notes:
- Add `?tenantId=<id>` to every call when `GET /me` lists more than one tenant for the user.
- Errors are `{ "error": { "code", "message" } }`; a 400 message says how to change the request.
- Lists page with `nextCursor` (or `offset` and `hasMore`). Times are Europe/Oslo, ranges half-open `[from, to)`, ids are UUIDs. `null` means no data.
- A path never changes its contract; a new version gets a new path.

## POST /buildings.list/v1

Buildings the user can see in this tenant, ordered by name, or by how well they match search. Page with offset while hasMore is true.

Body: `BuildingsListInput`. Response: `BuildingsListOutput`.

```js
/**
 * @typedef {Object} BuildingsListInput
 * @property {string} [search] Only buildings whose name resembles this text (fuzzy: a word, part of a name or a near miss), best matches first (min length 1, max length 200)
 * @property {number} [limit=100] Buildings per page (min 1, max 500)
 * @property {number} [offset=0] Buildings to skip, for paging (min 0)
 */

/**
 * @typedef {Object} BuildingsListOutput
 * @property {Array<BuildingsListOutputBuildingsItem>} buildings (max items 500)
 * @property {boolean} hasMore True when more buildings follow this page
 */

/**
 * @typedef {Object} BuildingsListOutputBuildingsItem
 * @property {string} id Building id; pass it to other functions that take a building
 * @property {string} name
 */
```