To receive the OTP, you need to call a second endpoint.
The get-number API only gives you a virtual phone number along with a request_id.
After that, you need to poll the get-sms API using that request_id until it returns sms_code (that value is your OTP).
You can refer to the official SMS‑MAN API documentation here:
So in simple terms, you need to follow these 3 steps:
Call get-number using WS.sendRequest()
You have already completed this step. what i see
Parse the response JSON and extract request_id
This request_id is required to fetch the OTP.
Use a loop with a small delay and call get-sms
Keep calling get-sms with the same request_id until the response contains sms_code.
Once sms_code appears, that is the OTP you’re looking for.
The get-number endpoint only gives you the virtual phone number. You still need to trigger the OTP in your application using that number, then poll the get-sms endpoint with the request_id until the sms_code field is populated.
def json = new groovy.json.JsonSlurper().parseText(response.getResponseText())
int requestId = json.request_id
// Poll for SMS (adjust iterations/delay as needed)
for (int i = 0; i < 30; i++) {
def smsResp = WS.sendRequest(findTestObject('GET_SMS', ['request_id': requestId, 'token': token]))
def smsJson = new groovy.json.JsonSlurper().parseText(smsResp.getResponseText())
if (smsJson.sms_code) {
println "OTP: ${smsJson.sms_code}"
break
}
WebUI.delay(2)
}
Make sure you actually submit the phone number to your app’s login or registration flow before you start polling, otherwise no SMS will arrive. The get-sms endpoint documentation is at sms-man.com/api.