Skip to main content
The Rubie Embedded Credential Capture widget is an iframe flow for connecting an end user’s account without sending them away from your product. The widget shows the Blueprints you make available, lets the user choose one, and renders the credential fields required by that Blueprint. Credentials travel directly from the iframe to Rubie. Your frontend receives only lifecycle events, and your backend receives an opaque credential_id after confirming the completed session.

The shape of the flow

Before you start

You’ll need:
  • The keys of the Blueprints you want to show in the widget
  • An HTTPS origin where the iframe will be embedded
  • A backend route that can call Rubie with your API key
Each Blueprint exposed in the widget must have a primary authentication strategy configured in Rubie. That strategy determines the credential form shown after the user selects the Blueprint. Your Rubie contact can configure the display name, logo, description, and sort order used by the picker.
Blueprint keys are safe to use as frontend configuration, but your Rubie API key is not. Create and confirm embed sessions through your backend.

1. Create an embed session

Create a new session when the user opens your connection flow:
blueprint_keys is an explicit allowlist, not a catalog query. The widget never shows other Blueprints from your Rubie account. If you pass one key, Rubie skips the picker and opens that Blueprint’s credential form directly. parent_origin must be an exact HTTPS origin — scheme, host, and port, with no path — allowlisted for your Rubie account. Rubie binds the session to that origin and uses it as the target origin for browser events. Embed sessions expire after 15 minutes. Create them just in time rather than when the surrounding page first loads. An Idempotency-Key replays the same session for 24 hours, even after it expires, so use one per deliberate opening of the widget rather than one permanent key per user.

2. Mount the iframe

Return only id, embed_url, and expires_at from your backend to the browser, then set embed_url as the iframe source:
Use a responsive container and give the iframe at least 640px of width where possible. On smaller screens, let it fill the viewport. The widget handles the Blueprint grid, search, loading states, credential fields, and errors. Avoid adding the sandbox attribute unless you have tested every authentication strategy you expose. OAuth strategies may need forms, redirects, or popups that an iframe sandbox blocks by default. Your Content Security Policy must permit Rubie:
Rubie applies a matching frame-ancestors policy for the session’s parent_origin. A copied embed_url cannot be framed by another origin.

3. Listen for widget events

The widget sends lifecycle events to its parent with window.postMessage:
Every message has this envelope:
Check event.origin, event.source, source, and session_id before acting on a message. A browser event is a notification, not proof of completion. Never accept a credential_id or Blueprint key from the browser.

4. Confirm the session

When the browser receives rubie:credential-capture.completed, ask your backend to fetch the session:
Only persist credential_id when status is completed. Store it with the selected_blueprint_key and the user, workspace, or connection that initiated the session. The selected key is guaranteed to be one of the session’s original blueprint_keys. If the status is still non-terminal, poll every 2 seconds for a short period. This leaves room for Rubie to add credential verification between submission and completion. Stop on completed or expired. Treat status as an open string set. Keep polling on unknown values, and only consider a credential usable after completed.

Closing and reopening

Closing your modal does not invalidate a pending session. You may reopen the same embed_url until it completes or expires. Create a new session after expiry, or when the user explicitly starts a different connection attempt. The cancelled browser event means the user dismissed the widget; it does not change the server-side session status. This keeps accidental closes recoverable.

Reconnecting and revoking

To replace stale credentials, create a new embedded session and swap the stored credential_id only after the new session completes. To disconnect, delete the credential through DELETE /credentials/{id}.

Next