API reference
Documentation
Authenticate with an API key, moderate text, tune thresholds, and subscribe to decision webhooks.
Introduction
SereinMod exposes a REST API over HTTPS. Send user-generated text, receive category scores and a final decision based on your project thresholds.
Base URL
https://api.sereinmod.comQuick start
01
Create a project
Sign up and create a project. Thresholds and keys are scoped per project.
02
Generate an API key
Create a key in the project dashboard. Keep it server-side only.
03
Moderate content
POST text to /v1/moderate/text with your key.
04
Handle the response
Use final_decision ("approved" or "denied") and model_output scores.
curl -X POST https://api.sereinmod.com/v1/moderate/text \
-H "x-api-key: mod_xxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"content": "Hello, world!"
}'Authentication
Include your API key on every request:
x-api-key: mod_xxxxxxxxxPOST /v1/moderate/text
Evaluate text with the project's enabled categories and thresholds.
Headers
- x-api-key — required
- Content-Type — application/json
Body
{
"content": "string",
"meta_data": {
"user_id": "123",
"session_id": "abc"
}
}content is required (max 10,000 characters). meta_data is optional and stored with the moderation log.
Examples
curl -X POST https://api.sereinmod.com/v1/moderate/text \
-H "x-api-key: mod_xxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"content": "Hello, this is a test message!"
}'Response
{
"final_decision": "denied",
"model_output": {
"toxic": 0.87,
"severe_toxic": 0.22,
"obscene": 0.18,
"threat": 0.03,
"insult": 0.45,
"identity_hate": 0.15
}
}Categories
Each request returns a score from 0 to 1 for every category below.
toxicToxic
Rude, disrespectful, or unreasonable language.
Default threshold 0.70
severe_toxicSevere toxic
Highly aggressive or extremely toxic language.
Default threshold 0.80
obsceneObscene
Profanity and sexually explicit content.
Default threshold 0.60
threatThreat
Intent to inflict harm or violence.
Default threshold 0.75
insultInsult
Insulting or inflammatory language.
Default threshold 0.50
identity_hateIdentity hate
Hate based on identity or protected attributes.
Default threshold 0.65
Thresholds
If any enabled category score is greater than or equal to its project threshold, the final decision is denied. Otherwise it is approved.
Threshold explorer
Adjust cutoffs against a fixed sample model output. No network call.
Webhooks
Receive POST callbacks when content is approved, denied, or when a decision changes. Deliveries are signed with HMAC-SHA256 and retried with backoff on failure.
Webhook events
content.approvedFired when content passes project thresholds and is approved.
{
"event_type": "content.approved",
"log_id": "uuid-here",
"decision": "approved",
"content": "The original content text",
"model_output": {
"toxic": 0.62,
"severe_toxic": 0.18,
"obscene": 0.21,
"threat": 0.08,
"insult": 0.54,
"identity_hate": 0.11
},
"timestamp": "2025-01-15T12:00:00Z"
}content.deniedFired when at least one enabled category score meets its threshold.
{
"event_type": "content.denied",
"log_id": "uuid-here",
"decision": "denied",
"content": "The original content text",
"model_output": {
"toxic": 0.62,
"severe_toxic": 0.18,
"obscene": 0.21,
"threat": 0.08,
"insult": 0.54,
"identity_hate": 0.11
},
"timestamp": "2025-01-15T12:00:00Z"
}decision.changedFired when a human overrides a logged decision in the dashboard.
{
"event_type": "decision.changed",
"log_id": "uuid-here",
"decision": "approved",
"previous_decision": "denied",
"content": "The original content text",
"model_output": {
"toxic": 0.62,
"severe_toxic": 0.18,
"obscene": 0.21,
"threat": 0.08,
"insult": 0.54,
"identity_hate": 0.11
},
"timestamp": "2025-01-15T12:05:00Z"
}Setting up webhooks
- Expose an HTTPS endpoint that accepts POST JSON.
- Open the project Settings tab and find Webhooks.
- Enter the URL, choose events, activate, and save.
- Store the generated webhook secret for signature verification.
Signature verification
Requests include X-Webhook-Signature as sha256=<hex>. Verify before processing.
const crypto = require("crypto");
function verifyWebhookSignature(payload, signature, secret) {
const payloadString = JSON.stringify(payload);
const hmac = crypto.createHmac("sha256", secret);
hmac.update(payloadString);
const expected = "sha256=" + hmac.digest("hex");
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}Rate limits
Limits depend on plan. Responses include X-RateLimit-Remaining and X-RateLimit-Limit. Exceeding the limit returns 429.
Free
3,000 / mo
100 / day
Basic
10,000 / mo
No daily cap
Pro
80,000 / mo
No daily cap
Error handling
Errors return JSON with a detail message. Check status codes and back off on 429.
async function moderateContent(content) {
const response = await fetch("https://api.sereinmod.com/v1/moderate/text", {
method: "POST",
headers: {
"x-api-key": "mod_xxxxxxxxx",
"Content-Type": "application/json",
},
body: JSON.stringify({ content }),
});
if (!response.ok) {
const error = await response.json();
if (response.status === 429) {
throw new Error("Rate limit exceeded");
}
throw new Error(error.detail || "Moderation request failed");
}
return response.json();
}HTTP response codes
200OK — request successful400Bad request — invalid format or missing fields401Unauthorized — invalid or missing API key404Not found — invalid user or project for API key422Unprocessable — content invalid (e.g. too long)429Too many requests — rate limit exceeded500Internal server errorBest practices
- Keep API keys and webhook secrets on the server.
- Verify webhook signatures before acting on events.
- Tune thresholds to your product's risk tolerance.
- Prefer webhooks over polling for decision workflows.
- Handle 429 with exponential backoff.