API reference
Audit logs
Read who did what in a server, and why.
The audit log records who did what in a server, and why. Bots can read it with the View audit log permission on their role, the same rule people follow.
#Get server audit log
GET
/v1/guilds/{guild_id}/audit-logsReturns { "audit_log_entries": [...] }, newest first. Without View audit log it answers 403 missing_permissions.
| Query | Type | Notes |
|---|---|---|
limit | integer | 1 to 100 |
before | entry id | Entries before this one |
after | entry id | Entries after this one |
user_id | user id | Only actions by this person |
action_type | integer | Only this kind of action |
To hear about new entries as they happen, use the guild_moderation intent and GUILD_AUDIT_LOG_ENTRY_CREATE.
#Audit log entry
JSON
{
"id": "…", "guild_id": "…", "action_type": 22, "action": "member_banned",
"user_id": "…", "target_id": "…", "reason": "Spam links",
"options": {}, "changes": [], "created_at": 1759312800000
}| Field | Type | Notes |
|---|---|---|
id | string | |
guild_id | string | |
action_type | integer or null | Discord's audit log event number, so existing code can switch on it: 22 for a ban, 24 for a member update such as a timeout or nickname, 30 for a new role. null for actions Discord doesn't log, such as joins and leaves |
action | string | Lamma's own name for the action, such as member_banned or member_joined |
user_id | string or null | Who did it. null for automatic actions such as AutoMod |
target_id | string or null | What it was done to |
reason | string or null | |
options | object | Extra details recorded with the action |
changes | array | [{ key, old_value, new_value }] for edits that recorded before and after |
created_at | integer | Unix milliseconds |