Documentation
Sign inGet started

Excluding event recipients

If a client applies a change optimistically before your server publishes it, receiving the same event can apply the change twice. This can cause a flicker or duplicate item.
Pass the acting client's connection ID to deliver the event to every other subscribed connection.
await bird.realtime.publish(appId, {
  event: "message.created",
  channels: ["presence-room-1"],
  data: { body: "hello" },
  exclude_connection_id: "26896.319537",
});

Get the connection ID

The client reads its connection ID and sends it with the request that triggers the change:
const bird = new BirdRealtime({ appKey: "your-app-key", region: "us1" });

await fetch("/messages", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({
    body: "hello",
    connection_id: bird.connection.connectionId,
  }),
});
The ID is null until the connection is established and changes after a reconnect. Read bird.connection.connectionId in the browser or bird.connectionId in Swift and Kotlin when you make the request.
Pass the value to exclude_connection_id after validating it as untrusted request data. This field can suppress delivery to one connection but cannot grant access to an event.

Excluded connection behavior

Only the named connection is excluded. The same person's other tabs use separate connections and still receive the event.
Excluding a connection ID that is not subscribed, or no longer exists, is not an error. The publish delivers normally to everyone else.

When to omit exclusion

Use exclusion for optimistic interfaces. If the client waits for the event before applying a change, do not exclude it. Otherwise, the acting tab remains stale.

Next steps