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
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 onlyid, embed_url, and expires_at from your backend to the browser,
then set embed_url as the iframe source:
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:
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 withwindow.postMessage:
4. Confirm the session
When the browser receivesrubie:credential-capture.completed, ask your backend
to fetch the session:
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 sameembed_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 storedcredential_id only after the new session completes. To disconnect, delete the
credential through DELETE /credentials/{id}.
Next
- Hosted credential collection — use a redirect or direct strategy instead of a Blueprint picker
- Blueprints — how Blueprints relate to strategies and runs
- Triggering Blueprint runs — use the captured credential
- Idempotency — choose safe retry keys for session creation