Core Concepts

Signals

When the API needs to communicate with your codebase, it will do so by providing a signal in the current Session object. If necessary, an accompanying signal_data array will be provided containing data relevant to the signal.


Log-in signal

The current session does not contain an authenticated user. This signal should trigger a route to your log-in page. See the logging in workflow for additional information.

// session object
{
  "signal": "login",
  ...
}

Signal data

None.


Select account signal

The user has been identified as being a member of multiple accounts. This signal should trigger a route to your select account page. See the logging in workflow for additional information.

// session object
{
  "signal": "select_account",
  ...
}

Signal data

The signal_data.accounts is an array of accounts to select from. The array keys are the account IDs and the values are the account titles. The signal_data.last_login value is the account ID the user last selected.

// session object
{
  "signal": "select_account",
  "signal_data": {
    "account": {
      "acc_1234567890": "Foo Account",
      "acc_2345678901": "Bar Account",
      ...
    },
    "last_login": "acc_1234567890"
  },
  ...
}

Example code to create dynamic HTML select options.

// using session.signal_data for creating select options
// when session.signal === 'select_account'
    
<select id="account_id"></select>

<script>

  const e = document.getElementById("account_id");
  
  for (const id in signal_data.accounts) {
    const option = document.createElement("option");
    option.value = id;
    option.textContent = signal_data.accounts[id];
    option.selected = (signal_data.last_login === id)
    e.appendChild(option);
  }
</script>
Previous
Monetization