Receive an SMS
When someone texts one of your Dial numbers, Dial emits a message.received event. The most common use is catching a one-time code: an agent triggers an SMS verification on some service, then waits for the code to arrive on its Dial number.
You don’t poll for messages — you wait for the event. There are two ways to wait.
For a one-time code, an active wait (below) is the right tool. But note the underlying event stream is presence-based, not at-least-once — a long-lived listener replays missed events only if it reconnects within 2 minutes. For guaranteed delivery, register an at-least-once webhook.
Wait once
Block until the next inbound message arrives (or a timeout elapses). Ideal for a single code.
The CLI and REST events/wait return as soon as a matching event arrives. If nothing arrives within the timeout, the REST endpoint responds 408; the CLI exits non-zero.
Filter to a specific number
If you have several numbers, match on event fields so you only wake for the right one:
Use --field name=value for exact matches or --regex name=pattern for patterns (both repeatable).
Extract the code
An inbound message.received event carries the message text at data.body. Pull the code out with a regex in your agent — for example, the first 6-digit run:
Receive media (MMS)
When an inbound message carries media (pictures, etc.), the event’s data.media array lists each attachment with a stable, unauthenticated url hosted by Dial — fetch or render it directly, no API key needed. contentType gives the MIME type and originalUrl preserves the carrier’s source URL. Plain SMS events have an empty media array.
Media is also returned on GET /api/v1/messages (each message’s media array), so you can recover attachments after the fact without having caught the event.