# Audit logs

**Audit Logs** allows Auditors to monitor user operations in their deployment.

<Callout type="info" title="Note">
  Audit logs require a
  [Premium license](https://coder.com/pricing#compare-plans).
  For more details, [contact your account team](https://coder.com/contact).
</Callout>

## Tracked Events [#tracked-events]

Coder records audit log entries for the resources below.
Each section lists the actions that produce an entry, followed by the resource's fields.
When a tracked field changes, the change appears in the entry's diff, and untracked fields are left out.

### AIGatewayKey [#aigatewaykey]

Actions: `create`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>hashed_secret</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>last_heartbeat_at</code></td><td>No</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>secret_prefix</code></td><td>Yes</td></tr>
</tbody>
</table>

### AIProvider [#aiprovider]

Actions: `create`, `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>base_url</code></td><td>Yes</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>deleted</code></td><td>Yes</td></tr>
<tr><td><code>display_name</code></td><td>Yes</td></tr>
<tr><td><code>enabled</code></td><td>Yes</td></tr>
<tr><td><code>icon</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>settings</code></td><td>Yes</td></tr>
<tr><td><code>settings_key_id</code></td><td>No</td></tr>
<tr><td><code>type</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
</tbody>
</table>

### AIProviderKey [#aiproviderkey]

Actions: `create`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>api_key</code></td><td>Yes</td></tr>
<tr><td><code>api_key_key_id</code></td><td>No</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>provider_id</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
</tbody>
</table>

### AISeatState [#aiseatstate]

Actions: `create`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>first_used_at</code></td><td>Yes</td></tr>
<tr><td><code>last_event_description</code></td><td>Yes</td></tr>
<tr><td><code>last_event_type</code></td><td>Yes</td></tr>
<tr><td><code>last_used_at</code></td><td>No</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>user_id</code></td><td>Yes</td></tr>
</tbody>
</table>

### APIKey [#apikey]

Actions: `login`, `logout`, `register`, `create`, `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>allow_list</code></td><td>No</td></tr>
<tr><td><code>created_at</code></td><td>Yes</td></tr>
<tr><td><code>expires_at</code></td><td>Yes</td></tr>
<tr><td><code>hashed_secret</code></td><td>No</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>ip_address</code></td><td>No</td></tr>
<tr><td><code>last_used</code></td><td>Yes</td></tr>
<tr><td><code>lifetime_seconds</code></td><td>No</td></tr>
<tr><td><code>login_type</code></td><td>No</td></tr>
<tr><td><code>scopes</code></td><td>No</td></tr>
<tr><td><code>token_name</code></td><td>No</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>user_id</code></td><td>Yes</td></tr>
</tbody>
</table>

### AuditOAuthConvertState [#auditoauthconvertstate]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>Yes</td></tr>
<tr><td><code>expires_at</code></td><td>Yes</td></tr>
<tr><td><code>from_login_type</code></td><td>Yes</td></tr>
<tr><td><code>to_login_type</code></td><td>Yes</td></tr>
<tr><td><code>user_id</code></td><td>Yes</td></tr>
</tbody>
</table>

### AuditableChatProjectInstructions [#auditablechatprojectinstructions]

Actions: `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>instructions</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>No</td></tr>
<tr><td><code>project_id</code></td><td>No</td></tr>
<tr><td><code>project_name</code></td><td>No</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>updated_by</code></td><td>No</td></tr>
</tbody>
</table>

### Group [#group]

Actions: `create`, `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>avatar_url</code></td><td>Yes</td></tr>
<tr><td><code>chat_spend_limit_micros</code></td><td>Yes</td></tr>
<tr><td><code>display_name</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>members</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>No</td></tr>
<tr><td><code>quota_allowance</code></td><td>Yes</td></tr>
<tr><td><code>source</code></td><td>No</td></tr>
</tbody>
</table>

### AuditableGroupAIBudget [#auditablegroupaibudget]

Actions: `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>group_id</code></td><td>No</td></tr>
<tr><td><code>group_name</code></td><td>No</td></tr>
<tr><td><code>spend_limit</code></td><td>Yes</td></tr>
<tr><td><code>spend_limit_micros</code></td><td>No</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
</tbody>
</table>

### AuditableOrganizationMember [#auditableorganizationmember]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>No</td></tr>
<tr><td><code>roles</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>Yes</td></tr>
<tr><td><code>user_id</code></td><td>Yes</td></tr>
<tr><td><code>username</code></td><td>Yes</td></tr>
</tbody>
</table>

### AuditableOrganizationSkill [#auditableorganizationskill]

Actions: `create`, `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>content</code></td><td>Yes</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>description</code></td><td>Yes</td></tr>
<tr><td><code>enabled</code></td><td>Yes</td></tr>
<tr><td><code>group_acl</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>Yes</td></tr>
<tr><td><code>project_id</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>user_acl</code></td><td>Yes</td></tr>
<tr><td><code>user_id</code></td><td>Yes</td></tr>
</tbody>
</table>

### AuditableUserAIBudgetOverride [#auditableuseraibudgetoverride]

Actions: `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>group_id</code></td><td>Yes</td></tr>
<tr><td><code>group_name</code></td><td>Yes</td></tr>
<tr><td><code>spend_limit</code></td><td>Yes</td></tr>
<tr><td><code>spend_limit_micros</code></td><td>No</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>user_id</code></td><td>No</td></tr>
<tr><td><code>username</code></td><td>No</td></tr>
</tbody>
</table>

### Chat [#chat]

Actions: `create`, `write`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>agent_id</code></td><td>No</td></tr>
<tr><td><code>archived</code></td><td>Yes</td></tr>
<tr><td><code>build_id</code></td><td>No</td></tr>
<tr><td><code>client_type</code></td><td>No</td></tr>
<tr><td><code>compaction_requested_at</code></td><td>No</td></tr>
<tr><td><code>context_aggregate_hash</code></td><td>No</td></tr>
<tr><td><code>context_dirty_resources</code></td><td>No</td></tr>
<tr><td><code>context_dirty_since</code></td><td>No</td></tr>
<tr><td><code>context_error</code></td><td>No</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>dynamic_tools</code></td><td>No</td></tr>
<tr><td><code>generation_attempt</code></td><td>No</td></tr>
<tr><td><code>group_acl</code></td><td>Yes</td></tr>
<tr><td><code>heartbeat_at</code></td><td>No</td></tr>
<tr><td><code>history_version</code></td><td>No</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>labels</code></td><td>Yes</td></tr>
<tr><td><code>last_error</code></td><td>No</td></tr>
<tr><td><code>last_model_config_id</code></td><td>No</td></tr>
<tr><td><code>last_read_message_id</code></td><td>No</td></tr>
<tr><td><code>last_reasoning_effort</code></td><td>No</td></tr>
<tr><td><code>last_turn_summary</code></td><td>No</td></tr>
<tr><td><code>mcp_server_ids</code></td><td>Yes</td></tr>
<tr><td><code>mode</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>No</td></tr>
<tr><td><code>owner_id</code></td><td>Yes</td></tr>
<tr><td><code>owner_name</code></td><td>No</td></tr>
<tr><td><code>owner_username</code></td><td>No</td></tr>
<tr><td><code>parent_chat_id</code></td><td>No</td></tr>
<tr><td><code>pin_order</code></td><td>Yes</td></tr>
<tr><td><code>plan_mode</code></td><td>No</td></tr>
<tr><td><code>project_id</code></td><td>Yes</td></tr>
<tr><td><code>queue_version</code></td><td>No</td></tr>
<tr><td><code>requires_action_deadline_at</code></td><td>No</td></tr>
<tr><td><code>retry_state</code></td><td>No</td></tr>
<tr><td><code>retry_state_version</code></td><td>No</td></tr>
<tr><td><code>root_chat_id</code></td><td>No</td></tr>
<tr><td><code>runner_id</code></td><td>No</td></tr>
<tr><td><code>snapshot_version</code></td><td>No</td></tr>
<tr><td><code>started_at</code></td><td>No</td></tr>
<tr><td><code>status</code></td><td>No</td></tr>
<tr><td><code>summary</code></td><td>No</td></tr>
<tr><td><code>summary_generated_at</code></td><td>No</td></tr>
<tr><td><code>title</code></td><td>Yes</td></tr>
<tr><td><code>title_source</code></td><td>Yes</td></tr>
<tr><td><code>title_updated_at</code></td><td>No</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>user_acl</code></td><td>Yes</td></tr>
<tr><td><code>worker_id</code></td><td>No</td></tr>
<tr><td><code>workspace_id</code></td><td>Yes</td></tr>
</tbody>
</table>

### ChatInstructionSettings [#chatinstructionsettings]

Actions: `write`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>include_default_system_prompt</code></td><td>Yes</td></tr>
<tr><td><code>include_default_system_prompt_set</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>No</td></tr>
<tr><td><code>plan_mode_instructions</code></td><td>Yes</td></tr>
<tr><td><code>system_prompt</code></td><td>Yes</td></tr>
</tbody>
</table>

### ChatModelConfig [#chatmodelconfig]

Actions: `create`, `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>ai_provider_id</code></td><td>Yes</td></tr>
<tr><td><code>compression_threshold</code></td><td>Yes</td></tr>
<tr><td><code>context_limit</code></td><td>Yes</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>created_by</code></td><td>Yes</td></tr>
<tr><td><code>deleted</code></td><td>Yes</td></tr>
<tr><td><code>deleted_at</code></td><td>No</td></tr>
<tr><td><code>display_name</code></td><td>Yes</td></tr>
<tr><td><code>enabled</code></td><td>Yes</td></tr>
<tr><td><code>group_acl</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>is_default</code></td><td>Yes</td></tr>
<tr><td><code>model</code></td><td>Yes</td></tr>
<tr><td><code>options</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>No</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>updated_by</code></td><td>Yes</td></tr>
<tr><td><code>user_acl</code></td><td>Yes</td></tr>
</tbody>
</table>

### ChatOperationalSettings [#chatoperationalsettings]

Actions: `write`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>chat_auto_archive_days</code></td><td>Yes</td></tr>
<tr><td><code>chat_debug_retention_days</code></td><td>Yes</td></tr>
<tr><td><code>chat_retention_days</code></td><td>Yes</td></tr>
<tr><td><code>computer_use_provider</code></td><td>Yes</td></tr>
<tr><td><code>debug_logging_allow_users</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>personal_model_overrides_enabled</code></td><td>Yes</td></tr>
<tr><td><code>workspace_ttl</code></td><td>Yes</td></tr>
</tbody>
</table>

### ChatOrganizationSystemPrompt [#chatorganizationsystemprompt]

Actions: `write`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>organization_id</code></td><td>No</td></tr>
<tr><td><code>system_prompt</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
</tbody>
</table>

### ChatProject [#chatproject]

Actions: `create`, `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>description</code></td><td>Yes</td></tr>
<tr><td><code>group_acl</code></td><td>Yes</td></tr>
<tr><td><code>icon</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>Yes</td></tr>
<tr><td><code>owner_id</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>user_acl</code></td><td>Yes</td></tr>
</tbody>
</table>

### ChatProjectMemory [#chatprojectmemory]

Actions: `create`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>body</code></td><td>Yes</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>created_by</code></td><td>Yes</td></tr>
<tr><td><code>description</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>Yes</td></tr>
<tr><td><code>project_id</code></td><td>Yes</td></tr>
</tbody>
</table>

### CustomRole [#customrole]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>display_name</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>is_system</code></td><td>No</td></tr>
<tr><td><code>member_permissions</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>org_permissions</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>No</td></tr>
<tr><td><code>site_permissions</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>user_permissions</code></td><td>Yes</td></tr>
</tbody>
</table>

### ExperimentRule [#experimentrule]

Actions: `write`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>condition</code></td><td>Yes</td></tr>
<tr><td><code>experiment</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>mode</code></td><td>Yes</td></tr>
<tr><td><code>revision</code></td><td>Yes</td></tr>
</tbody>
</table>

### GitSSHKey [#gitsshkey]

Actions: `create`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>private_key</code></td><td>Yes</td></tr>
<tr><td><code>private_key_key_id</code></td><td>No</td></tr>
<tr><td><code>public_key</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>user_id</code></td><td>Yes</td></tr>
</tbody>
</table>

### GroupSyncSettings [#groupsyncsettings]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>auto_create_missing_groups</code></td><td>Yes</td></tr>
<tr><td><code>field</code></td><td>Yes</td></tr>
<tr><td><code>legacy_group_name_mapping</code></td><td>No</td></tr>
<tr><td><code>mapping</code></td><td>Yes</td></tr>
<tr><td><code>regex_filter</code></td><td>Yes</td></tr>
</tbody>
</table>

### HealthSettings [#healthsettings]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>dismissed_healthchecks</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
</tbody>
</table>

### License [#license]

Actions: `create`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>exp</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>jwt</code></td><td>No</td></tr>
<tr><td><code>uploaded_at</code></td><td>Yes</td></tr>
<tr><td><code>uuid</code></td><td>Yes</td></tr>
</tbody>
</table>

### MCPServerConfig [#mcpserverconfig]

Actions: `create`, `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>allow_in_plan_mode</code></td><td>Yes</td></tr>
<tr><td><code>api_key_header</code></td><td>Yes</td></tr>
<tr><td><code>api_key_value</code></td><td>Yes</td></tr>
<tr><td><code>api_key_value_key_id</code></td><td>No</td></tr>
<tr><td><code>auth_type</code></td><td>Yes</td></tr>
<tr><td><code>availability</code></td><td>Yes</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>created_by</code></td><td>Yes</td></tr>
<tr><td><code>custom_headers</code></td><td>Yes</td></tr>
<tr><td><code>custom_headers_key_id</code></td><td>No</td></tr>
<tr><td><code>description</code></td><td>Yes</td></tr>
<tr><td><code>display_name</code></td><td>Yes</td></tr>
<tr><td><code>enabled</code></td><td>Yes</td></tr>
<tr><td><code>forward_coder_headers</code></td><td>Yes</td></tr>
<tr><td><code>group_acl</code></td><td>Yes</td></tr>
<tr><td><code>icon_url</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>model_intent</code></td><td>Yes</td></tr>
<tr><td><code>oauth2_auth_url</code></td><td>Yes</td></tr>
<tr><td><code>oauth2_client_id</code></td><td>Yes</td></tr>
<tr><td><code>oauth2_client_secret</code></td><td>Yes</td></tr>
<tr><td><code>oauth2_client_secret_key_id</code></td><td>No</td></tr>
<tr><td><code>oauth2_resource</code></td><td>Yes</td></tr>
<tr><td><code>oauth2_revocation_url</code></td><td>Yes</td></tr>
<tr><td><code>oauth2_scopes</code></td><td>Yes</td></tr>
<tr><td><code>oauth2_token_url</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>No</td></tr>
<tr><td><code>signing_secret</code></td><td>Yes</td></tr>
<tr><td><code>signing_secret_key_id</code></td><td>No</td></tr>
<tr><td><code>slug</code></td><td>Yes</td></tr>
<tr><td><code>tool_allow_list</code></td><td>Yes</td></tr>
<tr><td><code>tool_deny_list</code></td><td>Yes</td></tr>
<tr><td><code>transport</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>updated_by</code></td><td>Yes</td></tr>
<tr><td><code>url</code></td><td>Yes</td></tr>
<tr><td><code>user_acl</code></td><td>Yes</td></tr>
</tbody>
</table>

### NotificationTemplate [#notificationtemplate]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>actions</code></td><td>Yes</td></tr>
<tr><td><code>body_template</code></td><td>Yes</td></tr>
<tr><td><code>enabled_by_default</code></td><td>Yes</td></tr>
<tr><td><code>group</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>kind</code></td><td>Yes</td></tr>
<tr><td><code>method</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>title_template</code></td><td>Yes</td></tr>
</tbody>
</table>

### NotificationsSettings [#notificationssettings]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>notifier_paused</code></td><td>Yes</td></tr>
</tbody>
</table>

### OAuth2ProviderApp [#oauth2providerapp]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>callback_url</code></td><td>Yes</td></tr>
<tr><td><code>client_id_issued_at</code></td><td>No</td></tr>
<tr><td><code>client_secret_expires_at</code></td><td>Yes</td></tr>
<tr><td><code>client_type</code></td><td>Yes</td></tr>
<tr><td><code>client_uri</code></td><td>Yes</td></tr>
<tr><td><code>contacts</code></td><td>Yes</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>dynamically_registered</code></td><td>Yes</td></tr>
<tr><td><code>grant_types</code></td><td>Yes</td></tr>
<tr><td><code>icon</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>jwks</code></td><td>Yes</td></tr>
<tr><td><code>jwks_uri</code></td><td>Yes</td></tr>
<tr><td><code>logo_uri</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>policy_uri</code></td><td>Yes</td></tr>
<tr><td><code>redirect_uris</code></td><td>Yes</td></tr>
<tr><td><code>registration_access_token</code></td><td>Yes</td></tr>
<tr><td><code>registration_client_uri</code></td><td>Yes</td></tr>
<tr><td><code>response_types</code></td><td>Yes</td></tr>
<tr><td><code>scope</code></td><td>Yes</td></tr>
<tr><td><code>software_id</code></td><td>Yes</td></tr>
<tr><td><code>software_version</code></td><td>Yes</td></tr>
<tr><td><code>token_endpoint_auth_method</code></td><td>Yes</td></tr>
<tr><td><code>tos_uri</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
</tbody>
</table>

### OAuth2ProviderAppSecret [#oauth2providerappsecret]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>app_id</code></td><td>No</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>display_secret</code></td><td>No</td></tr>
<tr><td><code>hashed_secret</code></td><td>No</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>last_used_at</code></td><td>No</td></tr>
<tr><td><code>secret_prefix</code></td><td>No</td></tr>
</tbody>
</table>

### OAuth2ProviderSettings [#oauth2providersettings]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>dynamic_client_registration_enabled</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
</tbody>
</table>

### Organization [#organization]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>default_org_member_roles</code></td><td>Yes</td></tr>
<tr><td><code>deleted</code></td><td>Yes</td></tr>
<tr><td><code>description</code></td><td>Yes</td></tr>
<tr><td><code>display_name</code></td><td>Yes</td></tr>
<tr><td><code>icon</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>is_default</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>shareable_workspace_owners</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>Yes</td></tr>
</tbody>
</table>

### OrganizationSyncSettings [#organizationsyncsettings]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>assign_default</code></td><td>Yes</td></tr>
<tr><td><code>field</code></td><td>Yes</td></tr>
<tr><td><code>mapping</code></td><td>Yes</td></tr>
</tbody>
</table>

### PrebuildsSettings [#prebuildssettings]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>reconciliation_paused</code></td><td>Yes</td></tr>
</tbody>
</table>

### RoleSyncSettings [#rolesyncsettings]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>field</code></td><td>Yes</td></tr>
<tr><td><code>mapping</code></td><td>Yes</td></tr>
</tbody>
</table>

### Skill [#skill]

Actions: `create`, `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>content</code></td><td>Yes</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>description</code></td><td>Yes</td></tr>
<tr><td><code>enabled</code></td><td>Yes</td></tr>
<tr><td><code>group_acl</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>Yes</td></tr>
<tr><td><code>project_id</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>user_acl</code></td><td>Yes</td></tr>
<tr><td><code>user_id</code></td><td>Yes</td></tr>
</tbody>
</table>

### Template [#template]

Actions: `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>active_version_id</code></td><td>Yes</td></tr>
<tr><td><code>activity_bump</code></td><td>Yes</td></tr>
<tr><td><code>agents_allowed</code></td><td>Yes</td></tr>
<tr><td><code>allow_user_autostart</code></td><td>Yes</td></tr>
<tr><td><code>allow_user_autostop</code></td><td>Yes</td></tr>
<tr><td><code>allow_user_cancel_workspace_jobs</code></td><td>Yes</td></tr>
<tr><td><code>allow_workspace_renames</code></td><td>Yes</td></tr>
<tr><td><code>autostart_block_days_of_week</code></td><td>Yes</td></tr>
<tr><td><code>autostop_requirement_days_of_week</code></td><td>Yes</td></tr>
<tr><td><code>autostop_requirement_weeks</code></td><td>Yes</td></tr>
<tr><td><code>cors_behavior</code></td><td>Yes</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>created_by</code></td><td>Yes</td></tr>
<tr><td><code>created_by_avatar_url</code></td><td>No</td></tr>
<tr><td><code>created_by_name</code></td><td>No</td></tr>
<tr><td><code>created_by_username</code></td><td>No</td></tr>
<tr><td><code>default_ttl</code></td><td>Yes</td></tr>
<tr><td><code>deleted</code></td><td>No</td></tr>
<tr><td><code>deprecated</code></td><td>Yes</td></tr>
<tr><td><code>description</code></td><td>Yes</td></tr>
<tr><td><code>disable_module_cache</code></td><td>Yes</td></tr>
<tr><td><code>display_name</code></td><td>Yes</td></tr>
<tr><td><code>failure_ttl</code></td><td>Yes</td></tr>
<tr><td><code>group_acl</code></td><td>Yes</td></tr>
<tr><td><code>icon</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>max_port_sharing_level</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>organization_display_name</code></td><td>No</td></tr>
<tr><td><code>organization_icon</code></td><td>No</td></tr>
<tr><td><code>organization_id</code></td><td>No</td></tr>
<tr><td><code>organization_name</code></td><td>No</td></tr>
<tr><td><code>provisioner</code></td><td>Yes</td></tr>
<tr><td><code>require_active_version</code></td><td>Yes</td></tr>
<tr><td><code>time_til_autostop_notify</code></td><td>Yes</td></tr>
<tr><td><code>time_til_dormant</code></td><td>Yes</td></tr>
<tr><td><code>time_til_dormant_autodelete</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>use_classic_parameter_flow</code></td><td>Yes</td></tr>
<tr><td><code>user_acl</code></td><td>Yes</td></tr>
</tbody>
</table>

### TemplateVersion [#templateversion]

Actions: `create`, `write`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>archived</code></td><td>Yes</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>created_by</code></td><td>Yes</td></tr>
<tr><td><code>created_by_avatar_url</code></td><td>No</td></tr>
<tr><td><code>created_by_name</code></td><td>No</td></tr>
<tr><td><code>created_by_username</code></td><td>No</td></tr>
<tr><td><code>external_auth_providers</code></td><td>No</td></tr>
<tr><td><code>has_external_agent</code></td><td>No</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>job_id</code></td><td>No</td></tr>
<tr><td><code>message</code></td><td>No</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>No</td></tr>
<tr><td><code>readme</code></td><td>Yes</td></tr>
<tr><td><code>script_order_data_source_count</code></td><td>No</td></tr>
<tr><td><code>script_order_rule_count</code></td><td>No</td></tr>
<tr><td><code>source_example_id</code></td><td>No</td></tr>
<tr><td><code>template_id</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
</tbody>
</table>

### User [#user]

Actions: `create`, `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>avatar_url</code></td><td>No</td></tr>
<tr><td><code>chat_spend_limit_micros</code></td><td>Yes</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>deleted</code></td><td>Yes</td></tr>
<tr><td><code>email</code></td><td>Yes</td></tr>
<tr><td><code>github_com_user_id</code></td><td>No</td></tr>
<tr><td><code>hashed_one_time_passcode</code></td><td>No</td></tr>
<tr><td><code>hashed_password</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>is_service_account</code></td><td>Yes</td></tr>
<tr><td><code>is_system</code></td><td>Yes</td></tr>
<tr><td><code>last_seen_at</code></td><td>No</td></tr>
<tr><td><code>login_type</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>one_time_passcode_expires_at</code></td><td>Yes</td></tr>
<tr><td><code>quiet_hours_schedule</code></td><td>Yes</td></tr>
<tr><td><code>rbac_roles</code></td><td>Yes</td></tr>
<tr><td><code>status</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>username</code></td><td>Yes</td></tr>
</tbody>
</table>

### UserSecret [#usersecret]

Actions: `create`, `write`, `delete`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>description</code></td><td>Yes</td></tr>
<tr><td><code>enabled</code></td><td>Yes</td></tr>
<tr><td><code>env_name</code></td><td>Yes</td></tr>
<tr><td><code>file_path</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>user_id</code></td><td>Yes</td></tr>
<tr><td><code>value</code></td><td>Yes</td></tr>
<tr><td><code>value_key_id</code></td><td>No</td></tr>
</tbody>
</table>

### WorkspaceBuild [#workspacebuild]

Actions: `start`, `stop`

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>build_number</code></td><td>No</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>daily_cost</code></td><td>No</td></tr>
<tr><td><code>deadline</code></td><td>No</td></tr>
<tr><td><code>has_external_agent</code></td><td>No</td></tr>
<tr><td><code>id</code></td><td>No</td></tr>
<tr><td><code>initiator_by_avatar_url</code></td><td>No</td></tr>
<tr><td><code>initiator_by_name</code></td><td>No</td></tr>
<tr><td><code>initiator_by_username</code></td><td>No</td></tr>
<tr><td><code>initiator_id</code></td><td>No</td></tr>
<tr><td><code>job_id</code></td><td>No</td></tr>
<tr><td><code>max_deadline</code></td><td>No</td></tr>
<tr><td><code>notified_autostop_deadline</code></td><td>No</td></tr>
<tr><td><code>reason</code></td><td>No</td></tr>
<tr><td><code>template_version_id</code></td><td>Yes</td></tr>
<tr><td><code>template_version_preset_id</code></td><td>No</td></tr>
<tr><td><code>transition</code></td><td>No</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>workspace_id</code></td><td>No</td></tr>
</tbody>
</table>

### WorkspaceProxy [#workspaceproxy]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>created_at</code></td><td>Yes</td></tr>
<tr><td><code>deleted</code></td><td>No</td></tr>
<tr><td><code>derp_enabled</code></td><td>Yes</td></tr>
<tr><td><code>derp_only</code></td><td>Yes</td></tr>
<tr><td><code>display_name</code></td><td>Yes</td></tr>
<tr><td><code>icon</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>region_id</code></td><td>Yes</td></tr>
<tr><td><code>token_hashed_secret</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>url</code></td><td>Yes</td></tr>
<tr><td><code>version</code></td><td>Yes</td></tr>
<tr><td><code>wildcard_hostname</code></td><td>Yes</td></tr>
</tbody>
</table>

### WorkspaceTable [#workspacetable]

<table width="100%">
<thead><tr><th width="75%">Field</th><th width="25%">Tracked</th></tr></thead>
<tbody>
<tr><td><code>automatic_updates</code></td><td>Yes</td></tr>
<tr><td><code>autostart_schedule</code></td><td>Yes</td></tr>
<tr><td><code>created_at</code></td><td>No</td></tr>
<tr><td><code>deleted</code></td><td>No</td></tr>
<tr><td><code>deleting_at</code></td><td>Yes</td></tr>
<tr><td><code>dormant_at</code></td><td>Yes</td></tr>
<tr><td><code>favorite</code></td><td>Yes</td></tr>
<tr><td><code>group_acl</code></td><td>Yes</td></tr>
<tr><td><code>id</code></td><td>Yes</td></tr>
<tr><td><code>last_used_at</code></td><td>No</td></tr>
<tr><td><code>name</code></td><td>Yes</td></tr>
<tr><td><code>next_start_at</code></td><td>Yes</td></tr>
<tr><td><code>organization_id</code></td><td>No</td></tr>
<tr><td><code>owner_id</code></td><td>Yes</td></tr>
<tr><td><code>template_id</code></td><td>Yes</td></tr>
<tr><td><code>ttl</code></td><td>Yes</td></tr>
<tr><td><code>updated_at</code></td><td>No</td></tr>
<tr><td><code>user_acl</code></td><td>Yes</td></tr>
</tbody>
</table>

## How to Filter Audit Logs [#how-to-filter-audit-logs]

You can filter audit logs by the following parameters:

* `resource_type` - The type of the resource, such as a workspace, template,
  or user. For more resource types, refer to the
  [CoderSDK package documentation](https://pkg.go.dev/github.com/coder/coder/v2/codersdk#ResourceType).
* `resource_id` - The ID of the resource.
* `resource_target` - The name of the resource. Can be used instead of
  `resource_id`.
* `action`- The action applied to a resource, such as `create` or `delete`.
  For more actions, refer to the
  [CoderSDK package documentation](https://pkg.go.dev/github.com/coder/coder/v2/codersdk#AuditAction).
* `username` - The username of the user who triggered the action. You can also
  use `me` as a convenient alias for the logged-in user.
* `email` - The email of the user who triggered the action.
* `date_from` - The inclusive start date with format `YYYY-MM-DD`.
* `date_to` - The inclusive end date with format `YYYY-MM-DD`.
* `build_reason` - The reason for the workspace build, if `resource_type` is
  `workspace_build`. Refer to the
  [CoderSDK package documentation](https://pkg.go.dev/github.com/coder/coder/v2/codersdk#BuildReason)
  for a list of valid build reasons.

<a id="capturingexporting-audit-logs"></a>

## Capture and export audit logs [#capture-and-export-audit-logs]

In addition to the Coder dashboard, there are multiple ways to consume or query
audit trails.

### REST API [#rest-api]

You can retrieve audit logs via the Coder API.

Visit the
[`get-audit-logs` endpoint documentation](/beta-docs/@main/reference/api/audit/#get-audit-logs)
for details.

### Service Logs [#service-logs]

Audit trails are also dispatched as service logs and can be captured and
categorized using any log management tool such as [Splunk](https://splunk.com).

Example of a [JSON formatted](/beta-docs/@main/reference/cli/server/#--log-json) audit
log entry:

```json
{
    "ts": "2023-06-13T03:45:37.294730279Z",
    "level": "INFO",
    "msg": "audit_log",
    "caller": "/home/coder/coder/enterprise/audit/backends/slog.go:38",
    "func": "github.com/coder/coder/v2/enterprise/audit/backends.(*SlogExporter).ExportStruct",
    "logger_names": ["coderd"],
    "fields": {
        "ID": "033a9ffa-b54d-4c10-8ec3-2aaf9e6d741a",
        "Time": "2023-06-13T03:45:37.288506Z",
        "UserID": "6c405053-27e3-484a-9ad7-bcb64e7bfde6",
        "OrganizationID": "00000000-0000-0000-0000-000000000000",
        "Ip": null,
        "UserAgent": null,
        "ResourceType": "workspace_build",
        "ResourceID": "ca5647e0-ef50-4202-a246-717e04447380",
        "ResourceTarget": "",
        "Action": "start",
        "Diff": {},
        "StatusCode": 200,
        "AdditionalFields": {
            "workspace_name": "linux-container",
            "build_number": "9",
            "build_reason": "initiator",
            "workspace_owner": ""
        },
        "RequestID": "bb791ac3-f6ee-4da8-8ec2-f54e87013e93",
        "ResourceIcon": ""
    }
}
```

Example of a [human readable](/beta-docs/@main/reference/cli/server/#--log-human) audit
log entry:

```console
2023-06-13 03:43:29.233 [info]  coderd: audit_log  ID=95f7c392-da3e-480c-a579-8909f145fbe2  Time="2023-06-13T03:43:29.230422Z"  UserID=6c405053-27e3-484a-9ad7-bcb64e7bfde6  OrganizationID=00000000-0000-0000-0000-000000000000  Ip=<nil>  UserAgent=<nil>  ResourceType=workspace_build  ResourceID=988ae133-5b73-41e3-a55e-e1e9d3ef0b66  ResourceTarget=""  Action=start  Diff="{}"  StatusCode=200  AdditionalFields="{\"workspace_name\":\"linux-container\",\"build_number\":\"7\",\"build_reason\":\"initiator\",\"workspace_owner\":\"\"}"  RequestID=9682b1b5-7b9f-4bf2-9a39-9463f8e41cd6  ResourceIcon=""
```

<a id="purging-old-audit-logs"></a>

## Purge old audit logs [#purge-old-audit-logs]

<Callout type="warn" title="Warning">
  Audit Logs provide critical security and compliance information. Purging Audit Logs may impact your organization's ability
  to investigate security incidents or meet compliance requirements. Consult your security and compliance teams before purging any audit data.
</Callout>

### Data Retention [#data-retention]

Coder supports configurable retention policies that automatically purge old
Audit Logs. To enable automated purging, configure the
`--audit-logs-retention` flag or `CODER_AUDIT_LOGS_RETENTION` environment
variable. For comprehensive configuration options, see
[Data Retention](/beta-docs/@main/admin/setup/data-retention/).

### Manual Purging [#manual-purging]

Alternatively, you can purge Audit Logs manually by running SQL queries
directly against the database.

Audit Logs can account for a large amount of disk usage. Use the following
query to determine the amount of disk space used by the `audit_logs` table.

```sql
SELECT
    relname AS table_name,
    pg_size_pretty(pg_total_relation_size(relid)) AS total_size,
    pg_size_pretty(pg_relation_size(relid)) AS table_size,
    pg_size_pretty(pg_indexes_size(relid)) AS indexes_size,
    (SELECT COUNT(*) FROM audit_logs) AS total_records
FROM pg_catalog.pg_statio_user_tables
WHERE relname = 'audit_logs'
ORDER BY pg_total_relation_size(relid) DESC;
```

Should you wish to purge these records, it is safe to do so. This can only be done by running SQL queries
directly against the `audit_logs` table in the database. We advise users to only purge old records (>1yr)
and in accordance with your compliance requirements.

### Maintenance Procedures for the Audit Logs Table [#maintenance-procedures-for-the-audit-logs-table]

<Callout type="info" title="Note">
  `VACUUM FULL` acquires an exclusive lock on the table, blocking all reads and writes. For more information, see the [PostgreSQL VACUUM documentation](https://www.postgresql.org/docs/current/sql-vacuum.html).
</Callout>

You may choose to run a `VACUUM` or `VACUUM FULL` operation on the audit logs table to reclaim disk space. If you choose to run the `FULL` operation, consider the following when doing so:

* **Run during a planned maintenance window** to ensure ample time for the operation to complete and minimize impact to users

* **Stop all running instances of `coderd`** to prevent connection errors while the table is locked. The actual steps for this will depend on your particular deployment setup. For example, if your `coderd` deployment is running on Kubernetes:

  ```sh
  kubectl scale deployment coder --replicas=0 -n coder
  ```

* **Terminate lingering connections** before running the `VACUUM` operation to ensure it starts immediately

  ```sql
  SELECT pg_terminate_backend(pg_stat_activity.pid)
  FROM pg_stat_activity
  WHERE pg_stat_activity.datname = 'coder' AND pid <> pg_backend_pid();
  ```

* **Only `coderd` needs to scale down** - external provisioner daemons, workspace proxies, and workspace agents don't connect to the database directly.

After the vacuum completes, scale coderd back up:

```sh
kubectl scale deployment coder --replicas= -n coder
```

### Backup/Archive [#backuparchive]

Consider exporting or archiving these records before deletion:

```sql
-- Export to CSV
COPY (SELECT * FROM audit_logs WHERE time < CURRENT_TIMESTAMP - INTERVAL '1 year')
TO '/path/to/audit_logs_archive.csv' DELIMITER ',' CSV HEADER;

-- Copy to archive table
CREATE TABLE audit_logs_archive AS
SELECT * FROM audit_logs WHERE time < CURRENT_TIMESTAMP - INTERVAL '1 year';
```

### Permanent Deletion [#permanent-deletion]

<Callout type="info" title="Note">
  For large `audit_logs` tables, consider running the `DELETE` operation during maintenance windows as it may impact
  database performance. You can also batch the deletions to reduce lock time.
</Callout>

```sql
DELETE FROM audit_logs WHERE time < CURRENT_TIMESTAMP - INTERVAL '1 year';
-- Consider running `VACUUM VERBOSE audit_logs` afterwards for large datasets to reclaim disk space.
```

## How to Enable Audit Logs [#how-to-enable-audit-logs]

This feature is only available with a [Premium license](/beta-docs/@main/install/prepare/licensing/), and is automatically enabled.
