# Kernstra.setLicense()

```ts
static setLicense(token: string): Promise<LicenseState>
```

Replaces the license at runtime; resolves to the new license state. A `setLicense` is a load: the licensing API confirms the token's status, and a license that does not load (revoked, paused, expired, a copied token, a host it does not name, a malformed or forged key) shows the "license required" popup — signing out with `''` stops nothing that is open. Presenting the same key again changes neither a pause nor a revocation.

A verdict that adds rights reaches open documents at once; a viewer whose document's rights grow rebuilds its toolbar. A verdict that takes rights away reaches only the next load: each document keeps the rights it was opened with until it is closed.

- Kind: static method
- Since: 1.0.0

| Parameter | Type | Description |
| --- | --- | --- |
| `token` | `string` | The new license token. `''` signs out: it forgets the cached token, but not a stop — only a license that loads lifts a pause or a revocation. |

Returns `Promise<LicenseState>`: Resolves to the new license state.

```ts
const state = await Kernstra.setLicense(newToken);
if (state.valid && state.features.includes('export')) enableDownload();
```

Part of [Kernstra](https://kernstra.com/docs/web-sdk/api/kernstra) in the Kernstra Web SDK 1.0.0 API reference.

Web page: https://kernstra.com/docs/web-sdk/api/kernstra/setlicense
