Chat / Platform API
    Chat Platform API v3
    Chat Platform API
    Chat
    Platform API
    Version 3
    Home
    /
    Chat
    /
    Platform API
    /
    Message

    Overview

    Copy link

    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 Chat API 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.

    Note: When using advanced search, exact_match can't be set 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


    • 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, only exact matches are returned. 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. The logical operators must be in uppercase. 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 or 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 set of parentheses and either one of the conditions in the second set of parentheses.


    Resource representation

    Copy link

    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

    Copy link

    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 Sendbird Dashboard, go to Settings > Application > General, and then check Application ID and API request URL.

    List of actions

    Copy link
    ActionHTTP request

    Search messages

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