> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/realtime-communication/multiple-receivers/python.md). Agents can also search and read this documentation through its [MCP server](https://dnotifier.gitbook.io/product-docs/~gitbook/mcp).

# Python

Send one payload to several recipients with `receiver_ids`.

***

## Basic example

```python
import asyncio
from dnotifier import DNotifier

async def main():
    notifier = DNotifier(
        app_id="your-app-id",
        secret="your-app-secret",
        transport="ws",
        user_id="user-alice",
        on_connected=lambda: None,
        on_message=lambda msg: print(msg.payload.to_json()),
    )

    await notifier.connect()

    await notifier.send(
        sender_id="user-alice",
        receiver_ids=["user-bob", "user-carol", "user-dave"],
        data={"type": "text", "text": "Hello everyone"},
    )

asyncio.run(main())
```

***

## Team notification pattern

```python
TEAM_MEMBER_IDS = ["employee-101", "employee-102", "employee-103"]

await notifier.send(
    sender_id="svc-notifications",
    receiver_ids=TEAM_MEMBER_IDS,
    data={
        "type": "notification",
        "title": "Deploy complete",
        "body": "v2.4.0 is live in production.",
    },
    save_history=False,
)
```

***

## Dynamic member list

```python
async def broadcast_to_room(notifier, room_id: str, payload: dict):
    members = await load_room_members_from_your_db(room_id)
    receiver_ids = [m.user_id for m in members]

    await notifier.send(
        sender_id=current_user_id,
        receiver_ids=receiver_ids,
        data=payload,
    )
```

Your app owns room membership, moderation, and access control.

***

## `send_binary` with multiple receivers

```python
await notifier.send_binary(
    sender_id="user-alice",
    receiver_ids=["user-bob", "user-carol"],
    buffer=bytes([0x00, 0x01, 0x02]),
)
```

***

## Troubleshooting

| Issue                                              | Check                                                 |
| -------------------------------------------------- | ----------------------------------------------------- |
| Only some recipients receive                       | Offline users won't get live delivery                 |
| `ValueError: receiver_id or receiver_ids required` | Pass non-empty `receiver_ids`                         |
| Wrong recipients                                   | Verify member list matches DNotifier `user_id` values |

***

## Learn more

* [Send & receive text](https://dnotifier.gitbook.io/product-docs/realtime-communication/send-and-receive/python.md)
* [Binary messaging](https://dnotifier.gitbook.io/product-docs/realtime-communication/binary-messaging/python.md)
