Skip to main content

Embedded purchase flow

The embedded flow puts Greenlight's purchase experience inside an iframe in your application, so the renter never leaves your product. The same iframe URL serves Greenlight Deposit or Greenlight Guarantee — the product comes from the prospect (guarantor_coverage), not from a different URL. Greenlight handles the application, underwriting, disclosures, payment, and policy issuance.

You do not construct the iframe URL yourself. Get a prospect into Greenlight — by emitting partner webhook events or through the Partner Prospect API — and Greenlight produces the enrollment_url you load in the iframe. It reaches you on the prospect.ready webhook, or in an API response if you are polling.

How it works​

  1. Your backend creates a prospect and receives an enrollment_url.
  2. The renter chooses Greenlight in your product.
  3. Your page loads the enrollment_url in an iframe.
  4. The renter completes the application and pays, inside the iframe.
  5. The confirmation screen loads and the iframe posts success_shown to your page. When the renter clicks its closing button, the iframe posts completed.
  6. Greenlight issues the policy and sends your backend a policy.created webhook.

The postMessage events in step 5 tell your UI what to do next. The webhook in step 6 is the authoritative record. Do not treat a postMessage as proof a policy exists: completed is sent only if the renter clicks through, the browser can close before either event is sent, and neither message carries verifiable data. Steps 5 and 6 can arrive in either order.

For the screens the renter sees in step 4, the enrollment URL's structure, and the query parameters it accepts, see Enrollment URLs & flows.

Embedding​

<iframe
id="enrollment-iframe"
src="https://www.greenlightrent.com/enrollment/embedded/acme-properties/acme/prospect-123?email=renter%40example.com"
width="100%"
height="800"
frameborder="0"
allow="payment"
sandbox="allow-scripts allow-same-origin allow-forms">
</iframe>

allow="payment" is required. Greenlight's checkout uses Stripe, which runs its own nested iframe and needs access to the Payment Request API. Without this attribute the renter reaches checkout and cannot pay.

If you sandbox the iframe, these three flags are the minimum and each one breaks something specific if omitted:

FlagNeeded for
allow-scriptsThe flow itself, and postMessage
allow-same-originSession cookies. Without it the renter is logged out between steps.
allow-formsForm submission during application and checkout

Do not add further sandbox flags without checking with Greenlight first. If you are not already sandboxing iframes, omitting the attribute entirely is fine.

Allowlisting​

Greenlight must allowlist your domains before the iframe will render or send events. One setting is configured per property owner during onboarding:

  • embedded_frame_ancestors — the origins permitted to frame the flow and receive postMessage events. Greenlight sends Content-Security-Policy: frame-ancestors 'self' <your origins> and strips X-Frame-Options on embedded routes.

Send your Partner Success Manager every staging and production parent origin, or set them yourself with embedded_frame_ancestors on a property owner you provision through the Onboarding API. Greenlight resolves the actual parent and sends events only when it exactly matches an entry or is covered by a configured subdomain wildcard. A wildcard such as https://*.example.com covers https://staging.example.com and https://a.b.example.com, but not https://example.com. A port is part of the origin, so https://app.example.com:8443 needs its own entry.

Give each entry as a bare origin — scheme included, no trailing slash and no path:

https://app.example.com correct
https://app.example.com/ wrong
https://app.example.com/enroll wrong

Tell Greenlight before your origins change. A renter hitting a stale allowlist gets a blank frame with only a console error to explain it.

The flow keeps its session in cookies set as SameSite=None; Secure; Partitioned. Browsers that partition third-party cookies (CHIPS) accept these in a frame, so the flow works with default third-party cookie blocking in current Chrome, Edge, and Firefox. A browser or extension that blocks all third-party cookies outright, including partitioned ones, logs the renter out between steps.

Window events​

Each terminal screen in the embedded flow has a closing button. When the renter clicks it, Greenlight resolves the actual parent origin, confirms that it is HTTPS and allowlisted, and calls window.parent.postMessage(event, parentOrigin). The confirmation screen also sends success_shown the same way as soon as it loads, without a click. No other screen sends anything on load, so a renter who closes the tab on a decline or error screen produces no event. If the parent cannot be resolved or is not allowlisted, no event is sent.

The message payload is a plain string, not an object. There is no event.data.event property, no policy ID, and no timestamp.

