# Better Messages - REST API Reference > REST API endpoints for the Better Messages WordPress plugin. This file contains all documentation content in a single document following the llmstxt.org standard. ## Add participant Adds one or more users to a conversation. The current user must have invite permission for the thread (controlled by the `can_invite()` function and `allow_invite` thread setting). Users who are already participants are skipped. Returns an error if no valid additions can be made. Request --- ## Ban user from thread Bans a user from a thread — removes them as a participant and prevents them from rejoining. Requires moderator permission. The ban automatically expires after the given number of minutes. The user is immediately removed from the thread upon banning. Request --- ## Better Messages REST API The Better Messages REST API exposes every messenger operation — creating conversations, sending messages, managing participants, moderation, friend lists, settings, voice messages, file attachments, and more — over a standard WordPress REST API namespace. It powers both the official Better Messages JavaScript client and the iOS / Android mobile apps, and you can use it directly to build integrations, bots, mobile clients, sync workers, or any external service that needs to read or write messenger data. **Base URL:** `https://your-site.com/wp-json/better-messages/v1` All routes are rooted at the `/wp-json/better-messages/v1` namespace and follow standard WordPress REST API conventions. **Authentication:** Most endpoints require an authenticated WordPress user. Three authentication methods are supported: - **Cookie authentication** — the default for browser-based requests. Send the standard WordPress nonce header (`X-WP-Nonce`). - **Application passwords** — for server-to-server or external integrations. Use HTTP Basic auth with the username and an application password (WordPress 5.6+). - **Custom authentication** — override the auth check via the `better_messages_rest_is_user_authorized` PHP filter. Useful for bridging JWT, OAuth, or custom tokens. **Guest authentication** — for sites with Guest Chat enabled, unauthenticated visitors can interact with the messenger using two HTTP headers: `BM-Guest-ID` (positive guest database id) and `BM-Guest-Secret` (30-character token returned during guest registration). Guests are identified internally as **negative integer user IDs** so they don't collide with real WordPress users. **Authorization** — endpoint access depends on user capabilities, thread participation, plugin settings, and any custom `better_messages_capabilities` filter logic. A request that is authenticated but not authorized for a specific thread or action returns `403 Forbidden`. Endpoints marked **Public** in their tag description do not require authentication at all. **Response format** — all endpoints return JSON. Errors follow the WordPress REST API envelope (`{ code, message, data: { status } }`). Successful responses return the requested resource directly without wrapping. **Rate limiting** — the API imposes no HTTP-level rate limits or quotas, so polling and read traffic are bounded only by your own server capacity. The optional per-role sending limits in the plugin settings (a cooldown between new conversations, and a cap on replies per hour or per day) apply when a message is sent. They are not signalled with `429` — a rejected send returns `200 OK` with `result: false` and an `errors` object naming the reason. Contact [support@better-messages.com](mailto:support@better-messages.com) URL: [https://www.better-messages.com](https://www.better-messages.com) --- ## Block user Blocks a user from sending messages to the current user. Blocked users cannot start new conversations or send messages in existing conversations with the blocker. Users cannot block themselves or administrators. Role-based restrictions and immunity rules are applied via the `restrictBlockUsers` and `restrictBlockUsersImmun` settings. Request --- ## Calls Private and group voice/video calling (WebSocket version only) ```mdx-code-block ``` --- ## Change thread metadata Updates a metadata value on a thread. Only thread super-moderators can change metadata. The `allow_invite` key is handled specially — it updates the thread setting directly and triggers info change notifications. All other keys are processed via the `better_messages_change_thread_meta` action hook. Request --- ## Change thread subject Updates the subject/title of a conversation thread. Only thread super-moderators (admins, thread creators in group contexts) can change the subject. The subject is sanitized and filtered through the `better_messages_change_subject_content` hook before saving. Request --- ## Chat Rooms Join and leave public or semi-public chat rooms ```mdx-code-block ``` --- ## Check for new messages Polls for new messages and thread updates since the client's last check. This is the primary polling endpoint used in AJAX mode (when WebSocket is not available). Returns delta updates including new messages, updated threads, deleted threads and messages. Also marks visible threads as read. When lastUpdate is 0, returns initial thread data instead of delta. Request --- ## Clear all messages Deletes all messages from a thread in batches of 50. Resets unread counts and read timestamps for all participants. Requires the `bm_can_administrate` capability or moderator permission. This is a destructive operation — all message content and attachments are permanently removed. Request --- ## Conversation Settings Subject, metadata, mute, and pin settings for conversations ```mdx-code-block ``` --- ## Conversations Create, retrieve, delete, and restore conversation threads ```mdx-code-block ``` --- ## Create call room Creates a call message in a conversation and generates a room token. Used for multi-participant conversations. The call message is stored with `bpbm_call` metadata. Returns tokens and participant data needed to establish the call. Requires WebSocket version. Request --- ## Delete messages Deletes specific messages from a thread. Only the message sender can delete their own messages. Thread moderators can delete messages from non-moderators, and super-moderators can delete any message except those from other super-moderators. The delete method (hard delete vs. content replacement) is controlled by the plugin's `deleteMessageMethod` setting. When using the replacement method, the response includes updated message objects. Request --- ## Delete push subscription Removes a web push notification subscription for the current user. Typically called when the user disables push notifications or the browser subscription is invalidated. Request --- ## Delete thread Archives a thread for the current user by soft-deleting it. The thread is hidden from the user's conversation list but not permanently removed from the database. Other participants can still see the conversation. Deletion can be restricted via the `restrictThreadsDeleting` plugin setting — when enabled, only administrators can delete threads. The `bp_better_messages_can_delete_thread` filter allows custom permission logic. Request --- ## Edit message Edits an existing message with new content. Only the original sender can edit their messages, and the `allowEditMessages` setting must be enabled. Forwarded messages cannot be edited. The edit preserves any file attachments from the original message. A history of previous versions is saved internally for audit purposes. The response includes the updated message object. Request --- ## Email unsubscribe Unsubscribes a user from email notifications using a verification token. The token is generated per-user and included in email notification footers. **Public endpoint** — does not require authentication. Request --- ## Erase thread permanently Permanently and irreversibly deletes a thread along with all messages, metadata, and participant records. Requires the `bm_can_administrate` capability. Unlike clearing messages, this removes the thread entry itself from the database. Use with extreme caution. Request --- ## Forward message Forwards a message to one or more destination threads. The forwarding feature must be enabled in plugin settings (`enableForwardMessages`). Attachments and voice messages are copied to each destination. Forward attribution tracks the original sender when enabled. The user must have reply access in each destination thread. Limited to a maximum of 20 destination threads per forward operation. Deleted messages and messages the user doesn't have access to cannot be forwarded. Request --- ## Get bad words list Returns the configured bad words block list for client-side content filtering. The bad words feature must be enabled in plugin settings. Used by the frontend to prevent sending messages containing blocked words before they reach the server. --- ## Get conversation suggestions Returns user suggestions for the new conversation screen with optional search filtering. When a threadId is provided, excludes users already participating in that thread. Respects the `disableUsersSearch` setting. Returns up to 50 user profiles (configurable via filter). AI bots are hidden from suggestions in E2E encrypted thread contexts. Request --- ## Get emoji data Returns the emoji dataset for the emoji picker UI, including all categories and individual emoji data. The dataset can be customized via the `better_messages_get_emoji_dataset` filter. **Public endpoint** — does not require authentication. --- ## Get favorited messages Returns all messages starred by the current user across all conversations. Only returns messages the user still has access to. The `disableFavoriteMessages` setting must not be enabled. --- ## Get friends list Returns the current user's friends list. This endpoint is entirely filter-driven — the default returns an empty array. BuddyPress, BuddyBoss, and other social plugins hook into the `better_messages_get_friends` filter to provide actual friend data. --- ## Get groups Returns groups the current user belongs to. Like getFriends, this endpoint is filter-driven — the default returns an empty array. BuddyPress, PeepSo, and other group plugins hook into the `better_messages_get_groups` filter to provide group data. --- ## Get @mention suggestions Returns thread participants matching a search query for the @mention autocomplete feature. Searches display_name and user_nicename fields. Excludes the current user and deleted recipients. Returns up to 50 unique user IDs. Request --- ## Get or create private thread Gets an existing private 1-on-1 conversation with a specific user, or creates one if it doesn't exist. Supports unique conversation keys for context-specific conversations (e.g., per-product discussions). When a unique key is provided, the endpoint uses `get_unique_pm_thread_id()` instead of the standard PM lookup. Returns full thread data including messages and participants when a thread is found or created. Request --- ## Get report reasons Returns available report reason categories for a specific message. Also checks whether the current user has already reported this message — returns an error if they have. The default categories are inappropriate, spam, harassment, offensive, and other, but they can be customized via the `better_messages_get_report_reasons` filter. Request --- ## Get sticker pack Returns all stickers from a specific sticker pack for display in the sticker picker. Request --- ## Get sticker packs Returns the list of available sticker packs configured in the plugin. Each pack includes a preview image and sticker count. --- ## Get thread attachments Returns all file attachments shared in a conversation thread. Includes images, documents, videos, and other files sent as message attachments. Request --- ## Get thread details Returns a specific thread with its newest 80 messages and participant data. Older messages come from `/thread/{id}/loadMore`. Automatically marks the thread as read for the current user. For chat room threads, auto-add users are synced on access. The endpoint also detects messages that have been deleted since the client's last load by comparing the provided loaded message IDs against the database. Request --- ## Get threads for forwarding Returns a list of threads suitable for the message forwarding picker UI. Supports search filtering by thread subject or participant names. Excludes threads with `exclude_from_threads_list` metadata and creator-only threads. Returns up to 20 threads with participant data, images, and pin status. The forwarding feature must be enabled in plugin settings. Request --- ## Get threads list (POST) Same as GET /threads but accepts POST body for parameters. Useful when the exclude list is large and would exceed URL length limits. Request --- ## Get threads list Returns the current user's conversation list with recent messages and participant data. Threads are ordered by last activity. Deleted threads and threads without messages (except chat rooms and groups) are automatically excluded. Administrators can see pending messages from all users, while regular users only see their own pending messages. Request --- ## Get unique conversation Gets or creates a conversation identified by a unique key string. The actual thread resolution is handled by addon filters — the core plugin fires `better_messages_get_unique_conversation` filter and returns the resolved thread. This is commonly used for E2E encryption rooms and context-specific conversations. **Public endpoint** — does not require authentication. Request --- ## Get user settings Returns the current user's configurable messaging preferences. Available settings are dynamic and depend on plugin configuration — they may include email notifications, sound notifications, who can start conversations, and online status visibility. Each setting includes its current value, available options, and display labels. --- ## Get user suggestions Returns suggested users for starting new conversations. Prioritizes friends (up to 12), then falls back to other users. Respects friends-only and followers-only messaging modes. Can be overridden via the `better_messages_predefined_suggestions_user_ids` filter. Administrators bypass friends-only restrictions. --- ## Get users list Returns a page of the members the Users widget lists, excluding the current user, following the widget's settings: display mode (all members, by role or hand-picked), sort order and search. The route also answers GET with the same parameters. It answers only a viewer the Users widget is shown to: one of the mini widget bar, side panel or mobile tab bar has the Users tab on and its role restriction does not hide it from the viewer. A visitor who is not logged in, or a guest, also needs guest chat on. Anyone else gets 401 (not logged in) or 403. Request --- ## Guests Guest (non-registered) user registration and profile management ```mdx-code-block ``` --- ## Health check Simple health check endpoint that returns "pong" to verify the REST API is responding. **Public endpoint** — does not require authentication. --- ## Join call Joins an existing active call session. The message must have `bpbm_call` metadata indicating an active call. Returns a room token and encryption key for the user to connect. The user must be a participant of the conversation. Requires WebSocket version. Request --- ## Join chat room Adds the current user as a participant in a chat room. Access is validated against the room's role-based permissions via the `user_can_join()` method and `better_messages_chat_user_can_join` filter. After joining, returns the updated thread data for the chat room. Request --- ## Lazy load data Lazy-loads user profiles and message data by IDs for efficient on-demand data fetching. Used when the client encounters references to users or messages not yet in its local cache. Validates that the current user has access to the thread containing each requested message before returning it. Messages are returned with full formatting, favorite status, and metadata. Request --- ## Leave chat room Removes the current user from a chat room. Users cannot leave chat rooms that have auto_join enabled — in that case, the endpoint returns an error. After leaving, the user no longer receives messages or notifications for the room. Request --- ## Leave thread Removes the current user from a group conversation. The user will no longer receive messages or notifications for this thread. A single moderator cannot leave a thread — another moderator must be assigned first. The `can_leave()` function validates whether the user is allowed to leave. Request --- ## Lift call ban Lifts a ban from the conversation's group calls (Better Messages 3.2), the ban a moderator gives with **Remove and Ban from Calls** in a group call (`/groupCallAdmin` with `act` `ban_participant`). The user may join the calls of the conversation again at once. A ban from the conversation itself is lifted separately with `/thread/{id}/unbanUser`. Requires moderator permission in the conversation. Fires the `better_messages_user_unrestricted` action with the type `call_ban` when a ban was lifted. For its moderators, a conversation object lists the users banned from calls in `restricted.call_ban`, beside `ban` and `mute`, each user ID with the end of the restriction as a Unix time. Since 3.2 the `restricted` lists come with group conversations, integration groups and courses as well as chat rooms. Request --- ## Load more messages Loads additional messages for a thread, supporting both backward pagination (loading older messages) and forward range loading (loading messages up to a specific point). Also detects and returns any missed messages not in the client's loaded set. Returns up to 80 messages per request. The `mode` parameter controls the loading direction. Request --- ## Make moderator Promotes a thread participant to moderator status. For chat rooms, only WordPress administrators can promote moderators. For regular threads, the current user must be a super-moderator. The target user must already be a participant of the thread. Request --- ## Mark all as read Marks all conversations as read for the current user. Updates unread_count to 0 and sets last_read and last_delivered timestamps for every thread the user participates in. Fires the `better_messages_mark_all_read` action hook. --- ## Mark conversation as unread Marks a conversation the current user has read as unread again (Better Messages 3.2). The `unread_count` of the user for it becomes `-1`: the conversation shows a dot in the conversations list and is listed by the unread filter, while no unread total counts it (`get_user_unread_count()`, the conversations count, the totals of the realtime server and the mobile app badge). The mark ends when the user opens the conversation (`messages_mark_thread_read()`, `/openThreads`, `/markAllRead`) or when a new message arrives, which counts from 0. A deleted message keeps it. Nobody is notified. The route takes the word of the caller that the conversation was read: it writes `-1` whatever count the site holds, since in the WebSocket version the count the site keeps for a conversation read through the realtime connection catches up only at the next sync. The messenger offers the action only on a conversation it shows read. On the WebSocket version the mark reaches the other devices of the user through the realtime server. Conversation objects carry `unread: -1` for a marked conversation (REST, the `better_messages_rest_thread_item` filter and realtime events). Fires `better_messages_thread_marked_unread` with the thread ID and the user ID. Refused with 403 when **Settings → Messaging → Conversation Features → Mark as Unread** is off, in a presence-based chat room, and for a user who is not a participant. Request --- ## Mark threads as read Marks specific threads as read for the current user. Calls `messages_mark_thread_read()` for each provided thread ID, which resets unread counts and updates read timestamps. Request --- ## Media File attachments, sticker packs, and GIPHY integration ```mdx-code-block ``` --- ## Message Actions Emoji reactions, starred/favorite messages, and pinned messages ```mdx-code-block ``` --- ## Messages Send, edit, delete, and forward messages within conversations ```mdx-code-block ``` --- ## Moderate group call Runs a moderator action in a group call, chosen with `act`. Moderators of the conversation may use every action, everyone else only `raise_hand` and `lower_own_hand`. Participants are named by their call identity, `user_` and the user ID (`user_-5` for a guest). Requires WebSocket version. The actions: - `lock_room`, `unlock_room`: keep everyone but moderators from joining, or let them join again - `set_broadcast_mode`, `set_participatory_mode`: switch the call between broadcast and participatory mode - `mute_all`, `unmute_all`: mute or unmute everyone's microphone, or with `identities` only the people listed - `end_call` (3.2): end the call for everyone, taking out the people in `identities` - `remove_participant`: take `identity` out of the call. They can join again. - `ban_participant` (3.2): Remove and Ban from Calls. Takes `identity` out of the call and keeps them from the conversation's calls for `duration` minutes, and with `chat` also bans them from the conversation where that is offered (`canBanFromChat` of `/groupCallStart`: group conversations and chat rooms). Answers with the updated thread data. Lift the ban with `/thread/{id}/callUnbanUser`. - `mute_participant`, `unmute_participant`: stop `identity` from sending audio and video, or let them again - `mute_mic`, `unmute_mic`: mute or unmute the microphone of `identity` - `promote_participant`, `demote_participant`: in broadcast mode, let `identity` speak and show video, or make them a viewer again - `pin_participant`, `unpin_participant`: pin `identity` in the call, or unpin them - `spotlight_participant`, `unspotlight_participant` (3.2): put `identity` in the spotlight for everyone, up to four people, or take them out of it - `ask_camera`, `ask_microphone`, `ask_camera_microphone` (3.2): ask `identity` to turn on their camera, their microphone, or both in one ask. Once in 30 seconds for each moderator, person and device, and never yourself. Answers `{ "asked": true }`. - `raise_hand`, `lower_own_hand`: raise or lower your own hand - `lower_hand`: lower the hand of `identity` Request --- ## Moderation Block users, mute/ban users in threads, and report messages ```mdx-code-block ``` --- ## Mute thread Mutes notifications for a thread. The current user will no longer receive push notifications, browser notifications, or email notifications for new messages in this thread. The mute state is stored per-user in the recipients table. Fires thread update actions so other tabs/devices reflect the change. Request --- ## Mute user in thread Mutes a user within a specific thread, preventing them from sending messages for a duration. Requires moderator permission in the thread. The target user must be a current participant. The mute automatically expires after the given number of minutes. Request --- ## Participants Add, remove, promote, and search thread members ```mdx-code-block ``` --- ## Pin conversation Pins a conversation to the top of the current user's thread list. Pinned conversations always appear above unpinned ones regardless of last activity time. The pin state is stored per-user in the recipients table. Request --- ## Pin message Pins a message to a thread. Only one message can be pinned per thread at a time — pinning a new message automatically unpins the previous one. Requires the `can_pin_messages` permission (controlled by the `better_messages_can_pin_messages` filter). The message must exist and belong to the specified thread. Request --- ## Register guest Registers a new anonymous guest user for chat. Guest access must be enabled in plugin settings. The user must not be logged in. A display name is auto-generated using an alliterative name generator if not provided. The generated name must be unique. Returns the guest's credentials (ID and secret token) along with WebSocket profile data for real-time connectivity. **Public endpoint** — does not require authentication. Request --- ## Remove moderator Removes moderator status from a thread participant. For chat rooms, only WordPress administrators can demote moderators. For regular threads, the current user must be a super-moderator. The target user remains a regular participant after demotion. Request --- ## Remove participant Removes a user from a conversation. The current user must be a super-moderator or thread moderator. Moderators cannot remove super-moderators unless the requester is also a super-moderator. The removed user loses access to the conversation and stops receiving notifications. Request --- ## Report message Reports a message for moderator review. Each user can only report a specific message once. Users cannot report their own messages. The report category must be one of the allowed categories (default: inappropriate, spam, harassment, offensive, other — customizable via the `better_messages_get_report_reasons` filter). The description is limited to 500 characters by default (customizable via filter). Request --- ## Restore thread Restores a previously archived/deleted thread back to the user's conversation list. Sets the is_deleted flag to 0 and updates the last_update timestamp. Subject to the same permission restrictions as thread deletion. Request --- ## Save push subscription Saves a web push notification subscription for the current user. The subscription data should contain the browser push API endpoint and encryption keys. Subscriptions are stored in user meta and used for sending push notifications when new messages arrive. Request --- ## Save user settings Updates a single user preference. Supported options include `email_notifications`, `who_can_start_conversations`, `sound_notifications`, and `online_status`. Values are typically 'yes' or 'no'. The online_status option additionally triggers a WebSocket profile update and returns the full updated user item when WebSocket is enabled. Request --- ## Search GIFs Searches for animated GIFs via the GIPHY integration. The GIPHY feature must be enabled and a valid API key must be configured in plugin settings. Request --- ## Search participants Searches for participants within a specific thread by display name or username. Returns matching user IDs excluding the current user and deleted recipients. Request --- ## Search Comprehensive search across users, friends, and message content. User search can be disabled via the `disableUsersSearch` plugin setting. Results are separated into friend matches and non-friend matches. Message search returns thread IDs with match counts (limited to 10 results). The response includes full thread and user data for rendering search results. Request --- ## Send message Sends a message to a conversation thread. The current user must have reply access. Supports file attachments, message metadata, and offline message sync via temporary IDs. If moderation is enabled, the message enters a pending queue instead of being delivered immediately. The temp_id and temp_time parameters enable offline-first messaging — the server validates that temp_time is within ±600 seconds of server time. After sending, the thread is automatically marked as read for the sender. Request --- ## Settings & Notifications User messaging preferences and push notification subscriptions ```mdx-code-block ``` --- ## Start group call Starts or joins a group voice/video call in a thread. The response includes a room token and the current call mode (participatory or broadcast). In broadcast mode, non-moderators receive a receive-only token. Moderators can lock the room, mute participants, and switch between participatory and broadcast modes via the group call admin endpoint (`/groupCallAdmin`). Requires WebSocket version. Since 3.2 a person banned from the conversation's calls, or from a chat room, is refused with a 403 that says until when, and the answer also carries `canPublish`, `micMuted`, the call's `recording` and, for moderators, `canBanFromChat`. A call that cannot take more people is refused with `group_call_full`. The `better_messages_group_call_join_custom_error` filter can refuse with a message of its own. Request --- ## Start new conversation Creates a new conversation thread and sends the first message. Recipients are validated against plugin restrictions (friends-only mode, blocking, etc.). If message moderation is enabled, the message will be placed in a pending queue for admin approval. Supports file attachments and E2E encryption addon integration. Returns an error with detailed messages if the conversation cannot be created. Request --- ## Start private call Initiates a private 1-on-1 voice or video call. Can auto-create a conversation thread if thread_id is 0 or not provided. Only works for conversations with exactly 2 participants. The user must have reply permission in the conversation. Returns a room token and encryption key for establishing the call connection. Fires the `better_messages_call_created` action hook. Requires WebSocket version. Request --- ## Suggest thread for recipients Checks if a conversation can be started with the given recipients. When a single recipient is specified without the forceNew flag, it looks for an existing PM thread and returns its ID. Otherwise, it validates whether the current user has permission to start a new conversation with the specified recipients. Request --- ## Toggle favorite Stars or unstars a message for the current user. Starred messages can be retrieved later via the getFavorited endpoint. The `disableFavoriteMessages` setting must not be enabled. The operation is idempotent — starring an already-starred message still returns success. Request --- ## Toggle reaction Adds or removes an emoji reaction on a message. If the user has already reacted with the same emoji, it is removed (toggle behavior). Users cannot react to their own messages. The emoji must be in the configured reactions list. Returns the updated message with all current reactions. Request --- ## Unban user from thread Removes a ban restriction from a user, allowing them to rejoin the thread. Requires moderator permission. Note that unbanning does not automatically re-add the user as a participant — they must rejoin or be re-invited. Request --- ## Unblock user Removes a block on a previously blocked user, allowing them to send messages again. The user must have been blocked first. Request --- ## Unmute thread Restores notifications for a previously muted thread. The user will receive notifications for new messages again. Fires thread update actions for real-time sync. Request --- ## Unmute user in thread Removes a mute restriction from a user in a thread, allowing them to send messages again. Requires moderator permission. Request --- ## Unpin conversation Removes a conversation from the user's pinned list. The conversation returns to its normal position based on last activity time. Request --- ## Unpin message Removes the pinned message from a thread. Requires the `can_pin_messages` permission. After unpinning, no message will be pinned in the thread until a new one is explicitly pinned. Request --- ## Update guest profile Updates a guest user's display name. The current user must be authenticated as a guest (negative user ID). The new name must be unique among all guests. Returns updated credentials and WebSocket profile data. Request --- ## Users & Search User suggestions, friends, groups, and search across users and messages ```mdx-code-block ``` --- ## Utility Health checks, emoji data, lazy loading, and miscellaneous endpoints ```mdx-code-block ```