# `BaileysEx`
[🔗](https://github.com/jeffhuen/baileys_ex/blob/main/lib/baileys_ex.ex#L1)

Public facade for the BaileysEx connection runtime and major feature surfaces.

## Quick Start

    alias BaileysEx.Auth.NativeFilePersistence
    alias BaileysEx.Connection.Transport.MintWebSocket

    {:ok, persisted_auth} =
      NativeFilePersistence.use_native_file_auth_state("tmp/baileys_auth")
    parent = self()

    {:ok, connection} =
      BaileysEx.connect(
        persisted_auth.state,
        Keyword.merge(persisted_auth.connect_opts, [
          transport: {MintWebSocket, []},
          on_qr: fn qr -> IO.puts("Scan QR: #{qr}") end,
          on_connection: fn update ->
            IO.inspect({:connection, update})
            send(parent, {:connection_update, update})
          end
        ])
      )

    _creds_unsubscribe =
      BaileysEx.subscribe_raw(connection, fn events ->
        if Map.has_key?(events, :creds_update) do
          {:ok, latest_auth_state} = BaileysEx.auth_state(connection)
          :ok = persisted_auth.save_creds.(latest_auth_state)
        end
      end)

    receive do
      {:connection_update, %{connection: :open}} -> :ok
    after
      30_000 -> raise "connection did not open"
    end

    unsubscribe =
      BaileysEx.subscribe(connection, fn
        {:message, message} -> IO.inspect(message, label: "incoming")
        {:connection, update} -> IO.inspect(update, label: "connection")
        _other -> :ok
      end)

    unsubscribe.()
    :ok = BaileysEx.disconnect(connection)

## Persistence Backends

Use `BaileysEx.Auth.NativeFilePersistence.use_native_file_auth_state/1` for the
recommended durable file-backed setup in Elixir-first apps.

Use `BaileysEx.Auth.FilePersistence.use_multi_file_auth_state/1` when you need
the Baileys-compatible JSON multi-file auth layout and helper semantics.

Custom SQL/NoSQL backends remain supported through
`BaileysEx.Auth.Persistence`, `BaileysEx.Auth.KeyStore`, and a matching
`signal_store_module`. Advanced custom store modules must implement the
explicit transaction-handle contract in `BaileysEx.Signal.Store`; the
built-in helpers already wire the correct store for you.

Advanced callers can obtain the raw socket transport tuple via `queryable/1`
and pass it directly to the lower-level feature modules.

Outbound `send_message/4` and `send_status/3` use the built-in production Signal
adapter by default when the auth state includes `signed_identity_key`,
`signed_pre_key`, and `registration_id`. Use `:signal_repository` or
`:signal_repository_adapter` only when you need to override that default.

# `connection`

```elixir
@type connection() :: GenServer.server()
```

# `unsubscribe_fun`

```elixir
@type unsubscribe_fun() :: (-&gt; :ok)
```

# `web_message_info`

```elixir
@type web_message_info() :: struct()
```

Opaque WAProto `WebMessageInfo` struct accepted by media download and retry helpers.

# `archive_chat`

```elixir
@spec archive_chat(connection(), String.t(), boolean(), list(), keyword()) ::
  :ok | {:error, term()}
```

Archive or unarchive a chat via the app-state patch path.

# `auth_state`

```elixir
@spec auth_state(connection()) :: {:ok, map()} | {:error, :store_not_available}
```

Return the current auth state snapshot from the connection store.

`creds_update` events are mirrored into the store before public subscribers run,
so callers can safely read `auth_state/1` from inside those callbacks.

# `business_catalog`

```elixir
@spec business_catalog(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}
```

Fetch a business catalog.

# `business_collections`

```elixir
@spec business_collections(connection(), String.t() | nil, pos_integer(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Fetch business catalog collections.

# `business_order_details`

```elixir
@spec business_order_details(connection(), String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Fetch business order details.

# `business_product_create`

```elixir
@spec business_product_create(connection(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Create a business product.

# `business_product_delete`

```elixir
@spec business_product_delete(connection(), [String.t()], keyword()) ::
  {:ok, %{deleted: non_neg_integer()}} | {:error, term()}
```

Delete one or more business products.

# `business_product_update`

```elixir
@spec business_product_update(connection(), String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Update a business product.

# `business_profile`

```elixir
@spec business_profile(connection(), String.t(), keyword()) ::
  {:ok, map() | nil} | {:error, term()}
```

Fetch the business profile for a WhatsApp JID.

# `clear_chat`

```elixir
@spec clear_chat(connection(), String.t(), list(), keyword()) ::
  :ok | {:error, term()}
```

Clear a chat history via app-state sync.

# `community_accept_invite`

```elixir
@spec community_accept_invite(connection(), String.t(), keyword()) ::
  {:ok, String.t() | nil} | {:error, term()}
```

Accept a legacy community invite code.

# `community_accept_invite_v4`

```elixir
@spec community_accept_invite_v4(connection(), String.t() | map(), map(), keyword()) ::
  {:ok, String.t() | nil} | {:error, term()}
```

Accept a v4 community invite.

# `community_create`

```elixir
@spec community_create(connection(), String.t(), String.t() | nil, keyword()) ::
  {:ok, map()} | {:error, term()}
```

Create a community.

# `community_create_group`

```elixir
@spec community_create_group(
  connection(),
  String.t(),
  [String.t()],
  String.t(),
  keyword()
) ::
  {:ok, map() | nil} | {:error, term()}
```

Create a linked subgroup inside a community.

# `community_fetch_all_participating`

```elixir
@spec community_fetch_all_participating(
  connection(),
  keyword()
) :: {:ok, %{required(String.t()) =&gt; map()}} | {:error, term()}
```

Fetch all participating communities.

# `community_fetch_linked_groups`

```elixir
@spec community_fetch_linked_groups(connection(), String.t(), keyword()) ::
  {:ok,
   %{community_jid: String.t(), is_community: boolean(), linked_groups: [map()]}}
  | {:error, term()}
```

Fetch linked groups for a community or subgroup.

# `community_get_invite_info`

```elixir
@spec community_get_invite_info(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Fetch community invite metadata without joining.

# `community_invite_code`

```elixir
@spec community_invite_code(connection(), String.t(), keyword()) ::
  {:ok, String.t() | nil} | {:error, term()}
```

Fetch the current community invite code.

# `community_join_approval_mode`

```elixir
@spec community_join_approval_mode(connection(), String.t(), :on | :off, keyword()) ::
  :ok | {:error, term()}
```

Toggle join-approval mode for a community.

# `community_leave`

```elixir
@spec community_leave(connection(), String.t(), keyword()) :: :ok | {:error, term()}
```

Leave a community.

# `community_link_group`

```elixir
@spec community_link_group(connection(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}
```

Link an existing subgroup into a community.

# `community_member_add_mode`

```elixir
@spec community_member_add_mode(
  connection(),
  String.t(),
  :admin_add | :all_member_add,
  keyword()
) :: :ok | {:error, term()}
```

Switch whether only admins or all members can add participants to a community.

# `community_metadata`

```elixir
@spec community_metadata(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Fetch community metadata.

# `community_participants_update`

```elixir
@spec community_participants_update(
  connection(),
  String.t(),
  [String.t()],
  :add | :remove | :promote | :demote,
  keyword()
) :: {:ok, [map()]} | {:error, term()}
```

Add, remove, promote, or demote community participants.

# `community_request_participants_list`

```elixir
@spec community_request_participants_list(connection(), String.t(), keyword()) ::
  {:ok, [map()]} | {:error, term()}
```

Fetch the pending membership-approval request list for a community.

# `community_request_participants_update`

```elixir
@spec community_request_participants_update(
  connection(),
  String.t(),
  [String.t()],
  :approve | :reject,
  keyword()
) :: {:ok, [map()]} | {:error, term()}
```

Approve or reject pending community membership requests.

# `community_revoke_invite`

```elixir
@spec community_revoke_invite(connection(), String.t(), keyword()) ::
  {:ok, String.t() | nil} | {:error, term()}
```

Revoke the current community invite code and return the new one.

# `community_revoke_invite_v4`

```elixir
@spec community_revoke_invite_v4(connection(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}
```

Revoke a v4 community invite for a specific invited user.

# `community_setting_update`

```elixir
@spec community_setting_update(
  connection(),
  String.t(),
  :announcement | :not_announcement | :locked | :unlocked,
  keyword()
) :: :ok | {:error, term()}
```

Update a community announcement or locked setting.

# `community_toggle_ephemeral`

```elixir
@spec community_toggle_ephemeral(
  connection(),
  String.t(),
  non_neg_integer(),
  keyword()
) ::
  :ok | {:error, term()}
```

Enable or disable disappearing messages for a community.

# `community_unlink_group`

```elixir
@spec community_unlink_group(connection(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}
```

Unlink a subgroup from a community.

# `community_update_description`

```elixir
@spec community_update_description(
  connection(),
  String.t(),
  String.t() | nil,
  keyword()
) ::
  :ok | {:error, term()}
```

Update or clear a community description.

# `community_update_subject`

```elixir
@spec community_update_subject(connection(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}
```

Update a community subject.

# `connect`

```elixir
@spec connect(
  term(),
  keyword()
) :: {:ok, pid()} | {:error, term()}
```

Start a connection runtime and optionally attach convenience callbacks.

Pass a real `:transport` such as `{BaileysEx.Connection.Transport.MintWebSocket, []}`
when you want an actual WhatsApp connection. Without it, the default transport
returns `{:error, :transport_not_configured}`.

Use `BaileysEx.Auth.NativeFilePersistence.use_native_file_auth_state/1` for the
recommended durable built-in file setup.

Use `BaileysEx.Auth.FilePersistence.use_multi_file_auth_state/1` when you want the
Baileys-compatible JSON multi-file helper instead.

Custom persistence backends remain supported through `BaileysEx.Auth.Persistence`
plus a compatible `signal_store_module`. Advanced custom store modules must
follow the explicit transaction-handle contract in `BaileysEx.Signal.Store`.

Supported callback options:
- `:on_connection` receives each `connection_update` payload
- `:on_qr` receives QR strings extracted from `connection_update`
- `:on_message` receives each message from `messages_upsert`
- `:on_event` receives the raw buffered event map

These convenience callbacks stay attached for the lifetime of the connection runtime.
Use `subscribe/2` or `subscribe_raw/2` when you need an explicit unsubscribe handle.

# `create_call_link`

```elixir
@spec create_call_link(connection(), :audio | :video, map() | nil, keyword()) ::
  {:ok, String.t() | nil} | {:error, term()}
```

Create an audio or video call link.

# `delete_chat`

```elixir
@spec delete_chat(connection(), String.t(), list(), keyword()) ::
  :ok | {:error, term()}
```

Delete a chat via app-state sync.

# `delete_message_for_me`

```elixir
@spec delete_message_for_me(
  connection(),
  String.t(),
  map(),
  integer(),
  boolean(),
  keyword()
) ::
  :ok | {:error, term()}
```

Delete a specific message for the current device.

# `disconnect`

```elixir
@spec disconnect(connection()) :: :ok | {:error, term()}
```

Stop a running connection runtime.

# `download_media`

```elixir
@spec download_media(
  map(),
  keyword()
) :: {:ok, binary()} | {:error, term()}
```

Download media into memory.

# `download_media_to_file`

```elixir
@spec download_media_to_file(map(), Path.t(), keyword()) ::
  {:ok, Path.t()} | {:error, term()}
```

Download media directly to a file path.

# `event_emitter`

```elixir
@spec event_emitter(connection()) ::
  {:ok, pid()} | {:error, :event_emitter_not_available}
```

Return the connection event emitter pid.

# `fetch_blocklist`

```elixir
@spec fetch_blocklist(
  connection(),
  keyword()
) :: {:ok, [String.t()]} | {:error, term()}
```

Fetch the account blocklist.

# `fetch_latest_baileys_version`

```elixir
@spec fetch_latest_baileys_version(keyword()) :: map()
```

Fetch the latest version published by Baileys' current `Defaults/index.ts`.

# `fetch_latest_wa_web_version`

```elixir
@spec fetch_latest_wa_web_version(keyword()) :: map()
```

Fetch the latest WhatsApp Web client revision from `web.whatsapp.com/sw.js`.

# `fetch_status`

```elixir
@spec fetch_status(connection(), [String.t()], keyword()) ::
  {:ok, [map()]} | {:error, term()}
```

Fetch profile status text for one or more JIDs.

# `group_accept_invite`

```elixir
@spec group_accept_invite(connection(), String.t(), keyword()) ::
  {:ok, String.t() | nil} | {:error, term()}
```

Accept a legacy group invite code.

# `group_accept_invite_v4`

```elixir
@spec group_accept_invite_v4(connection(), String.t() | map(), map(), keyword()) ::
  {:ok, String.t() | nil} | {:error, term()}
```

Accept a v4 group invite.

# `group_create`

```elixir
@spec group_create(connection(), String.t(), [String.t()], keyword()) ::
  {:ok, map()} | {:error, term()}
```

Create a group.

# `group_fetch_all_participating`

```elixir
@spec group_fetch_all_participating(
  connection(),
  keyword()
) :: {:ok, %{required(String.t()) =&gt; map()}} | {:error, term()}
```

Fetch all participating groups.

# `group_get_invite_info`

```elixir
@spec group_get_invite_info(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Fetch group invite metadata without joining.

# `group_invite_code`

```elixir
@spec group_invite_code(connection(), String.t(), keyword()) ::
  {:ok, String.t() | nil} | {:error, term()}
```

Fetch the current group invite code.

# `group_join_approval_mode`

```elixir
@spec group_join_approval_mode(connection(), String.t(), :on | :off, keyword()) ::
  :ok | {:error, term()}
```

Toggle join-approval mode for a group.

# `group_leave`

```elixir
@spec group_leave(connection(), String.t()) :: :ok | {:error, term()}
```

Leave a group.

# `group_member_add_mode`

```elixir
@spec group_member_add_mode(
  connection(),
  String.t(),
  :admin_add | :all_member_add,
  keyword()
) ::
  :ok | {:error, term()}
```

Switch whether only admins or all members can add participants.

# `group_metadata`

```elixir
@spec group_metadata(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Fetch group metadata.

# `group_participants_update`

```elixir
@spec group_participants_update(
  connection(),
  String.t(),
  [String.t()],
  :add | :remove | :promote | :demote,
  keyword()
) :: {:ok, [map()]} | {:error, term()}
```

Add, remove, promote, or demote group participants.

# `group_request_participants_list`

```elixir
@spec group_request_participants_list(connection(), String.t(), keyword()) ::
  {:ok, [map()]} | {:error, term()}
```

Fetch the pending join-request list for a group.

# `group_request_participants_update`

```elixir
@spec group_request_participants_update(
  connection(),
  String.t(),
  [String.t()],
  :approve | :reject,
  keyword()
) :: {:ok, [map()]} | {:error, term()}
```

Approve or reject pending group join requests.

# `group_revoke_invite`

```elixir
@spec group_revoke_invite(connection(), String.t(), keyword()) ::
  {:ok, String.t() | nil} | {:error, term()}
```

Revoke the current group invite code and return the new one.

# `group_revoke_invite_v4`

```elixir
@spec group_revoke_invite_v4(connection(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}
```

Revoke a v4 group invite for a specific invited user.

# `group_setting_update`

```elixir
@spec group_setting_update(
  connection(),
  String.t(),
  :announcement | :not_announcement | :locked | :unlocked,
  keyword()
) :: :ok | {:error, term()}
```

Update a group announcement or locked setting.

# `group_toggle_ephemeral`

```elixir
@spec group_toggle_ephemeral(connection(), String.t(), non_neg_integer(), keyword()) ::
  :ok | {:error, term()}
```

Enable or disable disappearing messages for a group.

# `group_update_description`

```elixir
@spec group_update_description(connection(), String.t(), String.t() | nil, keyword()) ::
  :ok | {:error, term()}
```

Update or clear a group description.

# `group_update_subject`

```elixir
@spec group_update_subject(connection(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}
```

Update a group subject.

# `mark_chat_read`

```elixir
@spec mark_chat_read(connection(), String.t(), boolean(), list(), keyword()) ::
  :ok | {:error, term()}
```

Mark a chat read or unread.

# `mute_chat`

```elixir
@spec mute_chat(connection(), String.t(), integer() | nil, keyword()) ::
  :ok | {:error, term()}
```

Mute a chat until the given Unix timestamp, or pass `nil` to unmute.

# `newsletter_admin_count`

```elixir
@spec newsletter_admin_count(connection(), String.t(), keyword()) ::
  {:ok, non_neg_integer()} | {:error, term()}
```

Fetch newsletter admin count.

# `newsletter_change_owner`

```elixir
@spec newsletter_change_owner(connection(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}
```

Change the newsletter owner.

# `newsletter_create`

```elixir
@spec newsletter_create(connection(), String.t(), String.t() | nil, keyword()) ::
  {:ok, map()} | {:error, term()}
```

Create a newsletter.

# `newsletter_delete`

```elixir
@spec newsletter_delete(connection(), String.t(), keyword()) :: :ok | {:error, term()}
```

Delete a newsletter.

# `newsletter_demote`

```elixir
@spec newsletter_demote(connection(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}
```

Demote a newsletter admin.

# `newsletter_fetch_messages`

```elixir
@spec newsletter_fetch_messages(connection(), String.t(), pos_integer(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Fetch newsletter message history.

# `newsletter_follow`

```elixir
@spec newsletter_follow(connection(), String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Follow a newsletter.

# `newsletter_metadata`

```elixir
@spec newsletter_metadata(connection(), :invite | :jid, String.t(), keyword()) ::
  {:ok, map() | nil} | {:error, term()}
```

Fetch newsletter metadata by `:jid` or `:invite` key.

# `newsletter_mute`

```elixir
@spec newsletter_mute(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Mute a newsletter.

# `newsletter_react_message`

```elixir
@spec newsletter_react_message(
  connection(),
  String.t(),
  String.t(),
  String.t() | nil,
  keyword()
) :: :ok | {:error, term()}
```

React to a newsletter message or remove an existing reaction.

# `newsletter_remove_picture`

```elixir
@spec newsletter_remove_picture(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Remove the newsletter picture.

# `newsletter_subscribe_updates`

```elixir
@spec newsletter_subscribe_updates(connection(), String.t(), keyword()) ::
  {:ok, %{duration: String.t()} | nil} | {:error, term()}
```

Subscribe to live newsletter updates.

# `newsletter_subscribers`

```elixir
@spec newsletter_subscribers(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Fetch newsletter subscriber counts.

# `newsletter_unfollow`

```elixir
@spec newsletter_unfollow(connection(), String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Unfollow a newsletter.

# `newsletter_unmute`

```elixir
@spec newsletter_unmute(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Unmute a newsletter.

# `newsletter_update`

```elixir
@spec newsletter_update(connection(), String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Update newsletter metadata.

# `newsletter_update_description`

```elixir
@spec newsletter_update_description(connection(), String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Update the newsletter description.

# `newsletter_update_name`

```elixir
@spec newsletter_update_name(connection(), String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Update the newsletter name.

# `newsletter_update_picture`

```elixir
@spec newsletter_update_picture(connection(), String.t(), term(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Update the newsletter picture.

# `on_whatsapp`

```elixir
@spec on_whatsapp(connection(), [String.t()], keyword()) ::
  {:ok, [%{exists: boolean(), jid: String.t()}]} | {:error, term()}
```

Check which phone numbers are registered on WhatsApp.

# `pin_chat`

```elixir
@spec pin_chat(connection(), String.t(), boolean(), keyword()) ::
  :ok | {:error, term()}
```

Pin or unpin a chat.

# `presence_subscribe`

```elixir
@spec presence_subscribe(connection(), String.t(), keyword()) ::
  :ok | {:error, term()}
```

Subscribe to a contact or group presence feed.

# `privacy_settings`

```elixir
@spec privacy_settings(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}
```

Fetch privacy settings.

# `profile_picture_url`

```elixir
@spec profile_picture_url(
  connection(),
  String.t(),
  BaileysEx.Feature.Profile.picture_type(),
  keyword()
) ::
  {:ok, String.t() | nil} | {:error, term()}
```

Fetch a profile picture URL.

# `queryable`

```elixir
@spec queryable(connection()) ::
  {:ok, {module(), pid()}} | {:error, :socket_not_available}
```

Return the underlying socket transport tuple used by feature modules.

# `read_messages`

```elixir
@spec read_messages(connection(), [map()], keyword()) :: :ok | {:error, term()}
```

Send read receipts for the provided message keys using current privacy settings.

# `reject_call`

```elixir
@spec reject_call(connection(), String.t(), String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Reject an inbound call.

# `remove_business_cover_photo`

```elixir
@spec remove_business_cover_photo(connection(), String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Remove the business cover photo.

# `remove_profile_picture`

```elixir
@spec remove_profile_picture(connection(), String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Remove the profile picture for yourself or a group.

# `request_pairing_code`

```elixir
@spec request_pairing_code(connection(), binary(), keyword()) ::
  {:ok, binary()} | {:error, term()}
```

Request a phone-number pairing code from the active socket.

# `send_message`

```elixir
@spec send_message(
  connection(),
  String.t() | BaileysEx.JID.t(),
  map() | struct(),
  keyword()
) ::
  {:ok, map()} | {:error, term()}
```

Send a message to a WhatsApp JID through the coordinator-managed runtime.

By default, `connect/2` builds the production Signal adapter when the auth state
includes `signed_identity_key`, `signed_pre_key`, and `registration_id`. Use
`:signal_repository` or `:signal_repository_adapter` only to override it.

# `send_presence_update`

```elixir
@spec send_presence_update(
  connection(),
  BaileysEx.Feature.Presence.presence(),
  String.t() | nil,
  keyword()
) :: :ok | {:error, term()}
```

Send an availability or chatstate update.

# `send_status`

```elixir
@spec send_status(connection(), map(), keyword()) :: {:ok, map()} | {:error, term()}
```

Send a status update through the `status@broadcast` fanout path.

By default, `connect/2` builds the production Signal adapter when the auth state
includes `signed_identity_key`, `signed_pre_key`, and `registration_id`. Use
`:signal_repository` or `:signal_repository_adapter` only to override it.

# `send_wam_buffer`

```elixir
@spec send_wam_buffer(connection(), binary() | BaileysEx.WAM.BinaryInfo.t()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Send a WAM analytics buffer or `BaileysEx.WAM.BinaryInfo` through the active socket.

# `signal_store`

```elixir
@spec signal_store(connection()) ::
  {:ok, BaileysEx.Signal.Store.t()} | {:error, :signal_store_not_available}
```

Return the wrapped Signal store for the connection when present.

# `star_messages`

```elixir
@spec star_messages(connection(), String.t(), [map()], boolean(), keyword()) ::
  :ok | {:error, term()}
```

Star or unstar one or more messages in a chat.

# `subscribe`

```elixir
@spec subscribe(connection(), (tuple() -&gt; term())) ::
  unsubscribe_fun() | {:error, :event_emitter_not_available}
```

Subscribe to friendly high-level events.

The handler receives:
- `{:connection, update}` for connection lifecycle updates
- `{:message, message}` for each incoming message
- `{:presence, update}` for presence updates
- `{:call, payload}` for call events
- `{:event, name, payload}` for all other event payloads

# `subscribe_raw`

```elixir
@spec subscribe_raw(connection(), (map() -&gt; term())) ::
  unsubscribe_fun() | {:error, :event_emitter_not_available}
```

Subscribe to raw buffered event maps.

# `update_block_status`

```elixir
@spec update_block_status(connection(), String.t(), :block | :unblock, keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Block or unblock a user.

# `update_business_cover_photo`

```elixir
@spec update_business_cover_photo(connection(), term(), keyword()) ::
  {:ok, String.t()} | {:error, term()}
```

Upload and set the business cover photo.

# `update_business_profile`

```elixir
@spec update_business_profile(connection(), map(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Update the business profile payload.

# `update_call_privacy`

```elixir
@spec update_call_privacy(connection(), atom() | String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Update call-add privacy.

# `update_default_disappearing_mode`

```elixir
@spec update_default_disappearing_mode(connection(), non_neg_integer(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Set the default disappearing-message duration in seconds.

# `update_groups_add_privacy`

```elixir
@spec update_groups_add_privacy(connection(), atom() | String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Update group-add privacy.

# `update_last_seen_privacy`

```elixir
@spec update_last_seen_privacy(connection(), atom() | String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Update last-seen privacy.

# `update_link_previews_privacy`

```elixir
@spec update_link_previews_privacy(connection(), boolean(), keyword()) ::
  :ok | {:error, term()}
```

Update the app-state privacy toggle that disables server-side link previews.

# `update_media_message`

```elixir
@spec update_media_message(connection(), web_message_info(), keyword()) ::
  {:ok, web_message_info()} | {:error, term()}
```

Request media re-upload and return the updated message with refreshed URLs.

Sends a retry request, waits for the matching `messages_media_update` event,
decrypts the response, and applies the refreshed `directPath`/`url`.

## Options

  * `:timeout` — milliseconds to wait for the media update event (default 10_000)

# `update_messages_privacy`

```elixir
@spec update_messages_privacy(connection(), atom() | String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Update who can message you.

# `update_online_privacy`

```elixir
@spec update_online_privacy(connection(), atom() | String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Update online-visibility privacy.

# `update_profile_name`

```elixir
@spec update_profile_name(connection(), String.t(), keyword()) ::
  :ok | {:error, term()}
```

Update the current account push name via app-state sync.

# `update_profile_picture`

```elixir
@spec update_profile_picture(connection(), String.t(), term(), map() | nil, keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Update the profile picture for yourself or a group.

# `update_profile_picture_privacy`

```elixir
@spec update_profile_picture_privacy(connection(), atom() | String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Update profile-picture privacy.

# `update_profile_status`

```elixir
@spec update_profile_status(connection(), String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Update the account status text.

# `update_read_receipts_privacy`

```elixir
@spec update_read_receipts_privacy(connection(), atom() | String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Update read-receipt privacy.

# `update_status_privacy`

```elixir
@spec update_status_privacy(connection(), atom() | String.t(), keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
```

Update status/story privacy.

---

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