Skip to main content
POST
/
v1
/
moderate
Moderate Content
curl --request POST \
  --url https://api.trynawa.com/v1/moderate
Dialect-aware Arabic content moderation powered by ALLaM. Understands profanity, slang, and offensive language differences across Gulf, Egyptian, Levantine, and MSA Arabic — catching what Western moderation APIs miss entirely.
Cost: $0.004 per request (4 credits). Semantic cache hits are free (X-NAWA-Cache: HIT).

Request

Headers

HeaderRequiredDescription
AuthorizationYesBearer nawa_live_sk_xxx or Bearer nawa_test_sk_xxx
Content-TypeYesapplication/json

Body parameters

ParameterTypeRequiredDescription
textstringYesThe text to moderate. Max 5,000 characters.
contextstringNoWhere the text appears (e.g. “youtube comment”, “product review”). Helps the model calibrate.
strictnessstringNoModeration strictness: low, medium, high. Default: medium.
platformstringNoSource platform: youtube, instagram, twitter, facebook.
Strictness levels:
  • low — only flag severe content (explicit hate speech, extreme profanity, direct threats)
  • medium — flag moderate and severe content (profanity, harassment, hate speech, spam)
  • high — flag all potentially problematic content (mild profanity, borderline content, subtle insults)

Example request

curl -X POST https://api.trynawa.com/v1/moderate \
  -H "Authorization: Bearer nawa_test_sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "هذا محتوى رائع جدا",
    "strictness": "medium"
  }'

Response

Safe content (200)

{
  "success": true,
  "result": {
    "id": "mod_nw_pon1yom9bkfe",
    "object": "moderation",
    "text": "هذا محتوى رائع جدا",
    "is_safe": true,
    "verdict": "safe",
    "flags": [],
    "severity": "none",
    "severity_score": 0.0,
    "language": "ar",
    "dialect": "gulf",
    "categories": {
      "profanity": false,
      "hate_speech": false,
      "harassment": false,
      "sexual": false,
      "spam": false,
      "self_harm": false,
      "violence": false
    },
    "category_scores": {
      "profanity": 0.01,
      "hate_speech": 0.00,
      "harassment": 0.02,
      "sexual": 0.00,
      "spam": 0.05,
      "self_harm": 0.00,
      "violence": 0.01
    },
    "flagged_terms": [],
    "cleaned_text": null,
    "model": "nagl-v1",
    "provider": "allam",
    "fallback_used": false,
    "cached": false,
    "cost_usd": 0.004,
    "credits_used": 4
  },
  "errors": [],
  "request_id": "req_nw_4c11w71e44cb"
}

Flagged content (200)

When content is flagged, the response includes specific flags, severity scores, and a cleaned version of the text:
{
  "success": true,
  "result": {
    "id": "mod_nw_abc123def456",
    "object": "moderation",
    "text": "original text here",
    "is_safe": false,
    "verdict": "flagged",
    "flags": ["profanity", "harassment"],
    "severity": "high",
    "severity_score": 0.87,
    "language": "ar",
    "dialect": "egyptian",
    "categories": {
      "profanity": true,
      "hate_speech": false,
      "harassment": true,
      "sexual": false,
      "spam": false,
      "self_harm": false,
      "violence": false
    },
    "category_scores": {
      "profanity": 0.92,
      "hate_speech": 0.05,
      "harassment": 0.85,
      "sexual": 0.01,
      "spam": 0.03,
      "self_harm": 0.00,
      "violence": 0.08
    },
    "flagged_terms": ["term1", "term2"],
    "cleaned_text": "text with *** replacing flagged terms",
    "model": "nagl-v1",
    "provider": "allam",
    "fallback_used": false,
    "cached": false,
    "cost_usd": 0.004,
    "credits_used": 4
  },
  "errors": [],
  "request_id": "req_nw_xyz789"
}

Result fields

FieldTypeDescription
textstringThe original input text
is_safebooleanWhether the content passed moderation
verdictstringsafe or flagged
flagsarrayList of triggered category names
severitystringOverall severity: none, low, medium, high
severity_scorenumberSeverity score 0—1
languagestringDetected language: ar, en, or mixed
dialectstring or nullDetected Arabic dialect. Null if not Arabic.
categoriesobjectBoolean flags for each moderation category
category_scoresobjectConfidence scores 0—1 for each category
flagged_termsarraySpecific problematic words/phrases found
cleaned_textstring or nullText with flagged terms replaced by ***. Null if safe.
modelstringModel version used
providerstringAI provider used (allam or claude)
fallback_usedbooleanWhether the fallback provider was used
cachedbooleanWhether served from semantic cache
cost_usdnumberCost in USD
credits_usednumberCredits deducted

Moderation categories

CategoryDescription
profanitySwearing, vulgar language, dialect-specific profanity
hate_speechContent targeting groups based on race, religion, ethnicity, etc.
harassmentPersonal attacks, bullying, intimidation
sexualSexually explicit or suggestive content
spamPromotional content, repetitive text, link spam
self_harmContent promoting or describing self-harm
violenceThreats, glorification of violence, graphic descriptions

Examples

Input: “هذا محتوى رائع جدا” Result: is_safe: true, verdict: safe, severity: none
curl -X POST https://api.trynawa.com/v1/moderate \
  -H "Authorization: Bearer nawa_test_sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"text": "هذا محتوى رائع جدا", "strictness": "medium"}'
Input: “اشتركوا في قناتي الرابط في البايو!! فولو فولو فولو!!” Result: is_safe: false, flags: ["spam"], severity: low
curl -X POST https://api.trynawa.com/v1/moderate \
  -H "Authorization: Bearer nawa_test_sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"text": "اشتركوا في قناتي الرابط في البايو!! فولو فولو فولو!!", "strictness": "medium"}'
Input: Borderline content that passes on medium but flags on high strictness
curl -X POST https://api.trynawa.com/v1/moderate \
  -H "Authorization: Bearer nawa_test_sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"text": "your text here", "strictness": "high"}'
Input: Moderate a YouTube comment with platform context
curl -X POST https://api.trynawa.com/v1/moderate \
  -H "Authorization: Bearer nawa_test_sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"text": "your text here", "strictness": "medium", "platform": "youtube", "context": "youtube comment"}'

Error responses

StatusTypeWhen
400invalid_request_errorMissing text. Invalid strictness or platform. Text too long.
401authentication_errorInvalid or missing API key
402insufficient_creditsNo credits remaining
429rate_limit_errorRate limit exceeded
500api_errorInternal or provider error