Text Moderation & Toxicity Shield Documentation
Complete API reference, integration examples, authentication guidelines, and response structures.
Overview
Multilingual text safety analysis. Detect hate speech, harassment, profanity, toxic sentiment, spam, and PII in chat messages, comments, and user profiles.
Endpoint
POST /v1/moderate-text
· Base URL:https://api.safeframe.devAuthentication
Authenticate every HTTP request using the custom X-API-Key header:
X-API-Key: nsk_live_xxxxxxxxxxxxxxxxxxxxxxxx
Do not expose your private key in client-side applications. Proxy requests through your backend service or Edge Workers.
Code Examples
Multi-Language SDKs
cURL — request
curl -X POST "https://api.safeframe.dev/v1/moderate-text" \
-H "Content-Type: application/json" \
-H "X-API-Key: nsk_live_xxxxxxxxxxxxxxxxxxxxxxxx" \
-d '{
"input": "Sample text or payload"
}'200 — response
{
"success": true,
"issafe": false,
"message": "NSFW content detected: FEMALE_BREAST_EXPOSED",
"detections": [
{
"label": "FEMALE_BREAST_EXPOSED",
"score": 0.94,
"box": [120, 85, 210, 160],
"top_left": [120, 85],
"bottom_right": [330, 245]
}
]
}Service Specification
# Text Moderation API
Real-time multilingual toxicity analysis and content safety inspection for chatrooms, comments, and user profiles.
## Authentication
Pass your universal API key in the `X-API-Key` header:
```http
X-API-Key: sk_live_...
```
## Endpoint
`POST /v1/moderate-text`
### Request Body (JSON)
| Field | Type | Description |
|---|---|---|
| `text` | string | The message or text payload to analyze |
| `mode` | string | `"standard"`, `"strict"`, or `"lenient"` |
| `detect_pii` | boolean | Detect email addresses, phone numbers, and SSNs |
Status & Error Responses
400 Bad Request
Input payload is empty, missing, or malformed.{
"detail": {
"success": false,
"error": "invalid_payload",
"message": "Invalid request payload"
}
}401 Unauthorized
The X-API-Key header is missing or the key is not recognised.{
"detail": {
"success": false,
"error": "missing_api_key",
"message": "X-API-Key header is required"
}
}402 Payment Required
No active subscription for this service.{
"detail": {
"success": false,
"error": "subscription_required",
"message": "An active subscription is required to access this service"
}
}403 Forbidden
The key was revoked or has expired.{
"detail": {
"success": false,
"error": "api_key_expired",
"message": "API key has expired or is revoked"
}
}429 Too Many Requests
Monthly request quota or rate limit has been reached.{
"detail": {
"success": false,
"error": "rate_limit_reached",
"message": "Monthly API request limit reached"
}
}500 Internal Error
Server error occurred while processing the request.{
"detail": {
"success": false,
"error": "internal_error",
"message": "Internal processing error"
}
}Sample Response
Example payload structure returned by this service.
{
"success": true,
"issafe": false,
"message": "NSFW content detected: FEMALE_BREAST_EXPOSED",
"detections": [
{
"label": "FEMALE_BREAST_EXPOSED",
"score": 0.94,
"box": [
120,
85,
210,
160
],
"top_left": [
120,
85
],
"bottom_right": [
330,
245
]
}
]
}Ready to test?
Head over to the playground to upload your own files and inspect live bounding boxes and classifications.
Open Playground