***

title: DetectAction
slug: /reference/python/relay/actions/detect-action
description: Action handle for an active detection operation.
max-toc-depth: 3
---------------------

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

[call-detect]: /docs/server-sdks/reference/python/relay/call/detect

[base-action-interface]: /docs/server-sdks/reference/python/relay/actions

[stop]: /docs/server-sdks/reference/python/relay/actions/detect-action/stop

Returned from [`call.detect()`][call-detect]. Tracks
an active detection operation (answering machine, fax tone, or digit detection).
Terminal states: `finished`, `error`.

<Note>
  Unlike other actions, `DetectAction` also resolves on the first detection result,
  not just on terminal state events. This means `await action.wait()` returns as
  soon as a detection is made.
</Note>

Inherits all properties and methods from the
[base Action interface][base-action-interface] (`control_id`,
`is_done`, `completed`, `result`, `wait()`).

## **Properties**

No additional properties beyond the [base Action interface][base-action-interface].

## **Methods**

<CardGroup cols={2}>
  <Card title="stop" href="/docs/server-sdks/reference/python/relay/actions/detect-action/stop">
    Stop detection immediately.
  </Card>
</CardGroup>

## **Example**

```python
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.detect(
        {"type": "machine", "params": {"initial_timeout": 5.0}}
    )

    event = await action.wait(timeout=10)
    detect_result = event.params.get("detect", {})
    print(f"Detected: {detect_result}")

client.run()
```