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

# Onboarding SDK

A lightweight JavaScript SDK for embedding the [Payroll Integrations](https://payrollintegrationsapp.com) onboarding flow into your web application via an iframe.

## Overview

The SDK mounts a secure iframe into a host element on your page and handles two-way communication between your app and the Payroll Integrations platform using the `postMessage` API.

## Installation

> **Note:** This package has not yet been published. Installation instructions will be added once it is available.

## Usage

1. Add a host element to your page:

```html theme={null}
<div id="pi-host"></div>
```

2. Call `bootstrap` with the `onboardingLink` obtained from the [Create Employer Invite Session endpoint]:

```js theme={null}
import { bootstrap } from "@payroll-integrations/onboarding-sdk";

bootstrap({
  onboardingLink: "YOUR_ONBOARDING_LINK",
  callbacks: {
    success: (value) => console.log("Onboarding complete", value),
    error: (value) => console.error("Onboarding error", value),
  },
});
```

## Configuration

A configuration object must be provided to the `bootstrap` function. It has the following properties:

### `onboardingLink` <small>(required)</small>

Link retrieved from the [Create Employer Invite Session endpoint]

*Type:* `string`

### `selector`

CSS selector for the element to mount the iframe into

*Type:* `string`

*Default:* `#pi-host`

### `callbacks.success`

Called when onboarding completes successfully

*Type:* `(value: string) => unknown`

### `callbacks.error`

Called when an error occurs

*Type:* `(value: string) => unknown`

### `callbacks.message`

Called for outbound debug messages sent from the iframe

*Type:* `(value: string) => unknown`

### `frameHost`

Intended for development only. Overrides the iframe host URL.

*Type:* `string`

*Default:* `https://secure.payrollintegrationsapp.com`

[Create Employer Invite Session endpoint]: /api-reference/endpoint/post-v1-employer-identifiers-employer-identifier-invites-invite-session
