Initialization

OnSched.js is initialized by passing your clientId and environment to the OnSched function. OnSched.js will then connect to the API and return an access token to be used by the elements.

After initialization, get instance of elements to use for creating all OnSched.js elements. See the elements tab for more information.

/// Initialize OnSched.js
/// Param 1 - Your API ClientId.
/// Param 2 - "sbox" for sandbox testing
///           "live" for production
///
///  NOTE - you must register your domain for authorization. see Overview for more details.
///

const onschedOptions = {};
const onsched = OnSched("<<clientId>>", "sbox", onschedOptions);

/// Get instance of elements to use for creating elements
const elements = onsched.elements();

Initializing from a Mobile App

When initializing OnSched.js from an IOS or Android application without a WebView the element will need to be loaded without any Domain Validation (explained in the Overview tab). In order to circumvent the domain validation requirement you must gather a token to include in the onschedOptions object as a value for the property token.

Request URL: https://sandbox-js.onsched.com/auth/mobile

Request Body:

{
  // Required
  "client_id":             "DemoUser",
    
  // Optional
  "id":                    "{id}",
  "name":                  "{name}",
  "given_name":            "{given_name}",
  "family_name":           "{family_name}",
  "middle_name":           "{middle_name}",
  "nickname":              "{nickname}",
  "preferred_username":    "{preferred_username}",
  "profile":               "{profile}",
  "picture":               "{picture}",
  "website":               "{website}",
  "email":                 "{email}",
  "email_verified":        "{email_verified}",
  "gender":                "{gender}",
  "birthdate":             "{birthdate}",
  "zoneinfo":              "{zoneinfo}",
  "locale":                "{locale}",
  "phone_number":          "{phone_number}",
  "phone_number_verified": "{phone_number_verified}",
  "address":               "{address}"
}

What’s Next