/api/modlogs/add
Record a new moderation action (warn, timeout, ban, kick, unban) for a Discord user.
Records a moderation action and generates a viewable HTML moderation log page stored in S3. The bot token is validated live against the Discord API (GET /users/@me) to ensure the bot is a member of the target guild. User and guild metadata (avatars, names, icons) are resolved via parallel Discord API calls. The response includes a permanent viewUrl that renders a styled HTML page with dark/light mode, search, and filtering. S3 path: {bucket}/{botId}/{guildId}/{userId}.json.
Prerequisites
- Valid Discord Bot Token (validated live against Discord API)
- Bot must be a member of the target guild
- S3-compatible object storage configured on the server
Required Headers
| Name | Description | Required | Example |
|---|---|---|---|
X-Bot-Token |
Discord Bot token for authentication. | Yes | MTEx...token |
X-Guild-Id |
Discord snowflake ID of the server. | Yes | 123456789012345678 |
X-User-Id |
Discord snowflake ID of the target user. | Yes | 987654321098765432 |
X-Action |
Action type: Warn, Timeout, Ban, Kick, Unban. | Yes | Warn |
X-Moderator-Id |
Discord snowflake ID of the moderator. | Yes | 111222333444555666 |
X-Moderator-Name |
Display name of the moderator. | Yes | AdminUser |
X-Reason |
Free-text reason. | No | Spamming |
X-Duration |
Duration for Timeout (e.g. 30m, 2h). | No | 2h |
Responses
{"success":true,"message":"Warn logged.","viewUrl":"https://api.noctra.xyz/api/modlogs/view/..."}
{"error":"Headers required."}
{"error":"Bot token invalid."}
{"error":"Bot not member."}
{"error":"Internal error."}
Use Cases
- Recording a warn/ban/kick/timeout from an external moderation dashboard and posting the viewUrl in a Discord channel for staff reference
- Building a persistent moderation history per user per server, accessible via a shareable HTML page with search and filtering
- Automating moderation logging from a custom Discord bot that performs actions and needs an audit trail