Registro de auditoría
When an administrative action is performed in a guild, an entry is added to its audit log. Viewing audit logs requires the permission and can be fetched using the Get Guild Audit Log endpoint. All audit log entries are stored for 45 days.
When performing an eligible action using the API, users can pass an header to indicate why the action was taken. More information is in the audit log entry section.
Each audit log entry represents a single administrative action (or event), indicated by . Most entries contain one to many changes in the array that affected an entity in Discord—whether that's a user, channel, guild, emoji, or something else.
The information (and structure) of an entry's changes will be different depending on its type. For example, in events there is only one change: a member is either added or removed from a specific role. However, in events there are many changes, including (but not limited to) the channel's name, type, and permission overwrites added. More details are in the change object section.
Users can specify why an administrative action is being taken by passing an request header, which will be stored as the audit log entry's field. The header supports up to 512 URL-encoded UTF-8 characters. Reasons are visible in the client and when fetching audit log entries with the API.
target_id
?snowflake
ID of the affected entity (webhook, user, role, etc.)
user_id
?snowflake
The user who made the changes
id
snowflake
The ID of the entry
reason?
string
The reason for the change (max 512 characters)
The table below lists audit log events and values (the field) that you may receive.
The Object Changed column notes which object's values may be included in the entry. Though there are exceptions, possible keys in the array typically correspond to the object's fields. The descriptions and types for those fields can be found in the linked documentation for the object.
If no object is noted, there won't be a array in the entry, though other fields like the still exist and many have fields in the array.
20
MEMBER_KICK
Member was removed from guild
21
MEMBER_PRUNE
Members were pruned from guild
22
MEMBER_BAN_ADD
Member was banned from guild
23
MEMBER_BAN_REMOVE
Member was unbanned from guild
26
MEMBER_MOVE
Member was moved to a different voice channel
27
MEMBER_DISCONNECT
Member was disconnected from a voice channel
28
BOT_ADD
Bot user was added to guild
72
MESSAGE_DELETE
Single message was deleted
73
MESSAGE_BULK_DELETE
Multiple messages were deleted
74
MESSAGE_PIN
Message was pinned to a channel
75
MESSAGE_UNPIN
Message was unpinned from a channel
121
APPLICATION_COMMAND_PERMISSION_UPDATE
Permissions were updated for a command
143
AUTO_MODERATION_BLOCK_MESSAGE
Message was blocked by AutoMod
144
AUTO_MODERATION_FLAG_TO_CHANNEL
Message was flagged by AutoMod
145
AUTO_MODERATION_USER_COMMUNICATION_DISABLED
Member was timed out by AutoMod
146
AUTO_MODERATION_QUARANTINE_USER
Member was quarantined by AutoMod
150
CREATOR_MONETIZATION_REQUEST_CREATED
Creator monetization request was created
151
CREATOR_MONETIZATION_TERMS_ACCEPTED
Creator monetization terms were accepted
171
GUILD_HOME_FEATURE_ITEM
Item was featured in guild home
172
GUILD_HOME_REMOVE_ITEM
Item was removed from guild home
180
HARMFUL_LINKS_BLOCKED_MESSAGE
Message blocked by harmful links filter
194
CLYDE_AI_PROFILE_UPDATE
Clyde AI profile was updated
200
GUILD_SCHEDULED_EVENT_EXCEPTION_CREATE
Exception was created for a guild scheduled event
201
GUILD_SCHEDULED_EVENT_EXCEPTION_UPDATE
Exception was updated for a guild scheduled event
202
GUILD_SCHEDULED_EVENT_EXCEPTION_DELETE
Exception was deleted for a guild scheduled event
1 Object has exception(s) to available keys. See the exceptions section below for details.
application_id
snowflake
The ID of the application whose permissions were targeted
APPLICATION_COMMAND_PERMISSION_UPDATE
auto_moderation_rule_name
string
The name of the AutoMod rule that was triggered
AUTO_MODERATION_BLOCK_MESSAGE
, AUTO_MODERATION_FLAG_TO_CHANNEL
, AUTO_MODERATION_USER_COMMUNICATION_DISABLED
, AUTO_MODERATION_QUARANTINE_USER
auto_moderation_rule_trigger_type
string
The trigger type of the AutoMod rule that was triggered
AUTO_MODERATION_BLOCK_MESSAGE
, AUTO_MODERATION_FLAG_TO_CHANNEL
, AUTO_MODERATION_USER_COMMUNICATION_DISABLED
, AUTO_MODERATION_QUARANTINE_USER
channel_id
snowflake
The channel in which the entities were targeted
MEMBER_MOVE
, MESSAGE_PIN
, MESSAGE_UNPIN
, MESSAGE_DELETE
, STAGE_INSTANCE_CREATE
, STAGE_INSTANCE_UPDATE
, STAGE_INSTANCE_DELETE
count?
string
Number of entities that were targeted
MESSAGE_DELETE
, MESSAGE_BULK_DELETE
, MEMBER_DISCONNECT
, MEMBER_MOVE
delete_member_days?
string
Number of days after which inactive members were kicked
MEMBER_PRUNE
event_exception_id
snowflake
The ID of the guild scheduled event exception that was targeted
GUILD_SCHEDULED_EVENT_EXCEPTION_CREATE
, GUILD_SCHEDULED_EVENT_EXCEPTION_UPDATE
, GUILD_SCHEDULED_EVENT_EXCEPTION_DELETE
id
snowflake
The ID of the overwritten entity
CHANNEL_OVERWRITE_CREATE
, CHANNEL_OVERWRITE_UPDATE
, CHANNEL_OVERWRITE_DELETE
integration_type?
string
The type of integration which performed the action
MEMBER_KICK
, MEMBER_ROLE_UPDATE
members_removed?
string
Number of members removed by the prune
MEMBER_PRUNE
message_id
snowflake
The ID of the message that was targeted
MESSAGE_PIN
, MESSAGE_UNPIN
role_name?
string
The name of the role (only present if type is "0")
CHANNEL_OVERWRITE_CREATE
, CHANNEL_OVERWRITE_UPDATE
, CHANNEL_OVERWRITE_DELETE
status
string
The new status of the voice channel
VOICE_CHANNEL_STATUS_UPDATE
type 1
string
CHANNEL_OVERWRITE_CREATE
, CHANNEL_OVERWRITE_UPDATE
, CHANNEL_OVERWRITE_DELETE
1 Due to technical limitations, this field is always serialized as a string, not an integer.
Many audit log events include a array in their entry object. The structure for the individual changes varies based on the event type and its changed objects, so apps shouldn't depend on a single pattern of handling audit log events.
Some events don't follow the same pattern as other audit log events. Details about these exceptions are explained in the next section.
new_value?
mixed (matches object field's type)
New value of the key
old_value?
mixed (matches object field's type)
Old value of the key
For most objects, the change keys may be any field on the changed object. The following table details the exceptions to this pattern.
$add_keyword_filter
, $remove_keyword_filter
, $add_regex_patterns
, $remove_regex_patterns
, $add_allow_list
, $remove_allow_list
as keys
new_value
and old_value
are arrays of strings representing the keywords, regex patterns, or allow list items that were added or removed
A snowflake is used as the key
The changes
array contains objects with a key
field representing the entity whose command was affected (role, channel, or user ID), a previous permissions object (with an old_value
key), and an updated permissions object (with a new_value
key)
Additional bypasses_verification
key (instead of object's flags
)
new_value
and old_value
are booleans representing whether the member bypasses verification
Additional channel_id
and inviter_id
keys (instead of object's channel.id
and inviter.id
)
$add
and $remove
as keys
new_value
is an array of objects that contain the role id
and name
verification_enabled
and manual_approval_enabled
as keys
new_value
and old_value
are booleans representing whether verification or manual approval is enabled
id
snowflake
The ID of the integration
name
string
The name of the integration
application_id?
snowflake
The OAuth2 application for Discord integrations
{ "id": "1029376264039039006", "type": "discord", "name": "Good University", "account": { "id": "971811349262917662", "name": "Good University" }, "application_id": "971811349262917662"}
id
snowflake
The ID of the role
name
string
The name of the role
{ "name": "I am a role", "id": "584120723283509258"}
GET/guilds/{guild.id}/audit-logs
Returns the audit log for the guild. Requires the permission.
before?
snowflake
Get entries before this entry ID
after?
snowflake
Get entries after this entry ID
limit?
integer
Max number of entries to return (1-100, default 50)
user_id?
snowflake
Get actions made by a specific user
target_id?
snowflake
Get actions affecting a specific entity
application_commands
array[application command object]
Application commands referenced in the audit log
guild_scheduled_events
array[guild scheduled event object]
Guild scheduled events referenced in the audit log