# Configuration

The Floorplan SDK is configured during initialisation by passing an options object. These options control what is displayed, how it is displayed, and which parts of the plan are interactive.

***

### Required parameters

| Key            | Type                  | Description                                                                         |
| -------------- | --------------------- | ----------------------------------------------------------------------------------- |
| `key`          | `string`              | DOM element ID where the floorplan will be mounted.                                 |
| `access_token` | `string`              | Short-lived access token generated via the gospace API. Required for secure access. |
| `location_id`  | `string`              | Unique ID of the location to render.                                                |
| `layer_id`     | `string` *(optional)* | Floor/layer to render. If omitted, defaults to the first available.                 |

***

### Optional parameters

| Key           | Type                | Description                                                              |
| ------------- | ------------------- | ------------------------------------------------------------------------ |
| `room_id`     | `string`            | Restrict view to a specific room.                                        |
| `zone_id`     | `string`            | Restrict view to a specific zone/neighbourhood.                          |
| `spaces`      | `string[]`          | Array of space IDs to highlight or restrict view to.                     |
| `mode`        | `"2D" \| "3D"`      | Rendering mode. Defaults to `"2D"`.                                      |
| `highlight`   | `boolean`           | Whether to highlight allocated spaces. Defaults to `true`.               |
| `readonly`    | `boolean`           | Disables interactions if `true`. Defaults to `false`.                    |
| `theme`       | `"light" \| "dark"` | Floorplan theme. Defaults to match system preference.                    |
| `labels`      | `boolean`           | Toggle space labels. Defaults to `true`.                                 |
| `fit_to_view` | `boolean`           | Automatically fit plan to available container space. Defaults to `true`. |
| `debug`       | `boolean`           | Enables console logging for development. Defaults to `false`.            |

***

### Example – minimal

```ts
import Floorplan from "@gospace-ai/floorplan";

const sdk = new Floorplan({
  key: "floorplan-root",
  access_token: "<short-lived-access-token>",
  location_id: "loc_123",
});

sdk.init();
```

***

### Example – advanced

```ts
import Floorplan from "@gospace-ai/floorplan";

const sdk = new Floorplan({
  key: "floorplan-root",
  access_token: "<short-lived-access-token>",
  location_id: "loc_123",
  layer_id: "layer_001",
  mode: "3D",
  highlight: true,
  theme: "dark",
  readonly: false,
  spaces: ["space_a1", "space_a2"],
  labels: true,
  fit_to_view: true,
  debug: true,
});

sdk.init();
```

***

### Access tokens

* Access tokens are **short-lived** and must be generated server-side using your gospace API key.
* Tokens should be scoped to the required resources (location, layer, etc.).
* Never expose your API key directly in the browser — use your backend to request tokens securely.

***

### Container requirements

* The container element (`key`) must exist in the DOM before calling `init()`.
* Set a fixed height or flexible layout so the iframe renders correctly (e.g., `height: 720px` or `height: 100%`).
