Sending events to a member
Send personal events, such as order updates, shared-document notifications, or balance changes, directly to a member. You do not need to create a channel for each person.
This guide explains how to receive member events, send them from your server, and choose between member events and private channels.
Before you start
The connection must be signed in with a member identity. See Requiring authorized connections for signin() and its authorization endpoint.
Receive events in your app
After signin() succeeds, bind the event name on bird.member. Use the same name that your server sends as event. Member events require no channel subscription.
import { BirdRealtime } from "@messagebird/realtime";
const bird = new BirdRealtime({
appKey: "your-app-key",
region: "us1",
memberAuthEndpoint: "/bird/auth/member",
});
await bird.signin();
bird.member.bind("order.shipped", (data) => {
showToast(`Order ${data.order_id} is on its way`);
});import BirdRealtime
let bird = BirdRealtime(options: .init(
appKey: "your-app-key",
region: "us1",
memberAuthEndpoint: URL(string: "https://your-backend.example.com/bird/auth/member")
))
let me = try await bird.signin()
print("signed in as", me.memberId)
bird.member.bind("order.shipped") { data in
let orderId = (data as? [String: Any])?["order_id"] as? String ?? ""
showToast("Order \(orderId) is on its way")
}import com.bird.realtime.BirdRealtime
import com.bird.realtime.BirdRealtimeOptions
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
val bird = BirdRealtime(
BirdRealtimeOptions(
appKey = "your-app-key",
region = "us1",
memberAuthEndpoint = "https://your-backend.example.com/bird/auth/member",
)
)
val me = bird.signin() // suspending
println("signed in as ${me.memberId}")
bird.member.bind("order.shipped") { data ->
val orderId = data?.jsonObject?.get("order_id")?.jsonPrimitive?.content
showToast("Order $orderId is on its way")
}The client retains the binding, signs in after reconnecting, and then resumes member-event delivery.
signin() is asynchronous in all three clients. It returns a promise in the browser, uses async in Swift, and suspends in Kotlin. Call it from the appropriate asynchronous context. One call arms automatic sign-in after later reconnects.
Send an event from your server
Call members.send with the app ID, member ID, and event:
await bird.realtime.members.send("rap_01krdgeqcxet5s7t44vh8rt9mg", "u_42", {
event: "order.shipped",
data: { order_id: "ord_123" },
});client.realtime.members.send(
"rap_01krdgeqcxet5s7t44vh8rt9mg",
"u_42",
event="order.shipped",
data={"order_id": "ord_123"},
)err = client.Realtime.Members.Send(context.Background(), "rap_01krdgeqcxet5s7t44vh8rt9mg", "u_42", bird.RealtimeMemberSendParams{
Event: "order.shipped",
Data: map[string]any{"order_id": "ord_123"},
})$bird->realtime->members->send('rap_01krdgeqcxet5s7t44vh8rt9mg', 'u_42', (new RealtimeMemberPublish())
->setEvent('order.shipped')
->setData(['order_id' => 'ord_123']));curl -X POST \
https://us1.platform.bird.com/v1/realtime/apps/rap_01krdgeqcxet5s7t44vh8rt9mg/members/u_42/events \
-H "Authorization: Bearer $BIRD_API_KEY" \
-H "X-Realtime-Key: $BIRD_REALTIME_KEY" \
-H "X-Realtime-Secret: $BIRD_REALTIME_SECRET" \
-H "Content-Type: application/json" \
-d '{ "event": "order.shipped", "data": { "order_id": "ord_123" } }'u_42 is the member_id signed by your authorization endpoint. Use your system's existing identifier if it meets the member ID requirements.
Who receives the event
- Every connection that member holds, across their tabs and devices. One call, however many connections.
- Nobody else, even if another member's app binds the same event name.
- Nothing if the member has no live connections. The call still succeeds because delivery is not queued and cannot confirm occupancy. Store durable notifications and load them when the member returns.
Member or private channel
| Use a member event | Use a private channel |
|---|---|
| The recipient is the destination: personal notifications, account changes | The destination is a shared thing several people watch: a document, an order, a room |
| No channel to name or authorize | You name the channel and authorize each subscription |
| No presence, connection counts, or client events | Presence, connection counts, and client events are available |
Next steps
- Authorized connections covers signin() and the member auth endpoint.
- Terminating member connections closes every connection a member holds.
- Send an event to a member is the full API reference.