Unlock the Full Potential of SMS 2FA Authentication Developer API

Your Go-To Guide for Integrating Robust 2FA Integration into Your Applications. Welcome to the MyOTPApp! This API allows you to generate and verify One-Time Passwords (OTPs) using SMS for user two-factor authentication.
Secure SMS API

Before You Get Started

  • To start using the  SMS Multi-Factor Authentication API, you’ll need an API key from your  Dashboard
  • This key should be included in the header of each request as  X-API-Key
  • Contact our support team at  support@myotp.app  if you have any questions

API Endpoints

Our API consists of two primary endpoints to send and verify an OTPs, as well as a number of other supporting endpoints for reporting and other advanced features:

  1. /generate_otp
  2. /verify_otp
  3. /extend_otp:
  4. /check_otp
  5. /report

1. Generate OTP (POST /generate_otp)

This endpoint generates an OTP and sends it to a specified phone number.

phone_number: The mobile number to send the OTP to. Include country code with no prefix. (Required)

otp_length: The length of the Code. Must be between 3 and 8. (Default: 6)

otp_validity: The validity period for the OTP in seconds. Must be between 30 and 14400. (Default: 300)

template_order: The message template to use. Must be a valid number. (Default: 1)

force_send: Force send an OTP to a number with a valid OTP outstanding. (Default: False)

return_otp: Return the OTP value in the response. This is NOT compliant with regulations in many markets. (Default: False)

brand: Force a different brand name manually. This overrides account brand. (Default: From Account)

Response

A successful request will return a JSON object with the following fields:

				
					{
  "message_id": "The ID of the sent message",
  "status": "The status of the request",
  "message": "A message describing the status or error of the request",
  "date_sent": "The UTC timestamp when the OTP was sent",
  "expires_at": "The UTC timestamp when the OTP expires",
  "cost": "The cost of delivering this OTP of this mobile number",
  "otp": "string"
}
				
			

2. Verify OTP (POST /verify_otp)

This endpoint verifies a provided OTP if it matches the generated and sent one.

Request Parameters

message_id: The ID of the message to verify. (Recommended)

otp: The code to verify. Must be between 3 and 8 digits. (Required)

phone_number: The mobile number you sent an OTP to.  Allowed if message_id is not included. (Optional)
Response

A successful request will return a JSON object with the following fields:

				
					{
  "status": "The status of the code verification",
  "reason": "A message describing the reason of a failed status. Ommitted on success."
  "message": "A message describing the status of the verification process"
}
				
			

3. Extend OTP (POST /extend_otp)

This endpoint extends the expiry time of an existing OTP.

Request Parameters

message_id: The ID of the message to extend. (Required)

duration: The number of seconds to extend the existing OTP validity. Same as otp_validity. (Required)

Response

A successful request will return a JSON object with the following fields:

				
					{
  "status": "The status of the request",
  "message": "A message describing the status or error of the request",
  "expires_at": "The new UTC timestamp when the OTP expires"
}
				
			

4. Check Message Status (POST /check_otp)

This endpoint checks delivery report and if a sent OTP is still active or expired.

Request Parameters

message_id: The ID of the message to check. (Required)

Response

A successful request will return a JSON object with the following fields:

				
					{
  "DLR": "The delivery report from the carrier or OTT provider",
  "is_valid": "Whether the OTP is still active or not"
  "expires_at": "The UTC timestamp when the OTP expires"
}
				
			

5. Get Transactions Report (POST /report)

This endpoint checks delivery report and if a sent OTP is still active or expired.

Request Parameters

start_date: The start date of the report in YYY-MM-DD format. (Default: 7 days ago)

end_date: The end date of the report in YYY-MM-DD format. (Default: today)

page: The page number to fetch. Minimum 1. (Default: 1)

per_page: The number of items per page to fetch. Must be between 1 and 100. (Default: 10)

Response

A successful request will return a JSON object with the following fields:

				
					{
  "transactions": [
    {
      "message_id": "The ID of the message",
      "phone_number": "The mobile phone number",
      "cost": 0,
      "timestamp": "UTC timestamp",
      "message_type": 0,
      "description": "The description of this request",
      "force_send": false,
      "client_ip": "The IP address of the client which made this request",
      "application": "The name of the application this API key is assigned to",
      "created_at": "UTC timestamp"
    }
  ]
}
				
			

Error Handling

Our API uses standard HTTP status codes to indicate the success or failure of a request. Here are some of the most common codes you might encounter:
  • 200: Success. The request was successful.
  • 400: Bad request. The request could not be understood or was missing required parameters.
  • 401: Unauthorized. Authentication failed or user does not have permissions for the requested operation.
  • 402: Payment Required. User balance is insufficient.
  • 404: Not Found. No OTP record or message_id was not found.
  • 409: Conflict. OTP already active for the same phone number.
  • 500: Internal Server Error. An error occurred on the server

Take the API for a Spin!

To make it easier for you to get started, we’ve provided a Swagger-UI with OpenAPI specs of our API.

This interactive tool allows you to try out our API endpoints directly from your web browser. You can enter your API key, fill in the request parameters, and see the API responses in real time.

Want to test the API right now?  Go to Swagger-UI

We hope you find our API easy to use and adds value to your business. Happy coding!

Additional Resources for Smooth Sailing

If you have any questions or run into any issues, please contact our support team at support@myotp.app.

We’re here to help!