PlatformIntegrations

Widgets & SDK

Embed Obligo's renter move-in flow in your web app with the JavaScript SDK.

Obligo's JavaScript SDK embeds the move-in widget, Obligo.movein, in your web app. In the widget, the renter confirms their email with a code, reviews their details, qualifies with a bank account, a card or a credit check, picks a deposit option and checks out.

The widget shows an Obligo-hosted page in an iframe, and opens with a renter session token that your server creates through the API. Obligo has no server SDK: on your server, call the REST API directly.

Set up the SDK

Load the script

Load the script for your environment before the closing </body> tag:

<!-- Production -->
<script defer src="https://cdn.obligo.com/libraries/obligoSDK.min.js"></script>

<!-- Sandbox -->
<script defer src="https://cdn.sandbox.myobligo.com/libraries/obligoSDK.min.js"></script>

The script defines a global Obligo object and sets the environment the widget opens in, so use the sandbox script with sandbox session tokens.

Initialize

Call Obligo.init once, before you open the widget. The script loads with defer, so call Obligo.init after the page has loaded, for example in a DOMContentLoaded listener. If your code can run after that event, call Obligo.init directly once Obligo is defined:

function initObligo() {
  Obligo.init({ clientId: 'app_7Hq2mXc9LpR4vT8bN3kW6yZ1aD5fG0sJ' });
}

if (window.Obligo) {
  initObligo();
} else {
  document.addEventListener('DOMContentLoaded', initObligo);
}
  • clientId (string, required) — Your app's client ID. Never pass the client secret.
  • test (boolean, optional) — Whether the widget runs in test mode, which loads no third-party analytics. Set it to true only in automated tests: the browser remembers test mode for later widget sessions.

Allow Obligo in your page

Your Content Security Policy must allow these hosts:

Environmentscript-srcframe-src
Productionhttps://cdn.obligo.comhttps://tenant.obligo.com
Sandboxhttps://cdn.sandbox.myobligo.comhttps://tenant.sandbox.myobligo.com

If your policy restricts style-src, allow 'unsafe-inline' for the widget's loading indicator.

Warning: Call the Obligo API from your server only. The API doesn't accept browser requests from your domain, and your client secret must stay on your server.

Create a renter session

On your server, create a session for the lease's renter with POST /renters/{renterId}/session:

  • leaseId (string, required) — The ID of the lease the renter completes Obligo for.
curl https://api.sandbox.myobligo.com/renters/3fa85f64-5717-4562-b3fc-2c963f66afa6/session \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -H "Obligo-Version: 1.2" \
  -H "Content-Type: application/json" \
  -d '{
    "leaseId": "550e8400-e29b-41d4-a716-446655440000"
  }'
{
  "token": "<renter session token>"
}
  • The token is valid for 14 days, and you can reuse it until it expires.
  • It returns 400 if the lease already has an active product (SessionCreationFailed). Obligo checks this only for leases with available products, such as leases created with API version 1.2.
  • It then moves the lease out of Draft if needed, and creates the renter's invitation, before it checks the renter. So a request rejected for the renter can still move the lease out of Draft.
  • It returns 400 if the renter isn't on the lease (HouseholdCannotBeFoundByRenterId) or isn't the lease's primary renter (RenterIsNotPrimary). Obligo can adjust the primary renter rule for your account.
  • Obligo invites eligible renters automatically, so the renter may also get an invitation email to the hosted renter app.

Open the widget

In the browser, pass the token to Obligo.movein.open:

// Your server endpoint that calls POST /renters/{renterId}/session
const { token } = await fetch('/api/obligo/renter-session', { method: 'POST' }).then((res) => res.json());

Obligo.movein.open(token, {
  targetElement: document.getElementById('obligo-movein'), // omit for a full-screen overlay
  hideCloseButton: false,
  onRenterFlowLoadedSuccessfully() {
    // hide your loading state
  },
  onProgress(prevStep, currStep) {
    console.log(`Renter moved from ${prevStep} to ${currStep}`);
  },
  onComplete() {
    Obligo.movein.close();
  },
  onOptOut(step) {
    // show your own deposit instructions
  },
  onClose(step) {
    // return the renter to your page
  },
  onError(error, step) {
    console.error(error.errorCode, error.message, step);
  },
});

Obligo.movein.open(token, options) takes two parameters:

  • token (string, required) — The renter session token.
  • options (object, optional) — The display properties and callbacks below.

Appearance

Two properties of options control how the widget appears:

  • targetElement (HTMLDivElement, optional) — The element to render the widget in, instead of a full-screen overlay. The SDK replaces the element's content and sizes the widget to the element's height. The widget doesn't resize itself, so give the element a fixed height.
  • hideCloseButton (boolean, optional) — Whether to hide the widget's close button. Defaults to false. Without the button, close the widget with Obligo.movein.close().

Callbacks

CallbackParametersCalled when
onRenterFlowLoadedSuccessfullynoneThe renter's flow has loaded in the widget.
onProgress(prevStep, currStep)The renter reaches a new step. prevStep is null at the start.
onCompletenoneThe renter selects the main button on the success screen. The widget stays open until you call Obligo.movein.close().
onOptOut(step)The renter opted out of Obligo, and Obligo saved the choice.
onClose(step)The widget closed: the renter closed it, the session failed, or you called Obligo.movein.close().
onError({errorCode, error, message}, step)An error occurred. errorCode is SessionError when the token is invalid or expired, or the session ends during the flow, or UnknownError. If the token fails on open, onClose follows. If the session ends during the flow, the widget stays open on an error screen, so call Obligo.movein.close().

step is the renter's current step: introduction, tenantVerification (email code), tenantInformation (personal details), offer (deposit options), checkout or success, in that order. The flow can skip steps, and Obligo.movein.moveinSteps lists the values. Obligo.movein.moveinSteps also lists depositFreeApplication, which the widget never reports.

Note: Callbacks report what the renter does in the widget, so onComplete doesn't mean the renter is approved. Take approvals and opt-outs from the lease.availableProducts.statusChanged and lease.availableProducts.optedOut webhooks, or from GET /leases/{leaseId}.

Next, test the widget end to end in the sandbox.