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

# License key

> Apply a hostname license key and read its state.

Every deployed hostname needs a valid key, including public prototypes and non-commercial demos. Local development needs no key. These functions apply the key and tell you its state.

## Import

```typescript theme={null}
import {
  setLicenseKey,
  getLicenseState,
  getLicenseInfo,
  LicenseError,
} from '@opengeometry/floorkit';
```

## Example

```typescript theme={null}
import { Floorkit, LicenseError, getLicenseState } from '@opengeometry/floorkit';

export async function start(wasmURL: string, licenseKey: string): Promise<void> {
  const floorkit = new Floorkit({ licenseKey });
  await floorkit.setupOpenGeometry(wasmURL);
  await floorkit.setLicenseKey(licenseKey);
  console.info(`Floorkit license: ${getLicenseState()}`);
}

export function isLicenseRefusal(error: unknown): error is LicenseError {
  return error instanceof LicenseError;
}
```

<Card title="Ask about a license" icon="key" href="https://ploterr.com/floorkit">
  Talk with our team about a license for your product.
</Card>

## Notes

* Give the key exactly as you received it. Do not add spaces or line breaks.
* Apply the key before the first view or the first export.
* Without a valid key on a deployed site, exports throw `LicenseError`. `saveProject` always works.
* See [Licensing](/floorkit/licensing) to ask about a license.

## setLicenseKey

Apply a floorkit license key.

```typescript theme={null}
function setLicenseKey(key?: string | null): Promise<LicenseState>;
```

## getLicenseState

The license state of this page.

```typescript theme={null}
function getLicenseState(): LicenseState;
```

## getLicenseInfo

The verified key's details, or `undefined` when no valid key is applied.

```typescript theme={null}
function getLicenseInfo(): LicenseInfo | undefined;
```

## LicenseError

Thrown by an export when the site has no valid license key.

```typescript theme={null}
class LicenseError extends Error {
  readonly code: LicenseBlockReason;
  readonly operation: string;
  constructor(code: LicenseBlockReason, operation: string);
}
```

## Types

### LicenseState

The license state of this page.

```typescript theme={null}
type LicenseState =
  | 'development'
  | 'pending'
  | 'unlicensed'
  | 'invalid'
  | 'wrong-domain'
  | 'expired'
  | 'trial-expired'
  | 'trial'
  | 'internal'
  | 'licensed';
```

### LicenseInfo

What a verified license key says.

```typescript theme={null}
interface LicenseInfo {
  readonly id: string;
  readonly organization: string;
  readonly type: LicenseType;
  readonly hosts: readonly string[];
  readonly issuedAt: Date;
  readonly expiresAt: Date;
}
```

<ResponseField name="id" type="string" required>
  The key id.
</ResponseField>

<ResponseField name="organization" type="string" required>
  The organisation the key was issued to.
</ResponseField>

<ResponseField name="type" type="LicenseType" required>
  The kind of key.
</ResponseField>

<ResponseField name="hosts" type="readonly string[]" required>
  The host rules the key is valid for.
</ResponseField>

<ResponseField name="issuedAt" type="Date" required>
  When the key was issued.
</ResponseField>

<ResponseField name="expiresAt" type="Date" required>
  The end date of the key.
</ResponseField>

### LicenseType

The kind of a floorkit license key.

```typescript theme={null}
type LicenseType = 'trial' | 'paid' | 'internal';
```

### LicenseBlockReason

Why an export was refused.

```typescript theme={null}
type LicenseBlockReason = 'no-key' | 'invalid-key' | 'wrong-domain' | 'expired';
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.