SDK overview
One line of JavaScript puts a CoverPort insurance quote-and-purchase flow on any page.
The CoverPort SDK (@coverport/js) lets a partner platform sell cargo insurance from its own pages. The buyer clicks a button on your site, a modal opens, and quoting, payment, and policy issuance all happen inside that modal on CoverPort's origin. Your page never touches insurance data or card details.
Every sale made through your publishable key is attributed to your platform, which is how your surcharge is attached to each purchase.
How it works
You mount a button
coverport.mount('#insure-btn', { key: 'pk_live_…' }) renders a "Get insurance quote" button, or wires up a button you already have.
The buyer opens the flow
Clicking the button opens a modal containing an iframe pointed at https://buy.coverport.io/embed/quote. The iframe carries your key and your page's origin.
CoverPort handles quote, payment, and policy
The buyer enters an email, picks a product, and pays. The certificate of insurance is issued by CoverPort.
Your page gets a complete event
The SDK fires onComplete(sale) with the purchase reference and amount so you can reconcile on your side. See Events.
Two ways to integrate
JavaScript SDK
npm package or script tag. Handles the modal, focus, escape key, and origin checks for you.
Direct iframe
Drop the hosted flow into your own iframe or mobile webview and listen for postMessage events yourself.
Which should I pick?
Use the SDK unless you have a reason not to. It is zero-dependency, about 3 KB, and does the security-sensitive parts (origin checking on incoming messages, one modal at a time) correctly. Use the direct iframe path for native mobile webviews or when your CSP forbids third-party scripts.
Hosts
| Host | Used for |
|---|---|
https://buy.coverport.io | The hosted embed flow (/embed/quote) that the SDK loads in its iframe |
https://dev.coverport.io | Developer portal: create keys, set your platform fee, manage your team |
https://api.coverport.io | The REST API, documented in the API section |