> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/harness-cli-commands/audit.md).

# Audit

Use the Harness CLI to read the audit trail, filter audit events, and inspect change diffs.

Use the Harness CLI to read the audit trail, filter audit events by date, resource type, action, and principal, and inspect the YAML diff of a change.

The Harness audit trail records every create, update, and delete across every Harness module. The CLI gives you read-only access to that trail, so you can answer who changed what and when from your terminal or from a script, and inspect the exact YAML diff of a change.

This page covers all Audit resources and actions available in the CLI.

***

## What you will learn in this topic

By the end of this page, you will know how to:

* List audit events and understand the default time window.
* Filter events by date range, resource type, action, and principal.
* Retrieve a single event with the YAML diff of the change.

***

## Before you begin

* **Harness CLI installed and authenticated:** Go to [Install and upgrade](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/overview.md) and [Authenticate](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/authenticate-the-harness-cli.md) for setup steps.
* **Audit view permissions:** Reading the audit trail requires view access on the audit trail at the scope you query. Go to [Audit trail](https://developer.harness.io/harness-platform/use-harness-platform/governance/audit-trail/audit-trail) for the permission model.

***

## Audit events

An audit event is one recorded change to one resource. Every create, update, and delete in Harness produces an event, and the audit trail is read-only: you can query events but never modify them.

### List audit events

By default the command returns events from the last seven days.

```shell
harness list audit_event 
harness list audit_event --all --format json 
harness list audit_event --limit 50
```

### Filter audit events

Narrow the trail with these flags:

* `--from`: Start of the time window.
* `--to`: End of the time window.
* `--resource-type`: Restricts results to one resource type.
* `--action`: Restricts results to one action, such as a create or a delete.
* `--principal`: Restricts results to changes made by one user or service account.

```shell
harness list audit_event --from <start_date> --to <end_date>
harness list audit_event --resource-type <resource_type>
harness list audit_event --action <action>
harness list audit_event --principal <email|uid|id>
harness list audit_event --resource-type <resource_type> --action <action> --from <start_date>
```

### Get an audit event

Retrieve a single event. The response includes the YAML diff of the change, so you can see the before and after state of the resource.

```shell
harness get audit_event <audit_event_id>
harness get audit_event <audit_event_id> --format json
```

***

## Troubleshooting

* **No events returned for the expected time window:** The `list audit_event` command defaults to the last seven days, since that is the default time window. Pass `--from` and `--to` to widen the range.
* **Permission denied when querying the audit trail:** Confirm the principal has view access on the audit trail at the scope you query, since audit view permissions are scope-specific.
* **A YAML diff is missing from a `get audit_event` response:** Not every action type captures a full before and after state, since some resource types do not support YAML diffs.

## Related concepts

* [Governance](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/harness-cli-commands/governance.md): Manage the OPA policies that gate the changes the audit trail records.
* [Audit trail](https://developer.harness.io/harness-platform/use-harness-platform/governance/audit-trail/audit-trail): Understand the full audit model and streaming options.
* [Platform](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/harness-cli-commands/platform.md): Manage account resources, connectors, and secrets.
