> For the complete documentation index, see [llms.txt](https://docs.exoguard.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exoguard.io/tutorials/audit-webhook-setup/external-audit-webhooks.md).

# External audit webhooks

If you have an [Exoguard Pro subscription](/service/subscriptions.md), you can leverage external auditing features through custom webhooks outside of the Discord platform. Every time a command that may affect your server's security or configuration is executed, a JSON POST request is sent to your webhook.

## Audit Log Object

Here are the JSON fields you can find in an audit log event's request body:

<table><thead><tr><th width="144">Field</th><th width="93">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>command</code></td><td>string</td><td>Full command name (example: <code>config roles add</code>)</td></tr><tr><td><code>author</code></td><td>object</td><td>Command author's Discord user object (<a href="https://discord.com/developers/docs/resources/user#user-object">developer docs</a>)</td></tr><tr><td><code>guild</code></td><td>object</td><td>Partial guild object, with only the <code>id</code> and <code>name</code> fields</td></tr><tr><td><code>timestamp</code></td><td>float</td><td>Timestamp at which the current audit log event was fired</td></tr><tr><td><code>args?</code></td><td>object</td><td>Command arguments with their respective values, if any</td></tr><tr><td><code>success?</code></td><td>boolean</td><td>Authentication status, only for commands that require it</td></tr><tr><td><code>error?</code></td><td>string</td><td>Authentication failure reason, only when <code>success</code> is <code>false</code></td></tr><tr><td><code>details?</code></td><td>string</td><td>Markdown-formatted string for additional command details</td></tr><tr><td><code>action?</code></td><td>string</td><td>Either <code>create</code> or <code>update</code>, only for the <a href="/pages/WZ1krtuzNiOUEX6KfP8M#enroll">enroll</a> command</td></tr></tbody></table>

Fields marked with a question mark `?` are contextual, they will not always be present.

## Example Events

#### Login (success)

<pre class="language-json"><code class="lang-json">{
<strong>  "command": "login",
</strong>  "success": true,
  "author": {
    "avatar": "39e2ed99424b085c44afac5f7d07f33c",
    "clan": null,
    "discriminator": "0",
    "global_name": "Xenthys",
    "id": "368771716140236802",
    "public_flags": 4588160,
    "username": "xenthys"
  },
  "timestamp": 1724620785.892197,
  "guild": {
    "id": 1201295802967019725,
    "name": "Exoguard HQ"
  }
}
</code></pre>

#### Login (failure)

<pre class="language-json"><code class="lang-json">{
<strong>  "command": "login",
</strong>  "success": false,
  "error": "invalid_code",
  "author": {
    "avatar": "39e2ed99424b085c44afac5f7d07f33c",
    "clan": null,
    "discriminator": "0",
    "global_name": "Xenthys",
    "id": "368771716140236802",
    "public_flags": 4588160,
    "username": "xenthys"
  },
  "timestamp": 1724620794.665614,
  "guild": {
    "id": 1201295802967019725,
    "name": "Exoguard HQ"
  }
}
</code></pre>

#### Login (failure, rate-limited)

```json
{
  "command": "login",
  "success": false,
  "error": "invalid_code",
  "details": "**Warning:** user has failed authentication at least 3 times in 2 minutes.",
  "author": {
    "avatar": "39e2ed99424b085c44afac5f7d07f33c",
    "clan": null,
    "discriminator": "0",
    "global_name": "Xenthys",
    "id": "368771716140236802",
    "public_flags": 4588160,
    "username": "xenthys"
  },
  "timestamp": 1724620800.03748,
  "guild": {
    "id": 1201295802967019725,
    "name": "Exoguard HQ"
  }
}
```

#### Logout

<pre class="language-json"><code class="lang-json">{
<strong>  "command": "logout",
</strong>  "author": {
  "avatar": "39e2ed99424b085c44afac5f7d07f33c",
    "clan": null,
    "discriminator": "0",
    "global_name": "Xenthys",
    "id": "368771716140236802",
    "public_flags": 4588160,
    "username": "xenthys"
  },
  "timestamp": 1724620789.882272,
  "guild": {
    "id": 1201295802967019725,
    "name": "Exoguard HQ"
  }
}
</code></pre>

#### Config roles add

<pre class="language-json"><code class="lang-json">{
<strong>  "command": "config roles add",
</strong>  "args": {
    "role": "1201298127920046181",
    "user": "368771716140236802"
  },
  "author": {
    "avatar": "39e2ed99424b085c44afac5f7d07f33c",
    "clan": null,
    "discriminator": "0",
    "global_name": "Xenthys",
    "id": "368771716140236802",
    "public_flags": 4588160,
    "username": "xenthys"
  },
  "timestamp": 1724616060.967678,
  "guild": {
    "id": 1201295802967019725,
    "name": "Exoguard HQ"
  }
}
</code></pre>

#### Delete

```json
{
  "command": "delete",
  "args": {
    "user": "262700032262799382"
  },
  "author": {
    "avatar": "39e2ed99424b085c44afac5f7d07f33c",
    "clan": null,
    "discriminator": "0",
    "global_name": "Xenthys",
    "id": "368771716140236802",
    "public_flags": 4588160,
    "username": "xenthys"
  },
  "timestamp": 1724628609.820362,
  "guild": {
    "id": 1201295802967019725,
    "name": "Exoguard HQ"
  }
}
```

#### Subscription redeem

```json
{
  "command": "subscription redeem",
  "details": "**Voucher information:** Exoguard Pro (30 days) subscription **Subscription expiry:** <t:1729805047:D> at <t:1729805047:T>",
  "author": {
    "avatar": "39e2ed99424b085c44afac5f7d07f33c",
    "clan": null,
    "discriminator": "0",
    "global_name": "Xenthys",
    "id": "368771716140236802",
    "public_flags": 4588160,
    "username": "xenthys"
  },
  "timestamp": 1724629098.998002,
  "guild": {
    "id": 1201295802967019725,
    "name": "Exoguard HQ"
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.exoguard.io/tutorials/audit-webhook-setup/external-audit-webhooks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
