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

    Profanity filter

    The profanity filter is designed to detect and filter out profanity words or regular expressions contained in text and file messages according to your policies and criteria. By default, the profanity filter is only applied to the messages. If you'd like to apply profanity filter for nicknames, contact our sales team.


    HTTP request

    // To apply the settings application-wide.
    PUT https://api-{application_id}.sendbird.com/v3/applications/settings_global
    
    // To apply the filter to channels with a custom channel type.
    PUT https://api-{application_id}.sendbird.com/v3/applications/settings_by_channel_custom_type/{custom_type}
    

    Parameters

    The following table lists a parameter that this action supports.

    Required
    Parameter nameTypeDescription

    custom_type

    string

    Specifies the custom channel type to apply a set of settings to a channel.


    Request body

    The following table lists the properties of an HTTP request that this action supports.

    Properties
    OptionalTypeDescription

    profanity_filter

    nested object

    Specifies a profanity filter configuration to filter out certain words and patterns that match the character combinations specified in profanity_filter.keywords[].

    profanity_filter.keywords[]

    array of strings

    Specifies an array of words to detect. A keyword that starts with an asterisk filters all words that end with the keyword including the keyword itself. A keyword that ends with an asterisk filters all words that start with the keyword including the keyword itself.

    profanity_filter.regex_filters[]

    array of objects

    Specifies an array of regular expressions to detect. Each item in the array should be specified in {"regex": "a pattern in regular expression"} format.

    profanity_filter.type

    int

    Determines which filtering method to apply to messages and nicknames that contain the specified keywords or regular expressions. Acceptable values are the following:
    - 0 (none): takes no action on matching messages. This is the default value.
    - 1 (replace): detects and replaces words that match the keywords property with asterisks.
    - 2 (block): prevents users from sending messages that contain the keywords property or match the regex_filters property.

    profanity_filter.should_check_global

    boolean

    Determines whether to apply the profanity filter of the application settings in addition to profanity_filter of the custom channel type. The default value of the property in the global settings is false. (Default: false)

    application widechannels with custom type
    {
        "profanity_filter": {
            "keywords": "ass,snatch,sperm",
            "regex_filters": [
                {
                    "regex": "[^!@#$%^&*]*(fuck|prick)[^!@#$%^&*]*"
                },
                {
                    "regex": "(http://|https://)?(casino|sex)+([-.]{1}[a-z0-9]+)*.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?"
                }
            ],
            "type": 2
        }
    }
    

    If you want to turn off the profanity filter, send a PUT request with a blank keywords property and regex_filters property as shown below:

    application widechannels with custom type
    {
        "profanity_filter": {
            "keywords": "",
            "regex_filters": []
        }
    }
    

    Response

    If successful, this action returns the updated moderation settings or channels with a custom channel type in the response body.

    In the case of an error, an error object is returned. A detailed list of error codes is available here.