How to Test an OTP API Using Postman

Let’s understand the testing process with a simple example.

Assume an application has two endpoints:

1. Generate OTP

POST /api/otp/generate

Sample request:

{
  "mobileNumber": "9999999999"
}

Possible successful response:

{
  "message": "OTP request processed successfully",
  "requestId": "OTP-TEST-101"
}

2. Verify OTP

POST /api/otp/verify

Sample request:

{
  "requestId": "OTP-TEST-101",
  "otp": "482615"
}

Possible successful response:

{
  "verified": true,
  "message": "OTP verified successfully"
}

These endpoints, fields, and responses are illustrative examples. Your actual API may use a different structure.

Step 1: Test the OTP Generation API

Open Postman and create a new request.

Check the following:

Do not assume that receiving HTTP 200 always means an OTP was successfully delivered. Check the API contract and delivery status where available.

Step 2: Test the OTP Verification API

Copy the request ID or other required reference returned by the generation API.

Enter the valid OTP using the test environment’s approved OTP retrieval method, then send the verification request.

Validate the following:

For security reasons, do not assume that an OTP will be returned in the API response. Production systems should not expose it unnecessarily.

Step 3: Test an Invalid OTP

Send an incorrect OTP to the verification endpoint.

Example request:

{
  "requestId": "OTP-TEST-101",
  "otp": "111111"
}

Expected behavior:

The exact status code and error message should follow the API specification.

Pages: 1 2 3 4 5 6 7 8 9

Leave a Reply

Your email address will not be published. Required fields are marked *