# How to access the verification code sent on email in SoapUI

Add Humanless as two extra REST test steps in your SoapUI test case. First, a POST to `https://api.usehumanless.com/v1/identities` with the body `{"channels":["email"]}` returns an `email` and an `identity_id`; transfer both into properties. Use the email in the request that triggers the verification email. Then a Groovy Script step calls `/v1/identities/{id}/wait`, which blocks until the email arrives and returns the parsed code in `code`; the script retries on 408 (nothing arrived yet) and stores the code as `${#TestCase#otp}` for the next request. Send `Authorization: Bearer <key>` on each call and keep socket timeouts above the wait time.

```groovy Groovy Script step: wait for code
import groovy.json.JsonSlurper

// A Groovy step just before the request that sends the email should run:
//   testRunner.testCase.setPropertyValue('since', System.currentTimeMillis() as String)
def id = context.expand('${#TestCase#identity_id}')
def since = context.expand('${#TestCase#since}')
def deadline = System.currentTimeMillis() + 120_000
def msg = null
while (msg == null && System.currentTimeMillis() < deadline) {
    def conn = new URL("https://api.usehumanless.com/v1/identities/${id}/wait?channel=email&timeout=30&since=${since}").openConnection()
    conn.setRequestProperty('Authorization', "Bearer ${System.getenv('HUMANLESS_API_KEY')}")
    conn.readTimeout = 45_000
    if (conn.responseCode == 200) msg = new JsonSlurper().parse(conn.inputStream)
    else if (conn.responseCode != 408) throw new Exception("wait failed: HTTP ${conn.responseCode}")  // 408: nothing yet
}
assert msg?.code : 'No verification code arrived'
testRunner.testCase.setPropertyValue('otp', msg.code)   // use ${#TestCase#otp} in the next request
```

## Other options

- **A Groovy script step** that reads the mailbox over IMAP with JavaMail, which ships with many SoapUI setups.
- **Query the test database** for the code in a JDBC step, if the test isn't about email delivery.
- **Mailpit** as the SMTP server of the system under test, read with a REST step.

> **Use policy:** Only for apps you own or are authorized to test. See the [Terms](/terms).

More: [Humanless REST API reference](/docs/api) · [All answers](/answers/)

Last updated 2026-12-04

Canonical: https://usehumanless.com/answers/how-to-access-the-verification-code-sent-on-email-in-soap-ui

---
More: https://usehumanless.com/llms.txt
