JavaScript

Create a custom verification integration in your web app. Upon positive verification, receive a unique token to send to our REST API for validation.

REST API

Positive verifications result in a unique access token, which you can securely pass to our REST API for validation and identifying information about the User.

Who should use the JavaScript SDK?

Most merchants using ID Services to offer a verified discount don’t need the JS-SDK.

Easier options exist, including customized landing pages or copy/paste code snippets for integrated verification. However, some merchants prefer the custom functionality of a JavaScript Software Development Kit. The JS-SDK allows the merchant to modify what happens before and after verification.

Quick Start

Compatible across all major browsers. JS-SDK authenticates Users with ID Services and returns token sent to REST API for validation.

CDN
<script src="https://cdn.id.services/js-sdk/api.js"></script>
This is the only script you need to integrate the JS-SDK.
HTML
<button type="button" id="myBtn">Open</button>
Basic Example
IDSRV.verify({
  pub_key: "{your public key}",
  initializer: document.getElementById("myBtn"),
  onSuccess: function(token){
    console.log(token); //Send to REST API
  }
});
Documentation

JS-SDK required and optional parameters.

Required Parameters
Parameter Type Description
initializer HTML Object Elements assigned to launch verification. Can be a single element getElementById() or array of elements getElementsByClassName(). Also compatible with jQuery, for example $("#myBtn") or $(".myClass").
onSuccess Function Handles the return of a token, which is returned as a String. In most cases, you'll perform either AJAX or a standard POST request to your app with the token to be validated via IDS REST API.
pub_key String Public key is found in your account page after enrolling in a Plan.
Optional Parameters
Parameter Type Description
forceLogin Boolean After a verification popup is closed, default behavior is to force Users to re-login. Default is true.
message String Overrides default Discount Description (within Store Info). Note: Store Name may not be overridden.
onLoad Function Callback for popup load success. This means your Public Key was accepted and the User reached authentication prompt.
onClose Function Callback for popup closing without a positive verification. Important: this does not mean the User was "rejected". It simply means the User closed the popup prior to completing verification.
REST API

Validate your User access token from the JS-SDK. All responses are in JSON.

Single Endpoint
POST https://api.id.services/user/{token}
Required Parameters
Parameter Type Description
private_key String Private Key is from your account. Private Key must be from the same initiating account Public Key belonged in the JS-SDK.
Response
Tokens reference a unique occasion of a verification. Regardless whether a User has multiple groups, the API will return truthy/falsy based on the token affiliated with the unique verification. Possible groups are mil, edu, fir and tea.
{
    "email": "customer@example.com",
    "first_name": "John",
    "group": "mil",
    "last_name": "Smith",
    "verified": true
}
Response
{
    "error": "Invalid token."
}