> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.kota.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.kota.io/_mcp/server.

# Embed SDK Reference

> Reference for the Kota Embed SDK

## Including Kota.js

Include the Kota.js script on each page you want to run it on - it should always be loaded directly from [https://js.kota.io](https://js.kota.io) or [https://test.js.kota.io](https://test.js.kota.io), rather than included in a bundle or hosted yourself. This ensures compliance and future updates.

When you are ready to go-live make sure your production environment is not including the test SDK.

**`Including Kota.js for testing`**

```javascript title="Including Kota.js for testing"
<script src="https://test.js.kota.io/v1"></script>
```

**`Including Kota.js for production`**

```javascript title="Including Kota.js for production"
<script src="https://js.kota.io/v1"></script>
```

---

## Initialising Kota.js

### Employer

#### Kota.Health.employer(employerAccessToken, options?)

Use `Kota.Health.Employer(employerAccessToken, options?)` to create an instance of the Kota Health's `Employer` embedded UI.

The `employerAccessToken` can be retrieved from the [Embed Session endpoint.](/api-reference/embed-sessions/create-embed-session)

Once initialised, if the optional `container` has not been provided, the employer embed will load in on a `<div>` with `id="employer"`.

#### Method parameters

employerAccessTokenstringRequired

Token retrieved from the `/embed/session` endpoint to authenticate the user session.

options objectOptional

container

stringOptional

The `id` of the container to load the Embedded UI in.\
Default value: `employer`

theme

objectOptional

Allows you to customise the look and feel of the embedded UI to match your platform. Learn about [theming your embedded UI here.](/embed/theming)

dependants_cover

enumOptional

Configure employer's options for covering dependants. `Full` allows employers to choose covering spouse & children separately, `binary` restricts employer cover to all dependants or none, and `none` doesn't allow the employer to cover their employees' dependants.
Default value: `full`

Allowed values: fullbinarynone

**`JavaScript (ESNext)`**

```javascript title="JavaScript (ESNext)"
const employerEmbed = Kota.Health.employer();

const themeConfig = {
  primaryColor: '#0875E1',
  backgroundColor: '#fff',
  radius: '12px',
  ringColor: '#0875E1'
};

employerEmbed.init(
  employerAccessToken,
  { container: 'employer', theme: themeConfig }
);
```

**`HTML`**

```html title="HTML"
<div id='employer' style="width: 90%; margin: 20px auto;"/>
```

### Employee

#### Kota.Health.employee(employeeAccessToken, options?)

Use `Kota.Health.Employee(employeeAccessToken, options?)` to create an instance of the Kota Health's `Employee` embedded UI.

The `employeeAccessToken` can be retrieved from the [Embed Session endpoint.](/api-reference/embed-sessions/create-embed-session)

Once initialised, if the optional `container` has not been provided, the employer embedded will load in on a `<div>` with `id="employee"`.

#### Method parameters

employeeAccessTokenstringRequired

Token retrieved from the `/embed/session` endpoint to authenticate the user session.

options objectOptional

container

stringOptional

The `id` of the container to load the Embedded UI in.\
Default value: `employee`

theme

objectOptional

Allows you to customise the look and feel of the embedded UI to match your platform. Learn about [theming your embedded UI here.](/embed/theming)

**`JavaScript (ESNext)`**

```javascript title="JavaScript (ESNext)"
const employeeEmbed = Kota.Health.employee();

const themeConfig = {
  primaryColor: '#0875E1',
  backgroundColor: '#fff',
  radius: '12px',
  ringColor: '#0875E1'
};

employeeEmbed.init(
  employeeAccessToken,
  { container: 'employee', theme: themeConfig }
);
```

**`HTML`**

```html title="HTML"
<div id='employee' style="width: 90%; margin: 20px auto;"/>
```

---

## Browser events

The only way to communicate with your Embedded UI in the browser is by listening to an event.

You can set up listeners directly from your initialised `employer` and `employee` objects or by directly listening for the events on the window.

**`Embedded object`**

```javascript title="Embedded object"
// events can be called on this object
const employerEmbed = Kota.Health.employer();
employerEmbed.init(employeeAccessToken);

function handler(event) {
  // Handle any metrics or actions here
}

employerEmbed.on('eventName', handler);
```

**`addEventListener`**

```javascript title="addEventListener"
function handler(event) {
  // Handle any metrics or actions here
}

window.addEventListener('eventName', handler);
```

<table class="kota-table fern-table reference-table">
  <caption>
    BROWSER EVENT LIST
  </caption>

  <thead>
    <tr>
      <th>
        Event name
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tr>
    <td>
      employer.pageLoaded
    </td>

    <td>
      Fires when a new page loads. Object contains page title.
    </td>
  </tr>

  <tr>
    <td>
      employer.healthSetupLoaded
    </td>

    <td>
      Fires when the employer health insurance setup flow loads.
    </td>
  </tr>

  <tr>
    <td>
      employer.healthManagementLoaded
    </td>

    <td>
      Fires when the employer health insurance setup management loads.
    </td>
  </tr>

  <tr>
    <td>
      employer.loadError
    </td>

    <td>
      Fires when the employer embedded UI fails to load.
    </td>
  </tr>

  <tr>
    <td>
      employee.pageLoaded
    </td>

    <td>
      Fires when a new page loads. Object contains page title.
    </td>
  </tr>

  <tr>
    <td>
      employee.healthSetupLoaded
    </td>

    <td>
      Fires when the employee health insurance setup flow loads.
    </td>
  </tr>

  <tr>
    <td>
      employee.healthManagementLoaded
    </td>

    <td>
      Fires when the employee health insurance setup management loads.
    </td>
  </tr>

  <tr>
    <td>
      employee.loadError
    </td>

    <td>
      Fires when the employee embedded UI fails to load.
    </td>
  </tr>
</table>

---

### pageLoaded

The `pageLoaded` event fires each time a new page is loaded throughout an Embedded UI - both for `employer` and `employee`.

You can listen for it directly from your initialised objects, e.g. `employerEmbed.on('pageLoaded', handler)`, or with event listeners. If listeningly directly be careful to listen for the correct event as they are namespaced by `employer` and `employee` - see the event list for more information.

#### Method parameters

event"pageLoaded"Required

The name of the event. See code examples for the embedded object and window listeners.

handler

functionRequired

`handler(event) => void` is a callback function that you provide that will be called when the event is fired. \

After it's called, it passes an event object with the following properties:

pageTitle string

The title of the page loaded in the Embedded UI.

**`Employer Embedded`**

```javascript title="Employer Embedded"
employerEmbed.on('pageLoaded', function(event) {
  // Handle employer pageLoaded event
})
```

**`Employee Embedded`**

```javascript title="Employee Embedded"
employeeEmbed.on('pageLoaded', function(event) {
  // Handle employer pageLoaded event
})
```

**`addEventListener`**

```javascript title="addEventListener"
function handler(event) {
  // Handle employer pageLoaded event
}

window.addEventListener('employer.pageLoaded', handler);
window.addEventListener('employee.pageLoaded', handler);
```

---

### healthSetupLoaded

The `healthSetupLoaded` event fires each time a new page is loaded throughout an Embedded UI - both for `employer` and `employee`.

You can listen for it directly from your initialised objects, e.g. `employerEmbed.on('healthSetupLoaded', handler)`, or with event listeners. If listeningly directly be careful to listen for the correct event as they are namespaced by `employer` and `employee` - see the event list for more information.

#### Method parameters

event"healthSetupLoaded"Required

The name of the event. See code examples for the embedded object and window listeners.

handler

functionRequired

`handler(event) => void` is a callback function that you provide that will be called when the event is fired.

**`Employer Embedded`**

```javascript title="Employer Embedded"
employerEmbed.on('healthSetupLoaded', function(event) {
  // Handle employer pageLoaded event
})
```

**`Employer Embedded`**

```javascript title="Employer Embedded"
employeeEmbed.on('healthSetupLoaded', function(event) {
  // Handle employer pageLoaded event
})
```

**`addEventListener`**

```javascript title="addEventListener"
function handler(event) {
  // Handle employer pageLoaded event
}

window.addEventListener('employer.healthSetupLoaded', handler);
window.addEventListener('employee.healthSetupLoaded', handler);
```

---

### healthManagementLoaded

The `healthManagementLoaded` event fires each time a new page is loaded throughout an Embedded UI - both for `employer` and `employee`.

You can listen for it directly from your initialised objects, e.g. `employerEmbed.on('healthManagementLoaded', handler)`, or with event listeners. If listeningly directly be careful to listen for the correct event as they are namespaced by `employer` and `employee` - see the event list below for more information.

#### Method parameters

event"healthManagementLoaded"Required

The name of the event. See code examples for the embedded object and window listeners.

handler

functionRequired

`handler(event) => void` is a callback function that you provide that will be called when the event is fired.

**`Employer Embed`**

```javascript title="Employer Embed"
employerEmbed.on('healthManagementLoaded', function(event) {
  // Handle employer pageLoaded event
})
```

**`Employee Embed`**

```javascript title="Employee Embed"
employeeEmbed.on('healthManagementLoaded', function(event) {
  // Handle employer pageLoaded event
})
```

**`addEventListener`**

```javascript title="addEventListener"
function handler(event) {
  // Handle employer pageLoaded event
}

window.addEventListener('employer.healthManagementLoaded', handler);
window.addEventListener('employee.healthManagementLoaded', handler);
```

---

### loadError

The `loadError` event fires when the Embedded UI fails to load.

You can listen for it directly from your initialised objects, e.g. `employerEmbed.on('loadError', handler)`, or with event listeners. If listeningly directly be careful to listen for the correct event as they are namespaced by `employer` and `employee` - see the event list below for more information.

#### Method parameters

event"loadError"Required

The name of the event. See code examples for the embedded object and window listeners.

handler

functionRequired

`handler(event) => void` is a callback function that you provide that will be called when the event is fired.

**`Employer Embed`**

```javascript title="Employer Embed"
employerEmbed.on('loadError', function(event) {
  // Handle employer loadError event
})
```

**`Employee Embed`**

```javascript title="Employee Embed"
employeeEmbed.on('loadError', function(event) {
  // Handle employee loadError event
})
```

**`addEventListener`**

```javascript title="addEventListener"
function handler(event) {
  // Handle employer loadError event
}

window.addEventListener('employer.loadError', handler);
window.addEventListener('employee.loadError', handler);
```

---