⚡ Cloudflare Edge Network • API v1.0

Developer Documentation & API Reference

Integrate deterministic, sub-millisecond edge content moderation, chat safety, and gaming handle impersonation defense into your web apps, game servers, or mobile backends.

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.

Zero Cold-Starts • Zero Central Origin SanitiText runs with 0ms cold-start overhead and requires zero external database queries per request. Customer API keys are cryptographically hashed and cached locally in Cloudflare Edge KV across 300+ data centers worldwide.

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...
Interactive Demo Mode on sanititext.com Requests originating from 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

POST /v1/sanitize Evaluates & sanitizes text or usernames

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

GET /health Edge service availability & health probe

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 [...], decorative xX_..._Xx, underscores, dots).
  • Checks reserved staff handles (admin, mod, official, support, sanititext, system).
  • Detects Cyrillic homoglyph spoofing (e.g. replacing Latin a with Cyrillic а).
  • Returns valid_username: false with 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"
  }'

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.

GDPR Article 28 Compliant We do not store customer content to disk, do not write messages to central databases, and never use customer chat logs to train external AI models. Read our GDPR & DPA Compliance Document for details.

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.