EventMeaning
success_shownThe confirmation screen loaded, so the renter is finished. Sent on load, before completed, and again every time the confirmation screen is shown: on a reload, or when a renter who already finished, or who already has coverage at the property, opens the enrollment URL again. It is a signal to update the UI around the frame, not to close it, because the renter is still reading the confirmation screen.
completedThe renter paid and their application was submitted. The policy or cash deposit is issued right after, and policy.created confirms it.
declinedUnderwriting declined the application. Treat it as final — do not send the renter back in. One variant of the decline screen tells the renter their screening is still pending, and it sends declined too.
blockedThe flow cannot continue: an error the renter cannot fix, or the property is not live on the embedded flow. Ineligible prospects never reach the flow, because they have no enrollment_url.
window.addEventListener('message', (event) => {
if (event.origin !== 'https://www.greenlightrent.com') {
return;
}

switch (event.data) {
case 'success_shown':
markEnrollmentFinished();
break;
case 'completed':
showSuccessState();
break;
case 'declined':
showDeclinedState();
break;
case 'blocked':
showFallbackDepositOptions();
break;
default:
break;
}
});

Act on the event name, never on the arrival of a message alone. success_shown arrives while the renter is still on the confirmation screen, so a listener that closes the frame on any message closes it before the renter can read it.

Keep the default case. Greenlight's emitter also recognizes opt_out, which no screen currently sends but which may start appearing without notice. Ignore values you do not recognize rather than throwing.

Every event is fire-and-forget. Greenlight expects no acknowledgement and does not retry, and the iframe does not close or navigate itself — moving the renter on is your job.

Because completed waits on a click and success_shown waits on the confirmation screen loading in an open browser, either can arrive before or after the policy is issued, or not at all. Always validate the outcome against the policy.created webhook or a GET on the prospect before granting anything of value.

Security​

Validate the origin​

Always compare event.origin against an explicit allowlist. Any page can post a message to your window.

const allowedOrigins = [
'https://www.greenlightrent.com',
'https://stage.greenlightrent.com',
];

if (!allowedOrigins.includes(event.origin)) {
return;
}

Content Security Policy​

If your app sets a CSP, permit the Greenlight frame:

Content-Security-Policy: frame-src https://www.greenlightrent.com https://stage.greenlightrent.com;

Layout​

The flow is responsive, but an iframe cannot resize itself to its content. Give it enough height to avoid a nested scrollbar on the longest step:

#enrollment-iframe {
width: 100%;
min-height: 800px;
border: 0;
}

@media (max-width: 768px) {
#enrollment-iframe {
min-height: 1000px;
}
}

Branding​

You can set the colors, fonts and logo the embedded flow shows your renters. Branding applies to every prospect you send, and to the embedded flow only.

GET /partners/providers/{provider}/branding
PATCH /partners/providers/{provider}/branding
DELETE /partners/providers/{provider}/branding

PATCH changes only the fields you send. Send any other field as null to remove it. brand_color and brand_text_color only work as a pair: send either one as null, without a value for the other, to clear both. Changes are live as soon as the request succeeds.

{
"brand_color": "#1d4ed8",
"brand_text_color": "#ffffff",
"primary_text_color": "#1c1a2b",
"secondary_text_color": "#5e5b70",
"link_color": "#1d4ed8",
"header_font_family": "Urbanist",
"body_font_family": "Urbanist",
"logo": "<base64-encoded PNG, JPEG or SVG>"
}
FieldRules
brand_color#rrggbb. Button backgrounds, plus focus outlines and selected controls. At least 3:1 contrast against white. HSL lightness between 15% and 90%, so the hover and pressed shades stay visible. Set together with brand_text_color; once both are set, you can change either one alone.
brand_text_color#rrggbb. Text and icons on buttons. At least 4.5:1 contrast with brand_color.
primary_text_color#rrggbb. Headings, labels and amounts. At least 4.5:1 contrast against white.
secondary_text_color#rrggbb. Body text, notes and the agreement text. At least 4.5:1 contrast against white.
link_color#rrggbb. Text links. At least 4.5:1 contrast against white.
header_font_familyThe font for headings and buttons. One of the supported fonts, spelled as listed.
body_font_familyThe font for all other text, including the card field. One of the supported fonts, spelled as listed.
logoBase64-encoded PNG, JPEG or SVG, 1 MB or smaller once decoded. Greenlight renders an SVG to a PNG of up to 960×192 and stores that, so logo_url returns a PNG. An SVG needs a viewBox and can't contain scripts, event handlers (on* attributes), <foreignObject>, animation (<set>, <animate>), declarations inside a DOCTYPE, or references to anything outside the file: every href must point to a # id in the same file, and CSS can't @import, use an external url(), or contain a backslash. A plain DOCTYPE line, as design tools export, is fine.

