Filters

Filters let you block or flag content based on specific words, domains, emails, or regex patterns. To use filters in moderation, you first create a blocklist, then attach it to a moderation policy.

Create a Blocklist

Create a custom blocklist with a name, type, and list of entries.

// Create a word blocklist
client.CreateBlockList(ctx, &getstream.CreateBlockListRequest{
    Name:  "profanity_custom",
    Words: []string{"badword1", "badword2", "offensive"},
    Type:  getstream.PtrTo("word"),
})

// Create a domain blocklist
client.CreateBlockList(ctx, &getstream.CreateBlockListRequest{
    Name:  "blocked_domains",
    Words: []string{"spam-site.com", "phishing.net"},
    Type:  getstream.PtrTo("domain"),
})

// Create a regex filter
client.CreateBlockList(ctx, &getstream.CreateBlockListRequest{
    Name:  "phone_numbers",
    Words: []string{`\b\d{3}[-.]?\d{3}[-.]?\d{4}\b`},
    Type:  getstream.PtrTo("regex"),
})

// Create a domain allowlist (only these domains are permitted)
client.CreateBlockList(ctx, &getstream.CreateBlockListRequest{
    Name:  "trusted_domains",
    Words: []string{"myapp.com", "getstream.io"},
    Type:  getstream.PtrTo("domain_allowlist"),
})

// Create an email allowlist
client.CreateBlockList(ctx, &getstream.CreateBlockListRequest{
    Name:  "approved_emails",
    Words: []string{"support@myapp.com", "info@myapp.com"},
    Type:  getstream.PtrTo("email_allowlist"),
})

Request Parameters

keyrequiredtypedescription
nametruestringUnique name for the blocklist (max 255 characters).
wordstruearrayList of words, domains, emails, or regex patterns (max 10,000 entries).
typefalsestringFilter type: word (default), domain, domain_allowlist, email, email_allowlist, or regex.
is_leet_check_enabledfalsebooleanDetect leet speak bypass attempts (e.g., h4ck3rhacker). Word type only.
is_plural_check_enabledfalsebooleanDetect singular/plural forms (e.g., cat matches cats). Word type only.
teamfalsestringTeam ID for multi-tenant blocklists.

Update a Blocklist

Replace the word list or settings of an existing blocklist.

client.UpdateBlockList(ctx, "profanity_custom", &getstream.UpdateBlockListRequest{
    Words:                []string{"badword1", "badword2", "offensive", "newword"},
    IsLeetCheckEnabled:   getstream.PtrTo(true),
    IsPluralCheckEnabled: getstream.PtrTo(true),
})

List Blocklists

response, err := client.ListBlockLists(ctx, &getstream.ListBlockListsRequest{})

Get a Blocklist

response, err := client.GetBlockList(ctx, "profanity_custom", &getstream.GetBlockListRequest{})

Delete a Blocklist

client.DeleteBlockList(ctx, "profanity_custom", &getstream.DeleteBlockListRequest{})

Attach a Blocklist to a Policy

Once created, attach your blocklist to a moderation policy to activate it. Each rule specifies the blocklist name and the action to take when matched.

client.Moderation().UpsertConfig(ctx, &getstream.UpsertConfigRequest{
    Key: "chat:messaging",
    BlockListConfig: &getstream.BlockListConfig{
        Rules: []getstream.BlockListRule{
            {Name: "profanity_custom", Action: "remove"},
            {Name: "blocked_domains", Action: "flag"},
            {Name: "phone_numbers", Action: "flag"},
        },
    },
})

Filter Types

Typetype valueDescription
Word BlocklistwordExact word matching (case-insensitive). Supports leet speak and plural detection.
Domain BlocklistdomainBlocks URLs by domain suffix matching. Ignores scheme and path.
Domain Allowlistdomain_allowlistOnly allows URLs from listed domains. Blocks everything else.
Email BlocklistemailBlocks exact email addresses.
Email Allowlistemail_allowlistOnly allows listed email addresses. Blocks everything else.
RegexregexPattern matching with regular expressions. Max 100 patterns per filter.

Word Matching

Word blocklists match exact words (case-insensitive). Adjacent punctuation is ignored, but partial word matches are not.

For a blocklist containing dogs, house:

  • "Dogs, are great" — matches (case-insensitive, ignores comma)
  • "I live in a lighthouse" — does not match (no partial match on house)

With leet speak detection enabled: d0g matches dog, w0m@n matches woman. With plural detection enabled: houses matches house, dog matches dogs.

Domain Matching

Domain filters match the suffix of URLs. gmail.com matches https://gmail.com, http://support.gmail.com, etc. A more specific filter like messenger.facebook.com only matches that subdomain.

Regex Matching

Regex filters support standard regular expression syntax. Tips:

  • Use (?i) for case-insensitive matching
  • Use \b for whole-word boundaries
  • Escape special characters with \
  • Max 100 patterns per filter, max 60 characters per pattern

Limits

LimitValue
Max blocklists per app20 (100 with multi-tenancy)
Max words per blocklist10,000
Max regex patterns per blocklist100
Max characters per word40
Max characters per regex pattern60