Two-Factor Authentication REST API

Samples

Samples

The following example are assuming that the request headers mentioned in Authentication, are amended.

Request Code – Simplest Request

{
   "client_ref" : "reference1",
   "phone_number": "35699XXXXXX"
}

 

What it does:
  • Uses reference1 as the client_ref for this request.
  • Generates a numeric code, with a length of 6 digits and case insensitive.
  • Sends the generated code to the destination (35699XXXXXX) using the sender_id found in the token.
  • Response will be received immediately, and no callback will be sent to no URL.

 

Request Code – Most complex request

{
   "client_ref" : "reference1”,
   "phone_number": "35699XXXXXX",
   "code_length": 12,
   "code_type": "alphanumeric",
   "case_sensitive": true,
   "callback_url": "http://www.example.com/callback/endpoint",
   "sender_id" : "Fortytwo",
   "message_template" : "Please enter this code: {#TFA_CODE}"
}

 

What it does:
  • Uses reference1 as the client_ref for this request.
  • Generates an alphanumeric code, with a length of 12 characters and case sensitive.
  • AN HTTP request is sent to the specified callback_url with the SMS delivery details in the JSON body (Section 8).
  • Sends the generated code to the destination(35699XXXXXX) using the “Fortytwo” as a sender_id.
  • Sends the generated code to the destination using a the custom message template: Please enter this code: {#TFA_CODE}.

 

Validate code

http://rest.fortytwo.com/1/2fa/reference1/xxxxxxxx
What it does:
  • Posting to this URL will trigger the validate code endpoint.
  • Initially this checks the code ‘xxxxxxxx’ to see if it was requested using the client_ref ‘reference1’ and the authorization token found in the request header.
  • As this succeeds, it checks whether the code is valid.
Get Started