Overview
The Transcrypts SDK lets you add employment verification to any web application. Install the package, initialize it with your API key, and call verify() to open a secure iframe-based verification widget — all in a few lines of code.
Prerequisites
Before you begin, make sure you have:
Installation
Install the transcrypts package using your preferred package manager:
CDN / Script Tag
You can also load the SDK directly via a script tag. This is useful for vanilla JavaScript projects or quick prototyping.
<script src="https://cdn.jsdelivr.net/npm/transcrypts/dist/index.js" type="module"></script>
Quick Start
The following example shows the minimal setup to run an employment verification:
Initialize the SDK
Create a new Transcrypts instance with your API key:import { Transcrypts } from 'transcrypts';
const transcrypts = new Transcrypts({
apiKey: 'your-api-key',
});
Run a verification
Call the verify() method with the required parameters:const result = await transcrypts.verify({
ssn: '123-45-6789',
user: {
firstName: 'Jane',
lastName: 'Doe',
email: 'jane@example.com',
},
});
Handle the result
Check the result to determine the outcome:if (result.verified) {
console.log('Verification passed', result.verificationId);
console.log('Work history:', result.workExperience);
} else if (result.error?.code === 'USER_CLOSED') {
console.log('User dismissed the widget');
} else {
console.error('Verification failed', result.error);
}
Calling verify() opens a full-screen overlay containing the Transcrypts widget. The returned promise resolves when the user completes or closes the verification flow.
Configuration Options
Pass these options when creating a new Transcrypts instance:
| Option | Type | Required | Default | Description |
|---|
apiKey | string | Yes | — | Your Transcrypts API key. |
widgetUrl | string | No | https://widget.transcrypts.com | URL of the hosted verification widget. |
containerStyle | Partial<CSSStyleDeclaration> | No | Full-screen centered overlay | Custom CSS styles for the widget overlay container. |
Verify Options
Pass these options when calling transcrypts.verify():
| Option | Type | Required | Description |
|---|
ssn | string | Yes | The Social Security Number to verify. |
user.firstName | string | No | Pre-fill the user’s first name. |
user.lastName | string | No | Pre-fill the user’s last name. |
user.email | string | No | Pre-fill the user’s email address. |
Listening to Events
Use the .on() method to subscribe to widget lifecycle events. It returns an unsubscribe function.
const transcrypts = new Transcrypts({ apiKey: 'your-api-key' });
// Subscribe to an event
const unsubscribe = transcrypts.on('verification_complete', (event) => {
console.log('Verification complete:', event.payload);
});
// Later, unsubscribe when no longer needed
unsubscribe();
Available Events
| Event | Description |
|---|
ready | The SDK is initialized and ready. |
loaded | The widget iframe has finished loading. |
verification_started | The user has started the verification process. |
verification_complete | Verification completed successfully. |
verification_failed | Verification encountered an error. |
close | The user closed the widget. |
Each event callback receives a TranscryptsEvent object:
interface TranscryptsEvent {
type: TranscryptsEventType;
payload?: Record<string, unknown>;
}
Error Handling
The verify() method can resolve with an error state or reject with an exception. Use both a try/catch block and a result check to handle all cases.
try {
const result = await transcrypts.verify({ ssn: '123-45-6789' });
if (result.verified) {
// Verification succeeded
console.log('Verified:', result.verificationId);
} else if (result.error) {
// The widget returned a structured error
switch (result.error.code) {
case 'USER_CLOSED':
console.log('User dismissed the widget');
break;
default:
console.error('Verification error:', result.error.message);
}
}
} catch (err) {
// An unexpected error occurred (network failure, widget crash, etc.)
console.error('Unexpected error:', err);
}
The verify() method can both resolve with an error state and reject with an exception. Always use both a try/catch block and a result check.
Error Codes
| Code | Description |
|---|
USER_CLOSED | The user closed the widget or pressed Escape before completing verification. |
Common Errors
| Error | Cause |
|---|
Transcrypts: apiKey is required | The apiKey option was not provided or is empty. |
Transcrypts: ssn is required | The ssn option was not provided to verify(). |
Next Steps