Moxtra JavaScript SDK

Moxtra's JavaScript SDK is a set of interfaces that enable developers to easily embed the Moxtra modules (Chat, Meet, Clip etc...) into your web application with just few lines of code.

Step 1: Register

After registering your app with Moxtra, you will be provided with a unique client id and client secret key that is used to initialize the Moxtra SDK.

Step 2: Setup

Include the following Moxtra JavaScript file as shown below in your HTML:

<script type="text/javascript" src="https://www.moxtra.com/api/js/moxtra-latest.js" id="moxtrajs" ></script>

Step 3: Authenticate User

Before making any calls with Moxtra SDK, authenticate the user and get the access token:

To authenticate an user using our platform API please make a simple HTTPS POST request to:

  • https://apisandbox.moxtra.com/oauth/token (for sandbox environment)
  • https://api.moxtra.com/oauth/token (for production environment)

POST /oauth/token
Host: https://apisandbox.moxtra.com
Content-Type: application/x-www-form-urlencoded

client_id=INSERT_CLIENT_ID&
client_secret=INSERT_CLIENT_SECRET&
grant_type=http://www.moxtra.com/auth_uniqueid&
uniqueid=INSERT_UNIQUE_USER_IDENTIFIER&
timestamp=TIMESTAMP&
firstname=INSERT_FIRST_NAME&
lastname=INSERT_LAST_NAME

On successful authentication and validating the request, Moxtra will return the access token as a JSON response. It'll look like::

{
    "access_token": "F6YwMQAAATp7lE9TAACowENMLWNsaWVudCAgICAgICAgICAgICAgAAAAAw",
    "token_type": "bearer",
    "expires_in": 43199,
    "scope": "read write"
}

Request Parameters

Name Type Description
client_id String Required: The client ID you received from Moxtra when you registered.
client_secret String Required: The client secret you received from Moxtra when you registered.
grant_type String Required: This should always be set to 'http://www.moxtra.com/auth_uniqueid'.
uniqueid String Requried: unqiue string (Example - email address, username, phone numbers, User ID, UID etc...) from your user management or identity system.
timestamp String Required: UTC timestamp in millseconds. Current UTC time in milliseconds:
firstname String Optional: User's first name
lastname String Optional: User's last name
orgid String Optional: The Moxtra Organization (Org) ID. This parameter is only valid if you are creating separate Org for each of your customer account in Moxtra.
pictureurl String Optional: URL of user's avatar or profile picture
timezone String Optional: This user's timezone based on TZ string in the tz database. For example, America/Los_Angeles, Asia/Shanghai.
plancode String Optional: Plan code or package code assigned by Moxtra for the org. May not be applicable for most of the cases.
language String Optional: This user's language. Default is "en". The supported languages are:
  • da - Danish, dansk
  • de - German, Deutsch
  • en - English
  • es - Spanish, español
  • fi - Finnish, suomi
  • fr - French, français
  • id - Indonesian, Bahasa Indonesia
  • it - Italian, italiano
  • ja - Japanese, 日本語(にほんご)
  • ko - Korean, 한국어, 조선어
  • lt - Lithuanian, lietuvių kalba
  • nb - Norwegian Bokmål, Norsk bokmål
  • nl - Dutch, Nederlands, Vlaams
  • nn - Norwegian Nynorsk, Norsk nynorsk
  • no - Norwegian, Norsk
  • pt - Portugese, português
  • ru - Russian, Русский
  • sv - Swedish, svenska
  • th - Thai, ไทย
  • tr - Turkish, Türkçe
  • vi - Vietnamese, Tiếng Việt
  • zh - Chinese Simplified, 中文简体
  • zh-tw - Chinese Traditional, 中文繁體

Response Parameters

Name Description
access_token Token generated for the user to use with Moxtra API and SDKs.
token_type This always has the value of "bearer".
expires_in Access token expiration time (in seconds)

For more details on this authentication method and for authentication using other methods please refer to the following docs:

Step 4: Initialize SDK Object

Use the Moxtra.init() API to initialize the SDK by adding the global configurations and parameters:

Setting global configurations for the SDK and the parameters to include in Moxtra.init() API request
Name Value Description
mode "production" OR "sandbox" Required: Specify the Moxtra environment to be used by the Moxtra SDK and APIs.
client_id Client ID Required: Replace with the actual Client ID you received from your app registration in Moxtra..
partner_id Partner ID Optional: this parameter is required only if your application is using partner-based SAML SSO.
org_id Org ID Optional: this parameter is required only if your application is using org-based SAML SSO
idp_id Identity Provider Entity Id Optional: this parameter is required only if you are using SAML based SSO.
access_token Access Token Optional: you can optionally set the value of access token. If the value is set here, you can skip passing this as a parameter for each of the SDK.
plugin_version Meet Plugin Version Optional: you can optionally set the version to "latest", which has remote control capability. Default is the stable release version (2.9.5) prior to the latest. Meet plugin is required for audio, video, and screen sharing in the Meet.
sdk_version SDK Version Optional: you can optionally set the version to "3" for version 3.x style UI or "2" for version 2.x style UI.
Moxtra init() callback events handled through a listener
Event Description Attributes
invalid_token Triggered when the access_token is expired. session_id
Sample JS code to initialize Moxtra SDK:
function init() {
    var options = {
        mode: "sandbox", //for production environment change to "production"
        client_id: INSERT_CLIENT_ID,
        access_token: ACCESS_TOKEN, //valid access token from user authentication
        sdk_version: "3",
        invalid_token: function(event) {
            alert("Access Token expired for session id: " + event.session_id);
        }
    };

    Moxtra.init(options);
}

Step 5: Embed Moxtra Modules

You are now ready to make calls and embed the rich and powerful team communication + collaboration layer into your web applications.

Chat Meet Clip Draw Timeline

Remove Embedded Moxtra Module

While using html tag to embed Moxtra module in an iframe on a page, the removeWidget(TAG_ID) API can be used to remove it. This command is not for Meet and Clip as well as Moxtra module in a popup window.

API to remove embedded Moxtra module:

    Moxtra.removeWidget(tagid4iframe);