@userplane/sdk package provides a JavaScript API for integrating Userplane into your web application. Use it to initialize the SDK, programmatically trigger recording flows, query recording state, and attach custom metadata.
For most setups, you only need the embed script (see Installation). The SDK package is for when you need programmatic control — for example, triggering a recording from a button in your app or attaching user-specific metadata.
Installation
Initialization
initialize(options?)
Initializes the Userplane SDK. Call this once when your application loads. Subsequent calls are ignored.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
options | InitializeOptions | {} | Configuration options (optional) |
InitializeOptions
| Property | Type | Default | Description |
|---|---|---|---|
workspaceId | string | string[] | Read from <meta name="userplane:workspace"> | Your workspace ID. Can be a single ID or an array for multi-workspace setups. |
openImmediately | boolean | string | true | Controls auto-open behavior. true: auto-open when recording URL params are detected. false: don’t auto-open. string: a recording token to open immediately. |
captureEnabled | boolean | true | Whether to mount the background capture iframe for collecting console logs and network requests. |
parseUserplaneData | (href: string) => SerializableUserplaneData | null | Built-in parser | Custom function to parse userplane-action and userplane-token from the URL. Use this if your app uses non-standard URL routing. |
applyUserplaneData | (data: SerializableUserplaneData) => string | Built-in handler | Custom function for applying Userplane data to the URL, used during cross-tab sync. |
excludeCaptureEndpoints | string[] | [] | URLs to exclude from network log capture. Merged with Userplane’s internal endpoints. Useful for filtering out auth, payment, or analytics calls. |
Examples
Basic initialization:Recorder control
open(token?)
Opens the recording flow for the user. Returns true if the recorder was opened, false otherwise (e.g. if the SDK is not initialized or the recorder is already mounted).
| Parameter | Type | Default | Description |
|---|---|---|---|
token | string | From URL params | Recording token. If omitted, the SDK uses the token from the current URL query parameters. |
boolean
unmount()
Closes and unmounts the recorder. If background capture is enabled, the capture iframe is re-mounted after the recorder is removed.
isInitialized()
Returns true if the SDK has been initialized.
isRecorderMounted()
Returns true if the recorder is currently mounted and visible.
Recording state
getRecordingState()
Returns the current recording state.
Returns: RecordingState — one of 'inactive', 'active', or 'retained'
| State | Description |
|---|---|
inactive | No recording is in progress |
active | A recording is currently in progress |
retained | A recording session exists but the recorder is not actively recording |
getRecordingContext()
Returns the full recording context, or null if no context is available.
Returns: RecordingContext | null
getSessionId()
Returns the current recording session ID, or null if no session is active.
Returns: string | null
getLinkId()
Returns the recording link ID for the current session, or null if no session is active.
Returns: string | null
Tab management
getTabRef()
Returns the unique tab reference for this browser tab. This is persisted in sessionStorage for the lifetime of the tab and is used internally to manage cross-tab recording state.
Returns: string | null
clearTabRef()
Clears the tab reference from sessionStorage. A new reference is generated on the next initialization.
Connection state
isBridgeConnected()
Returns true if the bridge connection between the SDK and the recorder iframe is established. Useful for debugging integration issues.
Returns: boolean
HTML attributes and meta tags
The SDK recognizes HTML attributes and meta tags for configuring blur and workspace identity.Blur attributes
Usedata-userplane-blur to blur sensitive elements in recordings:
.userplane-mask CSS class or <meta name="userplane:blur"> tags. See the Sensitive Data Redaction Developer Guide for the full list of blur methods and third-party compatibility.
Workspace meta tag
If you don’t passworkspaceId in initialize(), the SDK reads it from meta tags:
URL parameters
When a customer opens a recording link, Userplane appends these query parameters to the URL:| Parameter | Description |
|---|---|
userplane-token | The recording session token |
userplane-action | The action type (recording, verify, or capture) |
userplane-workspace | The workspace ID |
parseUserplaneData option.
Common patterns
Trigger recording from a support button
Show recording state in your UI
Correlate recordings with your own analytics
Integration with recording links
The SDK works alongside recording links. When a customer opens a recording link on a page where the SDK is initialized, the SDK can provide additional context:- Custom metadata is attached to the recording.
- Blur attributes are respected during capture.
- Domain recording preferences are applied.
Related articles
- Metadata SDK — attach custom metadata to recordings.
- Installation — install and configure the embed script.
- Sensitive Data Redaction Developer Guide — configure blur to protect sensitive content.
- Recording Data Reference — what data is captured.