SDK JS-Client

Introduction

The Case Management JS-Client allows you to call an Inbenta API endpoint quickly and easily with javascript.

Note: All examples shown are set in a Production environment.

Setup

Follow these steps:

Integration

Include the Inbenta Case Management SDK script somewhere in your page:

<script src="https://sdk.inbenta.io/cm/cm-js-client/<version>/cm-js-client.js"></script>
 

Creation

Next, create a new client instance. To do so, you need your API Key (public key) and your domain key. See Finding your API credentials in the Help Center to obtain your credentials.

The following example shows a creation that uses a domain key.

var client = InbentaCMClient({ domain_key: '<your_domain_key>', api_key: '<your_API_Key>' }).build();
 

Use client

client.createTicket({ 
     creator: { 
        address:'<email_address>', 
        extra:[], 
        name:'<name>' 
     }, 
     message:'<message>' 
}).then(function(result){ 
     console.log(result); 
});
 

Example

<!doctype html>
  <  lang="en"> 
    <head> 
      <script src="https://sdk.inbenta.io/cm/cm-js-client/<version>/cm-js-client.js"></script> 
  </head> 
  <body> 
    <script type="text/javascript"> 
      var domain_key = '<your_domain_key>'; 
      var api_key = '<your_API_key>'; 
      var client = InbentaCMClient({ domain_key, api_key }).build(); 

      client.createTicket({ 

        creator: { 
           address:'<email_address>', 
           extra:[], 
           name:'<name>' 
        }, 
        message:'<message>' 

      }).then(function(result) { 
          console.log(result); 
      }); 
    </script> 
  </body>
<html>

Versions

When you set up the SDK for your Inbenta product, you need to specify the version like this:

<script integrity="<hash-type>-<hash>" crossorigin="anonymous" src="https://sdk.inbenta.io/cm/cm-js-client/<version>/cm-js-client.js"></script>
 

Note: A subresource integrity hash table is available for this client here

Versions are written in MAJOR.MINOR.PATCH format.

Important:

  • Do NOT cache or store these files, otherwise you will not benefit from bug fixing and minor upgrades.
  • Inbenta strongly recommends that you use a MAJOR.MINOR.PATCH version.

Examples

  • If only MAJOR is set, this script will use the highest available MINOR version.
    <script integrity="<hash-type>-<hash>" crossorigin="anonymous" src="https://sdk.inbenta.io/cm/cm-js-client/1/cm-js-client.js"></script>
  • If MAJOR.MINOR are set, this script will use the highest available PATCH version.
    <script integrity="<hash-type>-<hash>" crossorigin="anonymous" src="https://sdk.inbenta.io/cm/cm-js-client/1.2/cm-js-client.js"></script>
  • If you specify the full version, only this exact version will be used.
    <script integrity="<hash-type>-<hash>" crossorigin="anonymous" src="https://sdk.inbenta.io/cm/cm-js-client/1.2.3/cm-js-client.js"></script>

Client Creation explanation

To create a new SDK instance, you need your API Key and a domain key. Contact your Inbenta representative to receive these credentials.

Methods

The methods page is available here.

Handling Errors

Click here to see a list of API error codes.

client.createUser(data).catch(function (error) { 

    if (error.response) { 
       // The request was made and the server responded with a status code 
       // that falls out of the range of 2xx 
       console.log(error.response.data); 
       console.log(error.response.status); 
       console.log(error.response.headers); 
    } else { 
       // Something happened in setting up the request that triggered an Error 
       console.log('Error', error.message); 
    } 
});