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

text
https://api.sereinmod.com

Quick start

  1. 01

    Create a project

    Sign up and create a project. Thresholds and keys are scoped per project.

  2. 02

    Generate an API key

    Create a key in the project dashboard. Keep it server-side only.

  3. 03

    Moderate content

    POST text to /v1/moderate/text with your key.

  4. 04

    Handle the response

    Use final_decision ("approved" or "denied") and model_output scores.

bash
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:

http
x-api-key: mod_xxxxxxxxx
Never ship API keys in client-side code or public repositories. Prefer environment variables or a secret manager.

POST /v1/moderate/text

Evaluate text with the project's enabled categories and thresholds.

POST/v1/moderate/text

Headers

  • x-api-key — required
  • Content-Type — application/json

Body

json
{
  "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

json
{
  "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.

toxic

Toxic

Rude, disrespectful, or unreasonable language.

Default threshold 0.70

severe_toxic

Severe toxic

Highly aggressive or extremely toxic language.

Default threshold 0.80

obscene

Obscene

Profanity and sexually explicit content.

Default threshold 0.60

threat

Threat

Intent to inflict harm or violence.

Default threshold 0.75

insult

Insult

Insulting or inflammatory language.

Default threshold 0.50

identity_hate

Identity 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.

denied
score 0.62
threshold0.50
score 0.18
threshold0.50
score 0.21
threshold0.50
score 0.08
threshold0.50
score 0.54
threshold0.50
score 0.11
threshold0.50

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.approved

Fired when content passes project thresholds and is approved.

json
{
  "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.denied

Fired when at least one enabled category score meets its threshold.

json
{
  "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.changed

Fired when a human overrides a logged decision in the dashboard.

json
{
  "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

  1. Expose an HTTPS endpoint that accepts POST JSON.
  2. Open the project Settings tab and find Webhooks.
  3. Enter the URL, choose events, activate, and save.
  4. 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.

javascript
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 successful
400Bad request — invalid format or missing fields
401Unauthorized — invalid or missing API key
404Not found — invalid user or project for API key
422Unprocessable — content invalid (e.g. too long)
429Too many requests — rate limit exceeded
500Internal server error

Best 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.