# Audit actions

The organisation’s audit trail: who did what to which resource, and when.

Its operations need the scope `audit.view`.

**Endpoints**

- `GET/v1/audit-actions`

## List audit actions

GET/v1/audit-actions

Returns the organisation’s audit trail, newest first by default (by date, then the order recorded), as the console’s Audit page shows it to a member holding `audit.view`: who or what did each action, to which resource, through which channel, the fields it changed with their old and new values, what else it recorded, the lane it belongs to and the IP address it came from. Filter by resource (`entity_type` and `entity_uuid`, a deleted resource’s too, or `resource`, a search of resource names), by actor (`actor_uuid`), by exact action code, by category (`GET /v1/audit-categories`), by lane and by time window, and order with `direction`. The user agent, the request URL and the raw metadata are never answered, nor are the identifiers the console hides. The key needs the `audit.view` scope, and its issuer must hold that permission. Pages by `page` and `per_page` (`limit` is the same as `per_page`); every page carries `current_page`, `per_page`, `last_page` and `total`.

Needs the scope `audit.view`.

### Query parameters

- `entity_type` (string or null): The type of the resource whose audit actions to list, such as `server`, `database_instance` or `log_source`; required with `entity_uuid`. More types may be added. Values:`server``domain``service``log_source``custom_metric``database_instance``metric_source``server_profile``report``server_port``server_volume``server_system_service``dashboard``tag``tag_group``alarm_policy``alarm_channel``contact_group``role``user``organisation`(an open set: new values may be added)
- `entity_uuid` (string (uuid) or null): The uuid of the resource whose audit actions to list, a deleted one too; required with `entity_type`.
- `actor_uuid` (string (uuid) or null): Only the actions of this person or service account, by user uuid; a removed member’s too.
- `category` (string or null): Only the actions of this category, by its `slug` (`GET /v1/audit-categories`). Values:`auth``sso``mfa``domain``service``server``server_profile``log_source``tag``dashboard``custom_metric``metric_source``database_instance``report``alarm_rule``alarm_policy``alarm_incident``health``alarm_channel``contact_group``organisation``user``role``invitation``ai_access``billing``email``api_token``system`(an open set: new values may be added)
- `lane` (string or null): Only the actions of this lane of the Audit page: `changes`, `alarms`, `incidents`, `health` or `lifecycle`. Values:`changes``alarms``incidents``health``lifecycle`(an open set: new values may be added)
- `resource` (string or null): Only the actions about a resource whose name contains this text (the Audit page’s resource search, not case sensitive, at most 100 characters).
- `direction` (string or null): The order by time: `desc` (newest first) when omitted, or `asc`. A cursor is tied to the order that made it. Values:`asc``desc`(an open set: new values may be added)
- `action` (string or null): Only the actions with this exact action code, such as `database_instance.update`.
- `period` (string or null): A relative window ending now: 1 to 9999 minutes, hours, days or weeks (`3h`, `2w`). Not with `from` and `to`. The operation names its longest window and its default.
- `from` (string or null): The start of a pinned window, epoch milliseconds or RFC 3339 with an offset. Needs `to`. A start before the oldest data kept is served from it.
- `to` (string or null): The end of a pinned window, epoch milliseconds or RFC 3339 with an offset, after `from`. A window that ends before the oldest data kept, or in the future, is refused.
- `limit` (integer or null): The same as `per_page`, kept for existing clients.
- `include_total` (string or null): Ignored: `total` is always present. Values:`true``false``1``0`(an open set: new values may be added)
- `per_page` (integer or null): How many audit actions to return in one page, from 1 to 100; 25 when omitted.
- `page` (integer or null): The page to read, from 1; 1 when omitted. A page past the last answers no rows.

### Returns

`200 OK`:

One page of the organisation’s audit actions.

Each item of the page:

- `uuid` (string): The audit action’s uuid.
- `at` (integer): Epoch milliseconds. When the action was recorded. An instant: epoch milliseconds, UTC.
- `action` (string): The action’s code, such as `database_instance.update`. More codes may be added.
- `action_label` (string): The action’s label, as the console shows it.
- `category` (object or null): The action’s category; null when it has none.
  - `slug` (string): The category’s key, such as `database`.
  - `name` (string): The category’s name.
