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

Creates messages in room and thread timelines.

# `add_reaction`

```elixir
@spec add_reaction(Req.Request.t(), Chatto.Api.V1.AddReactionRequest.t()) ::
  {:ok, Chatto.Api.V1.AddReactionResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Adds a reaction to a message. The user must be a room member and have
message.react. Reactions also require message.read or a matching thread
relationship with message.read-interactions.

# `batch_get_messages`

```elixir
@spec batch_get_messages(Req.Request.t(), Chatto.Api.V1.BatchGetMessagesRequest.t()) ::
  {:ok, Chatto.Api.V1.BatchGetMessagesResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Reads many renderable messages and their current pin state in one room.
Authentication and room membership are required. Reads also
require message.read or a matching thread relationship with
message.read-interactions. Missing,
retracted, non-message, wrong-room, and inaccessible event IDs are omitted.
Results preserve first-seen request order, and repeated event IDs are
de-duplicated.

# `create_message`

```elixir
@spec create_message(Req.Request.t(), Chatto.Api.V1.CreateMessageRequest.t()) ::
  {:ok, Chatto.Api.V1.CreateMessageResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Creates a message for the current user. The user must be a room member and
must have message.post for room messages. Thread replies require read
access and either message.post, message.post-in-thread, or
message.post-in-interactions with an existing interaction relationship.
Echoing a thread reply also requires message.echo and
message.post. The room's Threading Mode may automatically establish a root
thread or reject a thread placement that the mode does not allow.

# `delete_attachment`

```elixir
@spec delete_attachment(Req.Request.t(), Chatto.Api.V1.DeleteAttachmentRequest.t()) ::
  {:ok, Chatto.Api.V1.DeleteAttachmentResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Removes one attachment from the author's own message.

# `delete_link_preview`

```elixir
@spec delete_link_preview(Req.Request.t(), Chatto.Api.V1.DeleteLinkPreviewRequest.t()) ::
  {:ok, Chatto.Api.V1.DeleteLinkPreviewResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Removes the accepted link preview from the author's own message.

# `delete_message`

```elixir
@spec delete_message(Req.Request.t(), Chatto.Api.V1.DeleteMessageRequest.t()) ::
  {:ok, Chatto.Api.V1.DeleteMessageResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Retracts a message. Authors can delete their own messages. Non-authors need
message.manage.

# `fetch_link_preview`

```elixir
@spec fetch_link_preview(Req.Request.t(), Chatto.Api.V1.FetchLinkPreviewRequest.t()) ::
  {:ok, Chatto.Api.V1.FetchLinkPreviewResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Fetches and caches metadata for a URL. Authentication is required
to avoid exposing the preview fetcher as an unauthenticated network proxy.
Successful responses include a short-lived token accepted by CreateMessage,
unless omit_preview_token is set for a display-only read.

# `get_message`

```elixir
@spec get_message(Req.Request.t(), Chatto.Api.V1.GetMessageRequest.t()) ::
  {:ok, Chatto.Api.V1.GetMessageResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Reads one renderable message, including current body, attachment metadata,
link preview, reactions, thread metadata, and pin state. Authentication
and room membership are required. Reads also require
message.read or a matching thread relationship with
message.read-interactions. Returns
NOT_FOUND when the event does not exist, is not a message, has been
retracted, or belongs to a different room.

# `list_reaction_users`

```elixir
@spec list_reaction_users(Req.Request.t(), Chatto.Api.V1.ListReactionUsersRequest.t()) ::
  {:ok, Chatto.Api.V1.ListReactionUsersResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Lists all users with the requested reaction. Requires room membership and
permission to read the message. A missing reaction returns an empty page;
a missing or hidden message returns NOT_FOUND or PERMISSION_DENIED.

# `remove_reaction`

```elixir
@spec remove_reaction(Req.Request.t(), Chatto.Api.V1.RemoveReactionRequest.t()) ::
  {:ok, Chatto.Api.V1.RemoveReactionResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Removes a reaction from a message. The user must be a room member and have
message.react. Reactions also require message.read or a matching thread
relationship with message.read-interactions.

# `set_attachment_description`

```elixir
@spec set_attachment_description(
  Req.Request.t(),
  Chatto.Api.V1.SetAttachmentDescriptionRequest.t()
) ::
  {:ok, Chatto.Api.V1.SetAttachmentDescriptionResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Sets or clears one attachment description. Authors can change descriptions
within the message edit window. Effective message.manage permits changes
at any time and to other users' messages. Room membership and message read
access are required.

# `update_message`

```elixir
@spec update_message(Req.Request.t(), Chatto.Api.V1.UpdateMessageRequest.t()) ::
  {:ok, Chatto.Api.V1.UpdateMessageResponse.t()}
  | {:error, Chatto.Connect.Error.t()}
```

Edits a message body. Authors can edit their own messages within the edit
window. Effective message.manage permits edits at any time and removal of
another author's channel echo. Only the author can enable an echo, which
also requires message.echo and message.post. Omit unchanged echo state.
Disabled rooms reject
creation of a new channel echo while allowing an existing echo to be
removed. Room membership is also required.
Edits require message.read or a matching thread relationship with
message.read-interactions.

---

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