Chat / Platform API
Current version: v3
    Chat Platform API v3
    Chat Platform API
    Chat
    Platform API
    Home
    /
    Chat
    /
    Platform API

    Overview

    With the Message search feature, you can retrieve a list of messages that contain a search term from a specific group channel. You can look for exact or partial matches to your search terms and filter search results using message properties like target_user_ids, message_ts_from, or message_ts_to. You can also use various advanced search functionalities to enhance your search results.


    Sendbird's Chat API now supports advanced search functionalities including wildcard, fuzzy search, logical operators, and synonym search for the query parameter. These operators allow the client app to create and support complicated search conditions, improving search results. You can use these functionalities by setting the advanced_query parameter to true.

    • Wildcard: Include ? or * in search terms. ? matches a single character while * can match zero or more characters. Below are query examples with a wildcard and their plausible results.

      • ab?deabcde or abbde

      • ab*deabde, abcde, or abbccdde

    Note: When wildcard is used, exact_match is ignored.

    • Fuzzy search: Add ~ at the end of search terms. Fuzzy search shows similar terms to the search term determined by a Levenshtein edit distance. If your search term is less than two characters, it returns only exact matches. If the search term has between three and five characters, only one character is edited. If the search term is longer than five characters, up to two characters are edited. Below are query examples using fuzzy search and their plausible results.

      • ab~ab

      • abcd~abcde or abcdd

      • abcdefg~abcdefgh or abcdefghi


    • Logical operators: Use AND and OR to search for more than one term. You can also use parentheses to group multiple search terms or specify target fields. If you want to look for search terms in not only the content of the message but also specified target fields of the message, such as custom type and data, you can specify the field and search term as a key-value item. Below are query examples with logical operators and their plausible results.

      • fruit AND (apple OR orange) → Messages that contain the word "fruit" and either the word "apple" or "orange" in the text.

      • (message_text:apple OR custom_type:juice) AND (message_text:orange OR custom_type:salad) → Messages that satisfy either one of the conditions in the first parenthesis and either one of the conditions in the second parenthesis.

    Note: Alwyas use uppercase for logical operators.


    Resource representation

    The properties of search results are much the same as those of messages, except for the total_count property.

    Property nameTypeDescription

    total_count

    int

    The total number of messages that contain the search term and match with all the specified parameters.


    Actions

    The following table shows a list of actions supported for message search. API endpoints are relative to the base URL allocated to your Sendbird application. In this page, the /search/messages endpoint refers to https://api-{application_id}.sendbird.com/v3/search/messages.

    Note: If you want to know the ID and base URL of your application, sign in to the Sendbird Dashboard, go to the Settings > Application > General, and then check the Application ID and API request URL.

    • It's recommended that the parameter values in API URLs be urlencoded, such as {user_id} and {channel_url}.

    List of actions

    ActionHTTP request

    Search a message

    GET /search/messages
    Retrieves a list of messages containing a specific search term.