Audit Logs Resource

Audit Logs

Whenever an admin action is performed on the API, an entry is added to the respective guild's audit log.

X-Audit-Log-Reason

Certain endpoints support the X-Audit-Log-Reason header, which adds a reason in the audit log entry created from the action that was executed. This header supports url encoded UTF8 characters.

Audit Log Object

Audit Log Structure
FieldTypeDescription
webhooksarray of webhook objectslist of webhooks found in the audit log
usersarray of user objectslist of users found in the audit log
audit_log_entriesarray of audit log entry objectslist of audit log entries
integrationsarray of partial integration objectslist of partial integration objects
threadsarray of channel objectslist of threads found in the audit log*

* Threads referenced in THREAD_CREATE and THREAD_UPDATE events are included in the threads map, since archived threads might not be kept in memory by clients.

Example Partial Integration Object
json
{
"id": "33590653072239123",
"name": "A Name",
"type": "twitch",
"account": {
"name": "twitchusername",
"id": "1234567"
}
}

Audit Log Entry Object

Audit Log Entry Structure
FieldTypeDescription
target_id?stringid of the affected entity (webhook, user, role, etc.)
changes?array of audit log change objectschanges made to the target_id
user_id?snowflakethe user who made the changes
idsnowflakeid of the entry
action_typeaudit log eventtype of action that occurred
options?optional audit entry infoadditional info for certain action types
reason?stringthe reason for the change (0-512 characters)
Audit Log Events
EventValue
GUILD_UPDATE1
CHANNEL_CREATE10
CHANNEL_UPDATE11
CHANNEL_DELETE12
CHANNEL_OVERWRITE_CREATE13
CHANNEL_OVERWRITE_UPDATE14
CHANNEL_OVERWRITE_DELETE15
MEMBER_KICK20
MEMBER_PRUNE21
MEMBER_BAN_ADD22
MEMBER_BAN_REMOVE23
MEMBER_UPDATE24
MEMBER_ROLE_UPDATE25
MEMBER_MOVE26
MEMBER_DISCONNECT27
BOT_ADD28
ROLE_CREATE30
ROLE_UPDATE31
ROLE_DELETE32
INVITE_CREATE40
INVITE_UPDATE41
INVITE_DELETE42
WEBHOOK_CREATE50
WEBHOOK_UPDATE51
WEBHOOK_DELETE52
EMOJI_CREATE60
EMOJI_UPDATE61
EMOJI_DELETE62
MESSAGE_DELETE72
MESSAGE_BULK_DELETE73
MESSAGE_PIN74
MESSAGE_UNPIN75
INTEGRATION_CREATE80
INTEGRATION_UPDATE81
INTEGRATION_DELETE82
STAGE_INSTANCE_CREATE83
STAGE_INSTANCE_UPDATE84
STAGE_INSTANCE_DELETE85
STICKER_CREATE90
STICKER_UPDATE91
STICKER_DELETE92
THREAD_CREATE110
THREAD_UPDATE111
THREAD_DELETE112
Optional Audit Entry Info
FieldTypeDescriptionAction Type
delete_member_daysstringnumber of days after which inactive members were kickedMEMBER_PRUNE
members_removedstringnumber of members removed by the pruneMEMBER_PRUNE
channel_idsnowflakechannel in which the entities were targetedMEMBER_MOVE & MESSAGE_PIN & MESSAGE_UNPIN & MESSAGE_DELETE & STAGE_INSTANCE_CREATE & STAGE_INSTANCE_UPDATE & STAGE_INSTANCE_DELETE
message_idsnowflakeid of the message that was targetedMESSAGE_PIN & MESSAGE_UNPIN
countstringnumber of entities that were targetedMESSAGE_DELETE & MESSAGE_BULK_DELETE & MEMBER_DISCONNECT & MEMBER_MOVE
idsnowflakeid of the overwritten entityCHANNEL_OVERWRITE_CREATE & CHANNEL_OVERWRITE_UPDATE & CHANNEL_OVERWRITE_DELETE
typestringtype of overwritten entity - "0" for "role" or "1" for "member"CHANNEL_OVERWRITE_CREATE & CHANNEL_OVERWRITE_UPDATE & CHANNEL_OVERWRITE_DELETE
role_namestringname of the role if type is "0" (not present if type is "1")CHANNEL_OVERWRITE_CREATE & CHANNEL_OVERWRITE_UPDATE & CHANNEL_OVERWRITE_DELETE

