Overview & Architecture
SanitiText is an enterprise edge moderation engine engineered specifically for real-time multiplayer gaming, live streaming chats, and community platforms where 200ms–500ms LLM latency is intolerable.
Unlike traditional moderation APIs that forward user data to centralized GPU clusters, SanitiText compiles linguistic rules into deterministic Aho-Corasick automata and sub-segment pattern matchers directly inside Cloudflare Workers V8 isolates. The entire evaluation completes in < 1 millisecond directly at the edge node closest to your end-user.
Base URLs & Edge Network
All requests to the SanitiText API are served over TLS 1.3 with HTTP/2 and HTTP/3 multiplexing enabled:
| Environment | Base URL | Protocol |
|---|---|---|
| Production (Global Edge) | https://api.sanititext.com |
HTTPS / HTTP/2 / HTTP/3 |
| Fallback / Alternate Edge | https://sanititext-engine.burak-kucukparmaksiz.workers.dev |
HTTPS / HTTP/2 |
Authentication & Headers
Authenticate requests by providing your API key via the standard Authorization: Bearer header or the custom x-api-key header.
# Standard Bearer Authentication (Recommended)
Authorization: Bearer st_live_a1b2c3d4e5f6...
# Alternate Header Authentication
x-api-key: st_live_a1b2c3d4e5f6...
https://sanititext.com or https://sanititext.pages.dev do not require an API key in the browser and are granted a generous 15 RPM demo quota per client IP.
Quickstart (30 Seconds)
Execute a live test request using cURL to evaluate a chat message with profanity masking enabled:
curl -X POST https://api.sanititext.com/v1/sanitize \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"text": "What a f.u.c.k.i.n.g great match!",
"mode": "chat",
"lang": "en",
"mask": true
}'
Endpoint: POST /v1/sanitize
The primary moderation gateway. Accepts an input text string along with mode configuration, executes Unicode normalization (NFKD), strips leetspeak/homoglyphs, matches against compiled language rules, and returns structured flags and sanitized text.
Request Body Parameters
| Field | Type | Status | Default | Description |
|---|---|---|---|---|
| text | string | Required | — | The raw message, chat line, or username to moderate. Maximum length: 100,000 characters. |
| mode | string | Optional | "chat" |
Moderation mode: "chat" (general conversation) or "username" (handle/tag defense). |
| lang | string | Optional | "tr" |
Target language code: "tr", "en", "nl", "de", "es", or "fr". |
| mask | boolean | Optional | true |
Whether to replace prohibited words with asterisks (*****) in sanitized_text. |
Endpoint: GET /health
Used by container orchestrators, uptime monitors (Datadog, Better Stack), and client circuit-breakers to verify edge worker routing.
// HTTP/2 200 OK
{
"status": "ok",
"service": "sanititext-edge"
}
Chat Moderation (mode: 'chat')
Optimized for live messaging, voice-chat transcripts, and in-game text channels. Preserves non-toxic sentences while cleanly isolating and masking toxic phrases, leetspeak numbers (e.g. s1k1k), and spaced punctuation evasions.
// Response for "Bu tam bir s1k1k durumudur amk" (Turkish, mode: 'chat')
{
"clean": false,
"execution_time_ms": 0,
"detected_language": "tr",
"sanitized_text": "Bu tam bir ***** durumudur ***",
"flags": [
{
"match": "s1k1k",
"canonical": "sikik",
"category": "harassment",
"severity": 3,
"technique": "aho_corasick_norm",
"range": [12, 17]
},
{
"match": "amk",
"canonical": "amk",
"category": "vulgar",
"severity": 2,
"technique": "aho_corasick_norm",
"range": [28, 31]
}
],
"metrics": {
"toxicity_score": 0.75,
"confidence": 0.98
}
}
Username Safety (mode: 'username')
Designed specifically for account registration, gamer tags, clan handles, and vanity URLs. Traditional regexes fail when players wrap toxic phrases in decorative gamer separators (e.g. xX_s1k1k_Xx) or attempt staff impersonation ([admin]_player).
When mode: "username" is specified:
- Decomposes gamer separators (brackets
[...], decorativexX_..._Xx, underscores, dots). - Checks reserved staff handles (
admin,mod,official,support,sanititext,system). - Detects Cyrillic homoglyph spoofing (e.g. replacing Latin
awith Cyrillicа). - Returns
valid_username: falsewith an array of explicit reasons ("reserved_handle","gamer_tag_separator","profanity_detected").
// Response for "[admin]_official_42" (mode: 'username')
{
"clean": false,
"execution_time_ms": 0,
"detected_language": "tr",
"sanitized_text": "[admin]_official_42",
"flags": [],
"metrics": {
"toxicity_score": 0,
"confidence": 0.98
},
"valid_username": false,
"reasons": [
"reserved_handle"
]
}
Supported Languages
SanitiText compiles native linguistic dictionaries for 6 core languages, including curated positive whitelists to eliminate the "Scunthorpe problem" (preventing words like assistance, classic, or Darmstadt from triggering false alarms):
| Flag & Language | Code | Whitelist Immunity | Key Regulatory Drivers |
|---|---|---|---|
| 🇹🇷 Turkish | tr |
113 vetted terms | High-volume gaming chat, mobile esports, Cyrillic evasion |
| 🇬🇧 English | en |
92 vetted terms | Global multiplayer gaming, North America & UK safety |
| 🇳🇱 Dutch | nl |
52 vetted terms | Benelux gaming platforms & digital community chats |
| 🇩🇪 German | de |
9 vetted terms | EU Digital Services Act (DSA) & NetzDG compliance |
| 🇪🇸 Spanish | es |
12 vetted terms | Iberian & Latin American esports, GTA RP, CS2 hubs |
| 🇫🇷 French | fr |
10 vetted terms | ARCOM regulatory standards & French digital safety laws |
Violation Categories & Severity Scoring
Every match flag includes an explicit category taxonomy and numerical severity tier to enable fine-grained automated policy enforcement (e.g. instant ban for Severity 4 vs warning for Severity 1):
| Category | Severity Tier | Policy Guidance | Examples |
|---|---|---|---|
| Hate Speech | Severity 4 | Immediate shadowban, permanent account suspension | Racial slurs, homophobic slurs, dehumanizing rhetoric |
| Sexual Insults | Severity 3–4 | Temporary mute (24h), strike escalation | Explicit non-consensual sexual terms, severe anatomical attacks |
| Harassment | Severity 2–3 | Chat masking, automated warning banner | Targeted personal attacks, leetspeak derogatory insults |
| Vulgarity / Slang | Severity 1–2 | Masking only or permitted under adult filter settings | General profanity, mild curses, casual gaming banter |
Rate Limits & Response Headers
Every response from the SanitiText edge includes RFC 9110 / RFC 6585 standard rate limit headers calculated across a 60-second sliding window:
| Header | Type | Description |
|---|---|---|
X-RateLimit-Limit |
integer | Maximum requests allowed in the 60-second window (e.g. 60, 600, 6000). |
X-RateLimit-Remaining |
integer | Requests remaining in the current rolling window. |
X-RateLimit-Reset |
integer | Unix epoch timestamp when the current sliding window resets. |
Retry-After |
integer | Seconds to wait before retrying (present only on HTTP 429). |
Server-Timing |
string | Edge isolate processing duration (e.g. sanitize;dur=0). |
HTTP Error Codes
SanitiText uses conventional HTTP status codes to indicate the success or failure of requests:
| Status Code | Meaning | Resolution |
|---|---|---|
| 200 OK | Success | Request evaluated successfully. Inspect clean and flags. |
| 400 Bad Request | Invalid Payload | Missing text parameter, non-JSON body, or unsupported mode. |
| 401 Unauthorized | Missing Key | API key missing from Authorization or x-api-key headers. |
| 403 Forbidden | Revoked Key | API key is disabled or revoked in Cloudflare KV. Contact support. |
| 405 Method Not Allowed | Wrong HTTP Verb | Route requires POST (or GET for /health). |
| 413 Payload Too Large | Exceeded Bounds | Input text payload exceeds 100,000 characters. |
| 429 Too Many Requests | Rate Limit Exceeded | Exceeded tier RPM quota. Back off per Retry-After header or upgrade tier. |
Client Libraries & Code Samples
Copy and paste production-ready integration code in your preferred runtime:
curl -X POST https://api.sanititext.com/v1/sanitize \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"text": "Check out this gaming handle: xX_s1k1k_Xx",
"mode": "username",
"lang": "tr"
}'
import fetch from 'node-fetch';
interface SanitizeResponse {
clean: boolean;
sanitized_text: string;
execution_time_ms: number;
valid_username?: boolean;
reasons?: string[];
flags: Array<{
match: string;
canonical: string;
category: string;
severity: number;
}>;
}
async function moderateMessage(text: string): Promise<SanitizeResponse> {
const res = await fetch('https://api.sanititext.com/v1/sanitize', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.SANITITEXT_API_KEY}`,
},
body: JSON.stringify({
text,
mode: 'chat',
lang: 'en',
mask: true,
}),
});
if (!res.ok) {
throw new Error(`SanitiText API error: ${res.status}`);
}
return res.json() as Promise<SanitizeResponse>;
}
import os
import requests
def sanitize_chat(message: str) -> dict:
url = "https://api.sanititext.com/v1/sanitize"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('SANITITEXT_API_KEY')}"
}
payload = {
"text": message,
"mode": "chat",
"lang": "en",
"mask": True
}
response = requests.post(url, json=payload, headers=headers, timeout=2.0)
response.raise_for_status()
return response.json()
result = sanitize_chat("What a toxic message!")
print(f"Clean: {result['clean']}, Masked: {result['sanitized_text']}")
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
"time"
)
type SanitizeRequest struct {
Text string `json:"text"`
Mode string `json:"mode"`
Lang string `json:"lang"`
Mask bool `json:"mask"`
}
func main() {
client := &http.Client{Timeout: 2 * time.Second}
payload, _ := json.Marshal(SanitizeRequest{
Text: "pro_player_42",
Mode: "username",
Lang: "en",
Mask: true,
})
req, _ := http.NewRequest("POST", "https://api.sanititext.com/v1/sanitize", bytes.NewBuffer(payload))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("SANITITEXT_API_KEY"))
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.StatusCode)
}
using System;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Networking;
public class SanitiTextService : MonoBehaviour {
private const string API_URL = "https://api.sanititext.com/v1/sanitize";
private string apiKey = "YOUR_API_KEY";
[Serializable]
public class SanitizeRequest {
public string text;
public string mode;
public string lang;
public bool mask;
}
public async Task<string> ModerateAsync(string input) {
var payload = new SanitizeRequest { text = input, mode = "chat", lang = "en", mask = true };
string json = JsonUtility.ToJson(payload);
using (UnityWebRequest req = new UnityWebRequest(API_URL, "POST")) {
byte[] bodyRaw = Encoding.UTF8.GetBytes(json);
req.uploadHandler = new UploadHandlerRaw(bodyRaw);
req.downloadHandler = new DownloadHandlerBuffer();
req.SetRequestHeader("Content-Type", "application/json");
req.SetRequestHeader("Authorization", "Bearer " + apiKey);
var op = req.SendWebRequest();
while (!op.isDone) await Task.Yield();
if (req.result != UnityWebRequest.Result.Success) {
Debug.LogError("SanitiText error: " + req.error);
return input;
}
return req.downloadHandler.text;
}
}
}
Zero Data Retention (ZDR) & Privacy
SanitiText operates under a strict Zero Data Retention architecture. Text payloads, usernames, and chat transcripts evaluate exclusively in ephemeral Cloudflare V8 worker isolate RAM and are immediately garbage collected upon HTTP response termination.
Sub-Millisecond Performance Tips
- Keep-Alive Connections: Enable HTTP Keep-Alive / connection pooling on your client backends to reuse established TLS sessions with Cloudflare edge PoPs.
- HTTP/2 or HTTP/3 Multiplexing: Utilize HTTP/2 or HTTP/3 to send concurrent chat lines over a single TCP/QUIC stream without head-of-line blocking.
- Local Edge Routing: Because SanitiText runs in 300+ data centers, deploying your game servers or chat workers in proximity to major cloud hubs guarantees single-digit millisecond latency end-to-end.