Every request returns the live branding:

{
"status_code": 200,
"branding": {
"brand_color": "#1d4ed8",
"brand_text_color": "#ffffff",
"primary_text_color": "#1c1a2b",
"secondary_text_color": "#5e5b70",
"link_color": "#1d4ed8",
"header_font_family": "Urbanist",
"body_font_family": "Urbanist",
"logo_url": "https://..."
}
}

A request that breaks a rule returns 422 and changes nothing:

{
"status_code": 422,
"error": {
"code": "validation_failed",
"message": "Branding wasn't saved. See details for each field.",
"details": [
{
"field": "brand_text_color",
"code": "low_text_contrast",
"message": "doesn't contrast enough with brand_color for button text to be readable. Choose a color with at least 4.5:1 contrast"
}
]
},
"request_id": "6f1c2b9e-7d4a-4c1e-9a55-0b8f3d2e1a77"
}

Besides a missing or malformed color, each detail's code names the rule that was broken:

FieldCodes
brand_colorlightness_out_of_range, low_page_contrast
brand_text_colorlow_text_contrast
logotoo_large, unsupported_type, not_base64, unsafe_svg, unreadable_svg

A body that is not a JSON object returns 422 with a single detail coded not_an_object and a null field.

A {provider} that is not your own returns 403 with the code forbidden. If Greenlight hasn't set up branding for your account, these routes return 404. Ask your Partner Success Manager.

Each color besides the brand_color and brand_text_color pair is optional; an unset color keeps Greenlight's. Greenlight derives the hover and pressed shades of your buttons from brand_color. Everything else, including backgrounds, borders, status colors (success, warning, error) and highlight banners, keeps Greenlight's fixed values.

Each font is optional, and you can set either one with or without colors; an unset font keeps Greenlight's. Logos are images and don't change. Greenlight loads the fonts from Google Fonts and falls back to Arial if one can't load.

DELETE clears every color, both fonts and the logo, and the flow returns to its default branding.

Supported fonts​

Greenlight reviews each font in the embedded flow before supporting it, since wide fonts can cut off button text. These Google Fonts families are supported:

To use another Google Fonts family, ask your Partner Success Manager.

Testing​

Use the staging environment at https://stage.greenlightrent.com. Staging enrollment routes skip the HTTP basic auth that guards the rest of the staging site, so the iframe loads without credentials.

Worth exercising before launch:

  1. A prospect that reaches ready and completes a purchase
  2. A prospect that stays incomplete because of a missing field
  3. A declined application
  4. A renter who abandons mid-flow and returns to the same URL
  5. Mobile viewport rendering

Troubleshooting​

The iframe renders blank or is refused

  • Confirm your domain is in embedded_frame_ancestors for the property owner
  • Check the browser console for a frame-ancestors CSP violation
  • Confirm the browser is not blocking partitioned third-party cookies

400, 403, or 404 when the frame loads

  • A 400 means the email query parameter is missing. A 403 means it does not match the prospect's email (comparison is case- and whitespace-insensitive), or the property is not live on the embedded flow yet
  • A 404 means the source and source_prospect_id in the path do not match an active prospect for that property owner, or the renter is signed in to an account the prospect's authorized members list does not name
  • See When the URL does not load

No postMessage events

  • Confirm the actual parent origin is listed in embedded_frame_ancestors or covered by a configured wildcard
  • Confirm its HTTPS scheme and port match the allowlist entry
  • Confirm you are reading event.data as a string rather than event.data.event
  • completed, declined, and blocked are sent only when the renter clicks the closing button on a terminal screen. The only event sent on load is success_shown, from the confirmation screen

The renter is logged out between steps, or a form will not submit

  • You are sandboxing the iframe without allow-same-origin (session) or allow-forms (submission)

The renter reaches checkout but cannot pay

  • The allow="payment" attribute is missing, so Stripe's nested frame cannot reach the Payment Request API

Next steps​