Skip to main content

Iframe Integration

Show the SwyftFilings Customer Portal inside a page on your own website, such as https://www.example.com/my-filings. Your customer is signed in automatically with a token your server requests from the API. The portal shows your branding and only the sections enabled for your partner account.

1. Register your domains​

Browsers only show the portal in an iframe on domains that SwyftFilings has registered. On any other domain, the browser blocks the iframe.

Send your SwyftFilings contact:

  • every domain that will host the iframe, including subdomains (for example www.example.com and example.com);
  • which environment each domain is for: sandbox or production.

Domains are registered for each environment separately. Wait until SwyftFilings confirms them before you go live.

Local development

Pages served from https://localhost (port 443) can always show the portal, so you can build and test before your domains are registered. http://localhost and other ports, such as https://localhost:3000, are blocked.

2. Request a token from your server​

Each time you render the portal, your server requests a token for the signed-in customer:

GET /tokens/{CUSTOMER_EMAIL}/ucp
Authorization: Bearer {ACCESS_TOKEN}
{
"data": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOi...",
"partner_id": 1234
},
"success": true
}
  • Make this request from your backend. Your API credentials and access token must never reach the browser.
  • The customer must have at least one order placed through your partner account.
  • Request a new token every time you render the iframe. Tokens expire after a short time, and each new token replaces the customer's previous one. An iframe URL built from an older token stops working.

See Customer Portal Access Token for errors and details.

3. Add the iframe to your page​

Build the iframe URL from the token and partner_id in the response:

<iframe
id="swyft-portal"
title="My filings"
src="https://www.swyftfilings.com/portal/login?id={TOKEN}&partner-id={PARTNER_ID}"
style="width: 100%; height: 100vh; min-height: 800px; border: none;"
sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox"
referrerpolicy="strict-origin"
></iframe>
  • id is the token. partner-id is the partner_id from the same response. Don't hard-code partner-id. Use the value the API returns, because the portal only signs the customer in when it matches their partner account.
  • The portal must be framed. If the same URL is opened directly in a browser tab, the customer is not signed in. Always load it in the iframe.
  • Height: the portal doesn't report its height to your page. Give the iframe a fixed or viewport-based height, as in the example.
  • sandbox: if you add one, keep at least the values above. The portal needs them to save the session, submit forms, and open payment and document windows.

After the customer is signed in, the portal opens their Dashboard.

4. Follow the customer's navigation (optional)​

Each time the customer opens another page in the portal, the portal sends a PORTAL_NAVIGATION message to your page:

{
"type": "PORTAL_NAVIGATION",
"payload": { "page": "/my-orders" }
}

payload.page is the portal path, without the /portal prefix. Use it for your own analytics, to highlight your own navigation, or to scroll your page to the top.

<script>
const PORTAL_ORIGIN = "https://www.swyftfilings.com";

window.addEventListener("message", (event) => {
if (event.origin !== PORTAL_ORIGIN) return;
if (event.data?.type !== "PORTAL_NAVIGATION") return;

const page = event.data.payload.page;

if (page.startsWith("/login")) {
// Sign-in page. Don't record this path: it can include the token.
return;
}

// e.g. analytics.track("portal_page_viewed", { page });
});
</script>
caution

Always check event.origin, and never send /login paths to analytics or logs. The first message can contain the sign-in URL, including the token.

Handling an expired session​

If the customer's session ends while the portal is open, the portal goes back to its sign-in page and sends a PORTAL_NAVIGATION message whose page starts with /login. If you receive one after the customer reached any other page, request a new token from your server and reload the iframe with the new URL.

5. Send the customer to a page (optional)​

Your page can send the same message to open a portal section. For example, use it for links in your own menu:

const portal = document.getElementById("swyft-portal");

portal.contentWindow.postMessage(
{ type: "PORTAL_NAVIGATION", payload: { page: "/my-documents" } },
"https://www.swyftfilings.com"
);
Sectionpage
Dashboard/
My Orders/my-orders
My Documents/my-documents
Compliance Manager/compliance-manager
Billing & Subscriptions/billing-details
Order New Services/new-services

Only send customers to sections enabled for your partner account.

6. Apply your branding​

The portal uses your colors, fonts, wording and section list. SwyftFilings sets these up for your partner account, so you don't pass anything in the iframe URL. See Branding and sections.

Testing​

  1. Ask SwyftFilings to register your test domain for the sandbox environment, or test from https://localhost.

  2. Request tokens from the sandbox API with your sandbox credentials, for a customer who has a sandbox order.

  3. Use the sandbox portal URL in your iframe:

    https://www.qa.swyftfilings.com/portal/login?id={TOKEN}&partner-id={PARTNER_ID}

    In your message listener, set PORTAL_ORIGIN to https://www.qa.swyftfilings.com.

  4. Check that the customer is signed in, sees your branding, and can open each enabled section.

  5. Before going live, switch the iframe src, PORTAL_ORIGIN and your API base URL to production, and confirm that your production domains are registered.

Troubleshooting​

The iframe is blank​

If your domain isn't registered for the environment, the browser blocks the portal. The iframe shows a blank page or a "refused to connect" icon:

A partner page whose portal iframe is blank, showing only a broken-page icon

The browser console (DevTools → Console) explains why. Look for a frame-ancestors error:

Console error: Framing violates the Content Security Policy directive frame-ancestors

The "Framing" line names the portal, not your site. Ask SwyftFilings to register the domain of your page, the one in your browser's address bar, for that environment. To test before then, use https://localhost.

Other problems​

SymptomLikely cause
The iframe is blank or "refused to connect", and the browser console mentions frame-ancestorsYour domain isn't registered for this environment. For local testing, use https://localhost without a port.
The portal shows its sign-in form instead of the customer's dashboardThe token was rejected. It expired, a newer token was issued for this customer, or partner-id doesn't match the token's response. Request a new token and reload the iframe.
The portal opens in a new tab but the customer isn't signed inThe portal only signs customers in when it is framed. Load it in the iframe.
The portal shows the default SwyftFilings colorsYour branding isn't applied in this environment yet. Contact SwyftFilings.
GET /tokens/{email}/ucp returns 422The email doesn't belong to one of your customers. See Customer Portal Access Token.
Payment or document windows don't openThe sandbox attribute is missing allow-popups or allow-popups-to-escape-sandbox.