MTCaptcha Quick Start

You will need to have a registered account (Free Trial available) and your <SiteKey> to use MTCaptcha on your own website.

The best place to start and find out how to embed MTCaptcha captcha JavaScript plugin in to your website is to use our MTCaptcha Code Builder.  

code-gen-snippet.png

OR

Step 1. Embed JavaScript Code Snippet

You can copy the javascript code snippet below in to your HTML page.  Please make sure to replace the <SiteKey> with your sitekey from the Admin Portal.

<html>
<head>
    <!-- MTCaptcha javascript configuration and import, copy start -->
    <script>
    var mtcaptchaConfig = {
      "sitekey": "<SiteKey>"
    };
   (function(){var mt_service = document.createElement('script');
   mt_service.async = true;mt_service.src
   = 'https://service.mtcaptcha.com/mtcv1/client/mtcaptcha.min.js';
   (document.getElementsByTagName('head')[0] 
   || document.getElementsByTagName('body')[0]).appendChild(mt_service);
   var mt_service2 = document.createElement('script');
   mt_service2.async = true;mt_service2.src 
   = 'https://service2.mtcaptcha.com/mtcv1/client/mtcaptcha2.min.js';
   (document.getElementsByTagName('head')[0] 
   || document.getElementsByTagName('body')[0])
   .appendChild(mt_service2);}) ();
   </script>
  <!-- MTCaptcha javascript configuration and import, copy end -->
</head>
<body>    
    <form ... >
    <!-- MTCaptcha Anchor DOM, copy start -->
    <div class="mtcaptcha"></div>
    <!-- MTCaptcha Anchor DOM, copy end -->
    </form>  
</body>
</html>

Step 2. Check Validated Token on Server Side With an API Call

On successful captcha verification, a mtcaptcha vierrfied token (string) will be created and inserted into the HTML form as a hidden input

  <input type=’hidden’ name=’mtcaptcha-verifiedtoken’  value=’<token>’  />

The value of this ‘mtcaptcha-verifiedtoken’ form must be checked on the server side via an HTTP(S) API call.

HTTP(S) API:

https://service.mtcaptcha.com/mtcv1/api/checktoken?
privatekey=<privatekey>&token=<token>

HTTP Method:

 GET

Parameters

  • <privatekey>   : The PrivateKey secret  (Required).
  •                               This is the secrete, and can be obtained in the MTCaptcha Admin Portal.
  • <token>           : The verified token string.  (Required).
  •                              This is the value of the mtcaptcha-verifiedtoken input

Sample API Success Response (JSON):

  {
    "success": true,
    "tokeninfo": {
      "v": "1.0",
      "code": 201,
      "codeDesc": "valid:captcha-solved",
      "tokID": "ae1e60a1e249c217cb7b05c4dba8dd0d",
      "timestampSec": 1552185983,
      "timestampISO": "2019-03-10T02:46:23Z",
      "hostname": "some.example.com",
      "isDevHost": false,
      "action": "",
      "ip": "10.10.10.10"
    }
  }

Sample API Failure Response (JSON):

{
  "success": false,
  "fail_codes": [
    "token-expired"
  ],
  "tokeninfo": {
    "v": "1.0",
    "code": 201,
    "codeDesc": "valid:captcha-solved",
    "tokID": "25eff0c56a227781408a95a053c36b65",
    "timestampSec": 1552185729,
    "timestampISO": "2019-03-10T02:42:09Z",
    "hostname": "some.example.com",
    "isDevHost": false,
    "action": "",
    "ip": "10.10.10.10"
  }
}