- `subject` (object or null): The resource the action is about; null when it is about none, or the resource is no longer known.
  - `type` (string): The resource’s type, such as `server` or `database_instance`. More types may be added.
  - `uuid` (string): The resource’s uuid.
  - `name` (string or null): The resource’s name.
  - `deleted` (boolean): Whether the resource has since been deleted.
- `lane` (string): The Audit page’s lane the action belongs to: `changes`, `alarms`, `incidents`, `health` or `lifecycle`.
- `actor` (object): Who or what did the action.
  - `type` (string): `user` (a person), `service_account` (a service account, through its API key), `agent` (a server’s agent), `support` (a change WatchTower15 support made) or `system` (WatchTower15 itself). More types may be added.
  - `uuid` (string or null): The user uuid of the person or service account; null for an agent, the system or WatchTower15 support.
  - `name` (string or null): The name of the person or service account, or “WatchTower15 support” for a change WatchTower15 support made; null for an agent or the system.
  - `email` (string or null): The email of the person, as the Audit page shows it to a member holding `audit.view`; null for a service account, an agent or the system.
- `origin` (string or null): What caused an action nobody did by hand: `agent`, `scheduler`, `scan`, `ingest` or `system`; null otherwise, and on a row recorded without it. An open set.
- `via` (string or null): The channel the action came through: `api` (an API key) or `mcp` (an AI client); null for the console or WatchTower15 itself.
- `changes` (array of objects): The fields the action changed, with the values the Audit page shows: `old` and `new` for a value change, `added` and `removed` for a change of a set, `changed` true for a masked value (a secret, whose value is never recorded). A key that does not apply to a change is null (`changed`: false).
  - `field` (string): The changed field’s key.
  - `label` (string): The changed field’s label, as the console shows it.
  - `old` (any): The value before the change, as recorded; null when none was recorded or the change is not a value change.
  - `new` (any): The value after the change, as recorded; null when none was recorded or the change is not a value change.
  - `added` (any): What a change of a set added; null for any other change.
  - `removed` (any): What a change of a set removed; null for any other change.
  - `changed` (boolean): True when the field changed and its value is masked, never recorded.
- `changes_count` (integer): The number of fields the action changed.
- `context` (array of objects): What else the action recorded, as the Audit page lists it under the row.
  - `key` (string): The pair’s key; a nested value is `parent.child`.
  - `label` (string): The pair’s label, as the console shows it.
  - `value` (any): The pair’s value, by its `type`.
  - `type` (string): One of `text`, `number`, `boolean`, `instant` (epoch milliseconds) or `list` (strings).
- `ip_address` (string or null): The IP address the action came from, as recorded; null when none was.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/audit-actions**

curl:

```bash
curl https://rest.watchtower15.com/v1/audit-actions \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

foreach ($wt15->auditActions->list()->autoPaging() as $item) { echo $item->uuid, "\n"; }
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

for await (const item of wt15.auditActions.list()) {
  console.log(item.uuid);
}
```

Python:

```python
client = Client.from_environment()

for item in client.audit_actions.list():
    print(item.uuid)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "at": 1794214800000,
      "action": "example",
      "action_label": "example",
      "category": {
        "slug": "example",
        "name": "example"
      },
      "subject": {
        "type": "example",
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "deleted": true
      },
      "lane": "example",
      "actor": {
        "type": "example",
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "email": "example"
      },
      "origin": "example",
      "via": "example",
      "changes": [
        {
          "field": "example",
          "label": "example",
          "old": null,
          "new": null,
          "added": null,
          "removed": null,
          "changed": true
        }
      ],
      "changes_count": 1,
      "context": [
        {
          "key": "example",
          "label": "example",
          "value": null,
          "type": "example"
        }
      ],
      "ip_address": "example"
    }
  ],
  "current_page": 1,
  "per_page": 1,
  "last_page": 1,
  "total": 1
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the audit.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

Source: https://developer.watchtower15.com/api/reference/audit-actions/