Audit Log Change Object

Audit Log Change Structure
FieldTypeDescription
new_value?mixednew value of the key
old_value?mixedold value of the key
keystringname of audit log change key
Audit Log Change Key
NameObject ChangedTypeDescription
nameanystringname changed
descriptionguild or stickerstringdescription changed
icon_hashguildstringicon changed
splash_hashguildstringinvite splash page artwork changed
discovery_splash_hashguildstringdiscovery splash changed
banner_hashguildstringguild banner changed
owner_idguildsnowflakeowner changed
regionguildstringregion changed
preferred_localeguildstringpreferred locale changed
afk_channel_idguildsnowflakeafk channel changed
afk_timeoutguildintegerafk timeout duration changed
rules_channel_idguildsnowflakeid of the rules channel changed
public_updates_channel_idguildsnowflakeid of the public updates channel changed
mfa_levelguildintegertwo-factor auth requirement changed
verification_levelguildintegerrequired verification level changed
explicit_content_filterguildintegerchange in whose messages are scanned and deleted for explicit content in the server
default_message_notificationsguildintegerdefault message notification level changed
vanity_url_codeguildstringguild invite vanity url changed
\$addguildarray of partial role objectsnew role added
\$removeguildarray of partial role objectsrole removed
prune_delete_daysguildintegerchange in number of days after which inactive and role-unassigned members are kicked
widget_enabledguildbooleanserver widget enabled/disable
widget_channel_idguildsnowflakechannel id of the server widget changed
system_channel_idguildsnowflakeid of the system channel changed
positionchannelintegertext or voice channel position changed
topicchannel or stage instancestringtext channel topic or stage instance topic changed
bitratechannelintegervoice channel bitrate changed
permission_overwriteschannelarray of channel overwrite objectspermissions on a channel changed
nsfwchannelbooleanchannel nsfw restriction changed
application_idchannelsnowflakeapplication id of the added or removed webhook or bot
rate_limit_per_userchannelintegeramount of seconds a user has to wait before sending another message changed
permissionsrolestringpermissions for a role changed
colorroleintegerrole color changed
hoistrolebooleanrole is now displayed/no longer displayed separate from online users
mentionablerolebooleanrole is now mentionable/unmentionable
allowrolestringa permission on a text or voice channel was allowed for a role
denyrolestringa permission on a text or voice channel was denied for a role
codeinvitestringinvite code changed
channel_idinvitesnowflakechannel for invite code changed
inviter_idinvitesnowflakeperson who created invite code changed
max_usesinviteintegerchange to max number of times invite code can be used
usesinviteintegernumber of times invite code used changed
max_ageinviteintegerhow long invite code lasts changed
temporaryinvitebooleaninvite code is temporary/never expires
deafuserbooleanuser server deafened/undeafened
muteuserbooleanuser server muted/unmuted
nickuserstringuser nickname changed
avatar_hashuserstringuser avatar changed
idanysnowflakethe id of the changed entity - sometimes used in conjunction with other keys
typeanyinteger or stringtype of entity created
enable_emoticonsintegrationbooleanintegration emoticons enabled/disabled
expire_behaviorintegrationintegerintegration expiring subscriber behavior changed
expire_grace_periodintegrationintegerintegration expire grace period changed
user_limitvoice channelintegernew user limit in a voice channel
privacy_levelstage instanceinteger (privacy level)privacy level of the stage instance changed
tagsstickerstringrelated emoji of sticker changed
format_typestickerinteger (format type)format type of sticker changed
assetstickerstringempty string
availablestickerbooleanavailability of sticker changed
guild_idstickersnowflakeguild sticker is in changed
archivedthreadboolthread is now archived/unarchived
lockedthreadboolthread is now locked/unlocked
auto_archive_durationthreadintegerauto archive duration changed
default_auto_archive_durationchannelintegerdefault auto archive duration for newly created threads changed
Example Partial Role Object
json
{
"name": "I am a role",
"id": 584120723283509258
}

Endpoints

Get Guild Audit Log

GET/guilds/{guild.id}/audit-logs

Returns an audit log object for the guild. Requires the 'VIEW_AUDIT_LOG' permission.

Query String Params
FieldTypeDescription
user_idsnowflakefilter the log for actions made by a user
action_typeintegerthe type of audit log event
beforesnowflakefilter the log before a certain entry id
limitintegerhow many entries are returned (default 50, minimum 1, maximum 100)