Skip to content

Guild audit logs

An audit log entry records one change made to a guild and the account that made it. Entries are written by the operations that change a guild and read with List guild audit logs.

The route is relative to https://tebhos.com/api/v1, requires authentication and accepts both user sessions and bot tokens. Error bodies follow Errors.

Audit log reason

TEBHOS does not read an audit-log reason from a request header. Two operations take a reason from their body and store it on the entry:

Every other entry has a null reason.

Guild audit log response object

Field Type Description
audit_log_entries array[guild audit log entry object] The page of entries, newest first
users array[partial user object] The accounts that performed the returned entries, once each
webhooks array Always empty

A user in users has id, username, discriminator, global_name, avatar, avatar_color and flags. An account that no longer exists is returned with an empty username, discriminator "0000" and null avatar fields.

Guild audit log entry object

Field Type Description
id snowflake The entry ID. Its snowflake timestamp is when the entry was written
action_type integer The audit action
user_id snowflake The account that performed the action
target_id ?string The ID of the affected entity (for invites, the invite code)
reason ?string The reason, or null
options object String key-value pairs. Always has tebhos_action, the TEBHOS name of the action, and usually target_type (server, channel, member, user, role, invite, webhook, emoji or sticker)
changes array[audit log change object] The values the action set; empty when none were recorded

Entries expire 45 days after they are written.

{
  "id": "1501314428688998184",
  "action_type": 22,
  "user_id": "1489002177550843905",
  "target_id": "1489002177550843906",
  "reason": "Advertising",
  "options": {"tebhos_action": "MEMBER_BAN", "target_type": "member"},
  "changes": []
}

Audit log change object

Field Type Description
key string The name of the value
new_value any The value after the change

TEBHOS records only the new side of a change; there is no old_value. Most actions record the entity's name. Modify guild records each of name, features, icon, banner, splash and embed_splash it changed; Modify guild role records name and color; a webhook creation also records channel_id; voice moves record channel_id and connection_id; server mute and deafen record mute and deaf.

Audit actions

The value is the numeric action_type, which is also what the action_type query parameter accepts. The last column shows whether a current TEBHOS operation writes the action.

Value Name Written by
1 GUILD_UPDATE Modify guild. target_id is the guild
10 CHANNEL_CREATE Creating a text, voice or link channel
11 CHANNEL_UPDATE Modify channel
12 CHANNEL_DELETE Delete channel
13 CHANNEL_OVERWRITE_CREATE Not written
14 CHANNEL_OVERWRITE_UPDATE Not written
15 CHANNEL_OVERWRITE_DELETE Not written
20 MEMBER_KICK Remove guild member. target_id is the user
21 MEMBER_PRUNE Not written
22 MEMBER_BAN_ADD Create guild ban
23 MEMBER_BAN_REMOVE Remove guild ban
24 MEMBER_UPDATE Server mute or deafen through Modify guild member
25 MEMBER_ROLE_UPDATE Not written; role changes on members are not audited
26 MEMBER_MOVE Moving a member between voice channels
27 MEMBER_DISCONNECT Disconnecting a member from voice
28 BOT_ADD Not written
30 ROLE_CREATE Create guild role
31 ROLE_UPDATE Modify guild role
32 ROLE_DELETE Delete guild role
40 INVITE_CREATE Creating an invite. target_id is the invite code
41 INVITE_UPDATE Not written
42 INVITE_DELETE Delete invite. target_id is the invite code
50 WEBHOOK_CREATE Creating a webhook
51 WEBHOOK_UPDATE Modifying a webhook
52 WEBHOOK_DELETE Deleting a webhook
60 EMOJI_CREATE Creating or cloning a guild emoji
61 EMOJI_UPDATE Renaming a guild emoji
62 EMOJI_DELETE Deleting a guild emoji
72 MESSAGE_DELETE Not written by the public API
73 MESSAGE_BULK_DELETE Not written by the public API
74 MESSAGE_PIN Not written
75 MESSAGE_UNPIN Not written
90 STICKER_CREATE Creating or cloning a guild sticker
91 STICKER_UPDATE Modifying a guild sticker
92 STICKER_DELETE Deleting a guild sticker

TEBHOS-specific actions. Actions with no standard number are stored with action_type 0 and identified by options.tebhos_action:

tebhos_action Written by
MEMBER_TIMEOUT Setting a timeout through Modify guild member. target_id is the user and reason is the timeout_reason. Removing a timeout writes no entry

Such entries can be read without an action_type filter. Filtering with action_type=0 returns them.

List guild audit logs

GET /guilds/{guild_id}/audit-logs

Returns one page of audit history as a guild audit log response object. Requires VIEW_AUDIT_LOG.

Rate limit: guild:audit_logs, 20 per 10 seconds per account and guild.

Query parameters

Field Type Description
limit? integer Maximum number of entries, clamped to 1-100 (default 50)
before? snowflake Return entries older than this entry ID
after? snowflake Return entries newer than this entry ID. Ignored when before is also sent
user_id? snowflake Only entries performed by this account
action_type? integer Only entries with this audit action

Entries are always returned newest first, with after too: an after page starts with the newest entry above the cursor. To walk backwards through history, pass the id of the last entry you received as before.

Status Code Condition
400 BAD_REQUEST before, after or user_id is not a snowflake
403 FORBIDDEN The caller is not a member or lacks VIEW_AUDIT_LOG
curl "https://tebhos.com/api/v1/guilds/1489002177550843904/audit-logs?limit=25&action_type=22" \
  -H "Authorization: Bot $TEBHOS_BOT_TOKEN"

The guild also receives a Guild Audit Log Entry Create event over the Gateway when most entries are written. Entries with action_type 0 are not dispatched.