# `Chatto.Api.V1.RoomService`
[🔗](https://github.com/xtian/elixir-chatto/blob/v0.1.0/lib/chatto/generated/chatto_api_v1_room_service.ex#L3)

Manages room-scoped operations for the current user.

RoomService owns operations whose authorization and state are primarily scoped
to one room, including lifecycle, membership, moderation, room timeline reads,
room read state, attachments, and live typing. Resource-specific services
should still be preferred when an operation is not naturally room-scoped or
when the resource needs an independent CRUD/batch surface.

# `add_member`

```elixir
@spec add_member(Req.Request.t(), Chatto.Api.V1.AddMemberRequest.t()) ::
  {:ok, Chatto.Api.V1.AddMemberResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Adds an account as an explicit channel-room member. room.manage for this
room or user.manage-accounts overrides the target's missing room.join.
Bot owners and bot.manage holders may also add bots, but without either
override the acting human needs effective room.join. The bot's own
room.join is required only when the bot joins itself through JoinRoom.
Preserves permission grants. Suspensions, archived, universal, and DM rooms prevent adding.

# `archive_room`

```elixir
@spec archive_room(Req.Request.t(), Chatto.Api.V1.ArchiveRoomRequest.t()) ::
  {:ok, Chatto.Api.V1.ArchiveRoomResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Archives a room so it is hidden from active room lists. The caller must be
allowed to manage rooms.

# `batch_get_members`

```elixir
@spec batch_get_members(Req.Request.t(), Chatto.Api.V1.BatchGetMembersRequest.t()) ::
  {:ok, Chatto.Api.V1.BatchGetMembersResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Gets effective member rows for the requested accounts. Uses the same
authorization as GetMember; omits unknown accounts and nonmembers.

# `batch_get_room_read_states`

```elixir
@spec batch_get_room_read_states(
  Req.Request.t(),
  Chatto.Api.V1.BatchGetRoomReadStatesRequest.t()
) ::
  {:ok, Chatto.Api.V1.BatchGetRoomReadStatesResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Reads up to 100 states under the same authorization as GetRoomReadState.
Missing and inaccessible resources are omitted; duplicates use first-seen order.

# `clear_notice`

```elixir
@spec clear_notice(Req.Request.t(), Chatto.Api.V1.ClearNoticeRequest.t()) ::
  {:ok, Chatto.Api.V1.ClearNoticeResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Clears a notice under the same access and version rules as PublishNotice.

# `create_pinned_message`

```elixir
@spec create_pinned_message(
  Req.Request.t(),
  Chatto.Api.V1.CreatePinnedMessageRequest.t()
) ::
  {:ok, Chatto.Api.V1.CreatePinnedMessageResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Pins a current message. The caller must have message.pin and must be able
to read the message. Repeating an existing pin is idempotent. Direct-message
rooms are rejected.

# `create_room`

```elixir
@spec create_room(Req.Request.t(), Chatto.Api.V1.CreateRoomRequest.t()) ::
  {:ok, Chatto.Api.V1.CreateRoomResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Creates a new channel room in a room group. The caller must be allowed to
create rooms in the target group.

# `delete_pinned_message`

```elixir
@spec delete_pinned_message(
  Req.Request.t(),
  Chatto.Api.V1.DeletePinnedMessageRequest.t()
) ::
  {:ok, Chatto.Api.V1.DeletePinnedMessageResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Removes a current pin. The caller must have message.pin. Removing a
missing pin is idempotent. Direct-message rooms are rejected.

# `get_member`

```elixir
@spec get_member(Req.Request.t(), Chatto.Api.V1.GetMemberRequest.t()) ::
  {:ok, Chatto.Api.V1.GetMemberResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Gets one effective member, including automatic universal membership.
Channel-room members, room.manage holders, and user.manage-accounts holders
may read members. Bot owners and bot.manage holders may read their target
bots only. DMs require caller membership. Returns NOT_FOUND for nonmembers.

# `get_notice`

```elixir
@spec get_notice(Req.Request.t(), Chatto.Api.V1.GetNoticeRequest.t()) ::
  {:ok, Chatto.Api.V1.GetNoticeResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Reads a channel notice. Requires current room membership, including in
archived rooms. A room without a notice returns an empty body.

# `get_room_events`

```elixir
@spec get_room_events(Req.Request.t(), Chatto.Api.V1.GetRoomEventsRequest.t()) ::
  {:ok, Chatto.Api.V1.GetRoomEventsResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Returns one page of room timeline events, including related user data
needed to render the page. Room membership is required. Reads also require
message.read or message.read-interactions. The server returns only related
thread roots for an interaction-scoped caller.

# `get_room_events_around`

```elixir
@spec get_room_events_around(
  Req.Request.t(),
  Chatto.Api.V1.GetRoomEventsAroundRequest.t()
) ::
  {:ok, Chatto.Api.V1.GetRoomEventsAroundResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Returns a room timeline window centered around a specific event. Use this to
open a permalink, search result, or notification target in context. Returns
NOT_FOUND when the anchor event is missing or not visible in the room
timeline. Returns PERMISSION_DENIED when room membership or both read modes
are missing, or when the anchor is in an unrelated thread.

# `get_room_read_state`

```elixir
@spec get_room_read_state(Req.Request.t(), Chatto.Api.V1.GetRoomReadStateRequest.t()) ::
  {:ok, Chatto.Api.V1.GetRoomReadStateResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Reads the current viewer's stored marker without changing it. Requires the
same membership and read access as MarkRoomAsRead. Missing resources
return NOT_FOUND; inaccessible resources return PERMISSION_DENIED.

# `join_room`

```elixir
@spec join_room(Req.Request.t(), Chatto.Api.V1.JoinRoomRequest.t()) ::
  {:ok, Chatto.Api.V1.JoinRoomResponse.t()} | {:error, Chatto.Connect.Error.t()}
```

Joins the room as the current user when room permissions allow it.

# `join_room_group`

```elixir
@spec join_room_group(Req.Request.t(), Chatto.Api.V1.JoinRoomGroupRequest.t()) ::
  {:ok, Chatto.Api.V1.JoinRoomGroupResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Joins every unarchived room in a group that the current user can join.
Already-joined and non-joinable rooms are skipped.

# `leave_room`

```elixir
@spec leave_room(Req.Request.t(), Chatto.Api.V1.LeaveRoomRequest.t()) ::
  {:ok, Chatto.Api.V1.LeaveRoomResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Leaves the room as the current user. Direct-message and universal rooms
cannot be left.

# `lift_suspension`

```elixir
@spec lift_suspension(Req.Request.t(), Chatto.Api.V1.LiftSuspensionRequest.t()) ::
  {:ok, Chatto.Api.V1.LiftSuspensionResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Lifts an active channel room suspension. Requires room.remove-member.
Calling this when no active suspension exists succeeds.

# `list_members`

```elixir
@spec list_members(Req.Request.t(), Chatto.Api.V1.ListMembersRequest.t()) ::
  {:ok, Chatto.Api.V1.ListMembersResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Lists effective room member IDs in ascending ID order. Resolve user details
with UserService.BatchGetUsers. Existing members and room.manage holders may
list a channel room; other nonmembers need both room.list and room.join.

# `list_pinned_messages`

```elixir
@spec list_pinned_messages(
  Req.Request.t(),
  Chatto.Api.V1.ListPinnedMessagesRequest.t()
) ::
  {:ok, Chatto.Api.V1.ListPinnedMessagesResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Lists current pinned messages in a channel room. Room membership plus
message.read or message.read-interactions are required. The server omits
pins from threads that the caller cannot read. Direct-message rooms do not
support pins.

# `list_room_attachments`

```elixir
@spec list_room_attachments(
  Req.Request.t(),
  Chatto.Api.V1.ListRoomAttachmentsRequest.t()
) ::
  {:ok, Chatto.Api.V1.ListRoomAttachmentsResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Lists current message-owned room attachments. Authentication and room
membership are required. Attachments also require message.read or a
matching thread relationship with message.read-interactions. The server omits attachments from
inaccessible threads. Returns PERMISSION_DENIED when the room is
inaccessible to the caller.

# `list_suspensions`

```elixir
@spec list_suspensions(Req.Request.t(), Chatto.Api.V1.ListSuspensionsRequest.t()) ::
  {:ok, Chatto.Api.V1.ListSuspensionsResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Lists active channel room suspensions. Requires server-scope
room.remove-member.

# `mark_room_as_read`

```elixir
@spec mark_room_as_read(Req.Request.t(), Chatto.Api.V1.MarkRoomAsReadRequest.t()) ::
  {:ok, Chatto.Api.V1.MarkRoomAsReadResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Marks a room timeline as read through the supplied event. Room membership
is required. Reads also require message.read or
message.read-interactions. If no event
is supplied, the server marks through the latest root event that the caller
can read. Clients
usually call this after the user has viewed the latest visible event in the
room.

# `publish_notice`

```elixir
@spec publish_notice(Req.Request.t(), Chatto.Api.V1.PublishNoticeRequest.t()) ::
  {:ok, Chatto.Api.V1.PublishNoticeResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Publishes, corrects, or explicitly republishes a notice. Requires current
membership and room.manage-notice. Archived rooms reject writes. A stale
expected_version returns ABORTED; preserve the draft and reload before retry.

# `refresh_typing_indicator`

```elixir
@spec refresh_typing_indicator(
  Req.Request.t(),
  Chatto.Api.V1.RefreshTypingIndicatorRequest.t()
) ::
  {:ok, Chatto.Api.V1.RefreshTypingIndicatorResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Refreshes the current user's live-only typing indicator for a room or
thread. Room membership is required; message posting permission is not.
Send at most once every 2 seconds while typing. After posting a message,
the next typing activity can send immediately. Stop sending when typing
stops; receivers clear the indicator after 6 seconds without an event.

# `remove_member`

```elixir
@spec remove_member(Req.Request.t(), Chatto.Api.V1.RemoveMemberRequest.t()) ::
  {:ok, Chatto.Api.V1.RemoveMemberResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Removes an explicit channel-room member. Requires room.manage for this room,
user.manage-accounts, ownership of the target bot, or bot.manage.
Removal is allowed after room.join is lost and from archived rooms.
Preserves permission grants. Universal and DM membership cannot be edited.

# `remove_user`

```elixir
@spec remove_user(Req.Request.t(), Chatto.Api.V1.RemoveUserRequest.t()) ::
  {:ok, Chatto.Api.V1.RemoveUserResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Removes a current channel room member with a required reason. Requires
room.remove-member. Without suspension, ordinary join rules apply afterward.
Universal rooms require a suspension. Direct-message rooms are excluded.

# `start_dm`

```elixir
@spec start_dm(Req.Request.t(), Chatto.Api.V1.StartDMRequest.t()) ::
  {:ok, Chatto.Api.V1.StartDMResponse.t()} | {:error, Chatto.Connect.Error.t()}
```

Starts a direct-message room for the current human user and the requested
participant set, or fetches its existing DM. message.post is required
only when the DM must be created. A valid request from a bot receives
PERMISSION_DENIED and cannot use this RPC to fetch an existing DM.
New DMs support the caller and at most one other user. New group DMs
receive INVALID_ARGUMENT; use a channel room instead. Existing group
DMs can still be fetched.

# `unarchive_room`

```elixir
@spec unarchive_room(Req.Request.t(), Chatto.Api.V1.UnarchiveRoomRequest.t()) ::
  {:ok, Chatto.Api.V1.UnarchiveRoomResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Restores an archived room to active room lists. The caller must be allowed
to manage rooms.

# `update_room`

```elixir
@spec update_room(Req.Request.t(), Chatto.Api.V1.UpdateRoomRequest.t()) ::
  {:ok, Chatto.Api.V1.UpdateRoomResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Updates a room's editable metadata. The caller must be allowed to manage
rooms. Direct-message rooms cannot be universal.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
