1. Store the API key as a secret
Copy your project’s API key from the dashboard. Store it as a secret namedMODAPI_SECRET_KEY. Do not paste the key into the chat.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Add Moderation API to an app built with Lovable, v0, Bolt or Replit: where to put the API key, and a prompt to copy.
MODAPI_SECRET_KEY. Do not paste the key into the chat.
| Builder | Where to add the secret |
|---|---|
| Lovable | Cloud → Secrets. The key is available to Edge Functions only. |
| v0 | The Vars panel. Do not add the NEXT_PUBLIC_ prefix. |
| Bolt | The Secrets section in the database settings. The key is available to server functions. |
| Replit | The Secrets tool. When you publish, add the key to the deployment secrets too. |
Add content moderation with Moderation API to every place where users create
content (posts, comments, messages, profiles).
- Call it from server code only (an API route, server action, edge or server
function), never from the browser. Read the key from the MODAPI_SECRET_KEY
secret. Never put the key in client code.
- Send each piece of content before you save it:
POST https://api.moderationapi.com/v1/moderate
Authorization: Bearer <MODAPI_SECRET_KEY>
Body: {"content": {"type": "text", "text": "<the text>"}, "authorId": "<user id>"}
- Read recommendation.action from the response:
- "allow": save and publish.
- "review": save it but do not publish it yet. A moderator decides.
- "reject": do not save it. Show the user a short, neutral message.
Treat any other value as "review".
- If the request fails, save and publish the content, so users are not blocked.
Docs: https://docs.moderationapi.com/llms.txt
Was this page helpful?