Invites

Invites allow you to add users to a channel with a pending state. The invited user receives a notification and can accept or reject the invite.

Unread counts are not incremented for channels with a pending invite.

Invite Users

chat.updateChannel("messaging", "general", UpdateChannelRequest.builder()
    .invites(List.of(
        ChannelMemberRequest.builder().userID("thierry").build(),
        ChannelMemberRequest.builder().userID("tommaso").build()))
    .build()).execute();

Accept an Invite

Call acceptInvite to accept a pending invite. You can optionally include a message parameter to post a system message when the user joins (e.g., "Nick joined this channel!").

chat.updateChannel("messaging", "general", UpdateChannelRequest.builder()
    .acceptInvite(true)
    .userID("nick")
    .message(MessageRequest.builder().text("Nick joined the channel").userID("nick").build())
    .build()).execute();

Reject an Invite

Call rejectInvite to decline a pending invite. Client-side calls use the currently connected user. Server-side calls require a user_id parameter.

chat.updateChannel("messaging", "general", UpdateChannelRequest.builder()
    .rejectInvite(true)
    .userID("nick")
    .build()).execute();

Query Invites by Status

Use queryChannels with the invite filter to retrieve channels based on invite status. Valid values are pending, accepted, and rejected.

Query Accepted Invites

chat.queryChannels(QueryChannelsRequest.builder()
    .filterConditions(Map.of("invite", "accepted"))
    .build()).execute();

Query Rejected Invites

chat.queryChannels(QueryChannelsRequest.builder()
    .filterConditions(Map.of("invite", "rejected"))
    .build()).execute();

Query Pending Invites

FilterObject filter = Filters.eq("invite", "pending");
int offset = 0;
int limit = 10;
QuerySorter<Channel> sort = new QuerySortByField<>();
int messageLimit = 0;
int memberLimit = 0;
QueryChannelsRequest request = new QueryChannelsRequest(filter, offset, limit, sort, messageLimit, memberLimit);

client.queryChannels(request).enqueue(result -> {
  if (result.isSuccess()) {
    List<Channel> channels = result.getOrNull();
  } else {
    // Handle error
  }
});
Add Chat to my app: getstream.io/SKILL.md

The fastest way to build with Stream. Start a new project or improve an existing one. Full CLI and documentation integration out of the box.


Ask your agent:

/stream Build me a Social App with Feeds and Moderation.
/stream Any livestream calls running?
/stream Chat Java: <Your Question>