Publish a batch of Realtime events
/v1/realtime/apps/{realtime_app_id}/batch-eventsawait bird.realtime.publishBatch("rap_01krdgeqcxet5s7t44vh8rt9mg", {
events: [
{ event: "order.created", channel: "orders", data: { id: 1 } },
{ event: "order.updated", channel: "orders", data: { id: 2 } },
],
});client.realtime.publish_batch(
"rap_01krdgeqcxet5s7t44vh8rt9mg",
events=[
{"event": "order.created", "channel": "orders", "data": {"id": 1}},
{"event": "order.updated", "channel": "orders", "data": {"id": 2}},
],
)result, err := client.Realtime.PublishBatch(context.Background(), "rap_123", bird.RealtimePublishBatchParams{
Events: []bird.RealtimeBatchEventParams{
{Event: "order.created", Channel: "orders", Data: map[string]any{"id": 1}},
{Event: "order.updated", Channel: "orders", Data: map[string]any{"id": 2}},
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(result.Data)$batch = $bird->realtime->publishBatch($appId, (new RealtimeBatchPublish())
->setEvents([
(new RealtimeBatchEvent())->setEvent('message.created')->setChannel('room-1')->setData(['text' => 'hi']),
(new RealtimeBatchEvent())->setEvent('message.created')->setChannel('room-2')->setData(['text' => 'yo']),
]));
echo count($batch->getData() ?? []), ' event(s)';curl -X POST "https://us1.platform.bird.com/v1/realtime/apps/{realtime_app_id}/batch-events" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"events": [
{
"event": "order-updated",
"channel": "orders-42",
"exclude_connection_id": "123.4567"
}
]
}'{
"data": [
{
"channel": "orders-42"
}
]
}
Publishes up to 10 events (each to one channel) in a single request.
Parameters
realtime_app_idstringID of the Realtime app (rap_ prefix), as returned when the app was created.
Request Payload
eventsUp to 10 events per batch.
Show child parameters
events.eventThe event name clients bind to. Application event names are free-form; the bird: and bird_internal: prefixes are reserved for the protocol and rejected.
events.channelA Realtime channel name. Only letters, digits, and _ - = @ , . ; Prefix with private- or presence- for authenticated channels, or private-encrypted- for channels whose payloads are end-to-end encrypted with a key only you hold.
events.dataArbitrary JSON payload delivered as the event data: an object, array, or scalar. Cap: 10 KB serialized.
events.exclude_connection_idExclude this connection from delivery, to avoid echoing a change back to the client that triggered it. The value is the client's connection id, assigned when its connection is established.
events.includeAttributes of this event's channel to return alongside the publish (same semantics and validation errors as on the channel endpoints). Requesting attributes counts as one additional message toward usage.
Response Payload
dataPer-event channel attributes at publish time, present only when at least one event asked for them via include. Positional: one item per event, in request order.
Show child attributes
data.member_countDistinct members (presence channels only; requires include=member_count).
data.connection_countConnections currently subscribed to this channel (requires include=connection_count and the app's connection-counting flag). Channel-scoped: distinct from the app-wide peak connections metric.
data.channelA Realtime channel name. Only letters, digits, and _ - = @ , . ; Prefix with private- or presence- for authenticated channels, or private-encrypted- for channels whose payloads are end-to-end encrypted with a key only you hold.
Related resources
Continue with the documentation, guides and examples for this topic.