Wait for SMS verification code (OTP)
wait_for_otpWait for an SMS verification code / OTP to arrive on a Palmyr phone number you own, and return the parsed code. Blocks up to timeout_s (default 60, max 90) checking every ~2s — one call replaces hand-rolled polling of phone_read_messages during account signups and 2FA flows. Messages that arrived up to lookback_s seconds (default 10) BEFORE the call also match, so a code that landed early is not missed — pass lookback_s=0 when reusing a number across signups so a stale code can't be re-served. Default extraction handles standalone 4-8 digit codes, 'code is/code:' tokens, and Google-style G-XXXXXX; pass pattern to override (max 256 chars; a pattern that blows its per-match budget is dropped mid-wait and pattern_timeout: true is reported). Returns { found: true, code, message_text } on a hit or { found: false, waited_s } on timeout (not an error — just call again). Costs 0.02 USDC, paid per-action via x402.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | No | Custom extraction regex overriding the default OTP formats (first capture group wins, else the full match; max 256 chars) | |
| payment | No | base64 x402 payment payload (X-PAYMENT); omit on first call to receive payment instructions | |
| number_id | Yes | Phone number id returned by phone_buy_number | |
| timeout_s | No | Seconds to block waiting (default 60, max 90) | |
| lookback_s | No | Also match messages received up to this many seconds before the call (default 10; use 0 for reused numbers) |