> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # wait > Await until the message reaches a terminal state. [relayevent]: /docs/server-sdks/reference/typescript/relay/events Await until the message reaches a terminal state (`delivered`, `undelivered`, or `failed`). Returns the terminal [`RelayEvent`][relayevent]. > **Warning** > > Throws an `Error` if `timeout` is specified and the message does not > reach a terminal state within the given duration. ## **Parameters** **`timeout`** `number | undefined` Maximum seconds to wait (matches Python SDK convention). `undefined` waits indefinitely. --- ## **Returns** `Promise<`[`RelayEvent`][relayevent]`>` -- The event that caused the message to reach its terminal state. Inspect `message.state` for the final state value. ## **Example** ```typescript {18} import { RelayClient } from '@signalwire/sdk'; const client = new RelayClient({ project: process.env.SIGNALWIRE_PROJECT_ID!, token: process.env.SIGNALWIRE_API_TOKEN!, contexts: ['default'] }); await client.connect(); const message = await client.sendMessage({ toNumber: '+15551234567', fromNumber: '+15559876543', body: 'Your verification code is 123456', }); try { const event = await message.wait(30); if (message.state === 'delivered') { console.log('Message delivered successfully'); } else { console.log(`Message failed: ${message.reason}`); } } catch (err) { console.log('Timed out waiting for delivery confirmation'); } await client.disconnect(); ``` > Await until the message reaches a terminal state.