***

title: wait_for_ended
slug: /reference/python/relay/call/wait-for-ended
description: Wait for a call to reach the ended state.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[relayevent]: /docs/server-sdks/reference/python/relay/events

Wait for the call to reach the `ended` state. This is a convenience method
equivalent to waiting for a `calling.call.state` event with `call_state == "ended"`.

## **Parameters**

<ParamField path="timeout" type="Optional[float]" toc={true}>
  Maximum seconds to wait. Raises `asyncio.TimeoutError` if exceeded. `None`
  waits indefinitely.
</ParamField>

## **Returns**

[`RelayEvent`][relayevent] -- The state-change event indicating the call has ended.

## **Example**

```python {18}
from signalwire.relay import RelayClient

client = RelayClient(
    project="your-project-id",
    token="your-api-token",
    host="your-space.signalwire.com",
    contexts=["default"],
)

@client.on_call
async def handle_call(call):
    await call.answer()

    action = await call.play([{"type": "tts", "text": "Goodbye!"}])
    await action.wait()
    await call.hangup()

    event = await call.wait_for_ended()
    print(f"Call {call.call_id} has ended: {event.params}")

client.run()
```