@cas-parser/connect v2.x. For the underlying APIs the widget calls, see the API Reference.
Authentication
The widget accepts either credential — both are sent as thex-api-key header. At least one of accessToken / apiKey is required.
- Prefix:
at_ - TTL: 1–60 minutes (default: 60)
- Drop-in replacement for
x-api-keyon/v4/*endpoints - Cannot mint other tokens
Props
Config
Inbound email config
WhenenableInboundEmail: true, the widget creates a one-time forwarding address via POST /v4/inbound-email, polls GET /files, and parses the first file it receives. This works without a callback_url.
You can also pass an existingId (and optionally email) to inject an inbound email you’ve already created on your backend — useful when you want a stable address per user, or when you’re driving the API yourself and only need the SDK for the polling/UI.
The callbackUrl here is the underlying API’s callback_url — set it if you want both webhook delivery to your backend and in-widget reception. Omit for a pure-frontend integration.
Events
onSuccess
onError
The type is widened to
| string, so future codes won’t break exhaustive switches.
onExit
onSuccess / onError if you need to distinguish.
onEvent
- Lifecycle:
WIDGET_OPENED,WIDGET_CLOSED,MODE_SWITCHED,ASSET_SELECTED,BROKER_SELECTED - Upload:
FILE_SELECTED,FILE_REMOVED,UPLOAD_STARTED,UPLOAD_PROGRESS,PARSE_STARTED,PARSE_SUCCESS,PARSE_ERROR - Generator:
GENERATOR_STARTED,GENERATOR_SUCCESS,GENERATOR_ERROR - CDSL fetch:
CDSL_FETCH_STARTED,CDSL_OTP_SENT,CDSL_OTP_VERIFIED,CDSL_FETCH_SUCCESS,CDSL_FETCH_ERROR - Gmail inbox:
INBOX_CONNECT_STARTED,INBOX_CONNECTED,INBOX_FILES_LOADED,INBOX_FILE_SELECTED,INBOX_DISCONNECTED,INBOX_ERROR - Inbound email:
INBOUND_EMAIL_CREATED,INBOUND_EMAIL_COPIED,INBOUND_EMAIL_POLLING,INBOUND_EMAIL_FILE_RECEIVED,INBOUND_EMAIL_TIMEOUT,INBOUND_EMAIL_ERROR - Cross-flow handoffs — measure how often the widget’s nudges convert:
GENERATOR_TO_INBOUND_HANDOFF,INBOX_TO_GENERATOR_HANDOFF,INBOUND_TO_UPLOAD_HANDOFF,UPLOAD_TO_INBOUND_HANDOFF
metadata object always includes timestamp and may include event-specific fields.
onSubmit — collect PDFs without parsing
v2.1+. When onSubmit is provided, the SDK routes every intercept-capable flow through it instead of calling the parse API itself. Useful for:
- Forwarding PDFs to your own backend without burning parse credits
- Custom retry / queueing logic
- Storing a copy of the PDF before parsing
onSuccess. Throw to trigger onError.
Framework integration
React / Next.js
'use client' and fetch the access token from a server route.
Vanilla JS / Angular / Vue (Imperative API)
The standalone bundle ships its own React copy — no host-page React required.- Standalone: ~71 KB (includes React)
- UMD: ~27 KB (requires React 18+ on the page)
open() accepts the same accessToken / apiKey / apiBaseUrl / config / onSubmit / onEvent as the React props, plus an optional onOpen lifecycle hook. The success / error / cancel callbacks are intentionally dropped — the returned OpenResult covers all three outcomes.
If you need manual control (open the widget later, dispose without opening), use PortfolioConnect.create(config) which returns a { open, destroy } handle.
React Native / Flutter
Both are supported via WebView. See the@cas-parser/connect examples for working setups.
Theming
The recommended way to brand the widget is theconfig.theme object — it emits CSS variables on the modal root and derives the full palette (hover, soft, surface, border, text) from your primary colour automatically.
CSS variables
If you need to override individual tokens beyond whattheme exposes, set the CSS variables directly. The full list emitted on the modal root:
theme.mode: 'auto' follows the user’s prefers-color-scheme media query.
Next steps
Inbound Email Guide
Forward-email flow used by
enableInboundEmailAPI Reference
Endpoints the widget calls under the hood

