# User audit log

Using the audit log, account owner can track the activity of all users added through the "Access rights" section. Contains audit object and list method to get the audit log.

## Audit object

```json
{
  "id": 44504790,
  "user_id": 3,
  "subuser_id": 184541,
  "entry_category": "custom_field",
  "entry_id": null,
  "action": "create",
  "payload": {
    "name": "Decimal number"
  },
  "host": "94.140.138.215",
  "user_agent": "Apache-HttpClient/4.1.1 (java 1.5)",
  "action_date": "2020-12-21 17:54:01"
}
```

* `id` - int. An ID of the audit record.
* `user_id` - int. Master user's ID.
* `subuser_id` - int. ID of the sub-user who made an action.
* `entry_category` - string. Category of the entry on which an action made.
* `entry_id` - int. ID of the entry on which an action made. Nullable.
* `action` - string. Action on entry.
* `payload` - Nullable JSON object. Additional information about action.
* `host` - string. Host from which an action made. IPv4 or IPv6.
* `user_agent` - string. User agent.
* `action_date` - [date/time](https://navixy.com/docs/navixy-api/user-api/backend-api/..#data-types). Date and time of the action.

## API actions

API path: `/user/audit/log`.

### list

Gets list of audit records available for current user.

**required sub-user rights**: `admin` (available only to master users).

#### Parameters

| name         | description                                                                                                                           | type                                                                               |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| from         | Include audit objects recorded after this date.                                                                                       | [date/time](https://navixy.com/docs/navixy-api/user-api/backend-api/..#data-types) |
| to           | Include audits before this date.                                                                                                      | [date/time](https://navixy.com/docs/navixy-api/user-api/backend-api/..#data-types) |
| subuser\_ids | Optional. Include audits for specific sub-users.                                                                                      | int array                                                                          |
| actions      | Optional. Include audits for specific actions only.                                                                                   | string array                                                                       |
| limit        | Pagination. Maximum number of audit records to return.                                                                                | int                                                                                |
| offset       | Pagination. Get audits starting from.                                                                                                 | int                                                                                |
| sort         | Optional. Set of sort options. Each option is a pair of property name and sorting direction, e.g. `["action_date=asc", "user=desc"]`. | string array                                                                       |
| grouping     | Optional. Group log by "user", "action\_date", "action" or don't group "default".                                                     | [enum](https://navixy.com/docs/navixy-api/user-api/backend-api/..#data-types)      |

Properties available for sorting by:

* `action`.
* `action_date` - sort only by date, not considering time part.
* `action_datetime` - sort by date including time.
* `user` - sort by user's (sub-user) last+first+middle name, not by ID.
* `host`.\
  If no sort param is specified, then sorting equivalent to option `["action_date=asc"]` will be applied.

#### Example

cURL

{% code overflow="wrap" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/user/audit/log/list' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "22eac1c27af4be7b9d04da2ce1af111b", "from": "2020-12-25 03:24:00", "to": "2020-12-28 06:24:00", "limit": 50, "offset": 0}'
```

{% endcode %}

#### Response

```json
{
  "success": true,
  "list": [
    {
      "id": 44504790,
      "user_id": 3,
      "subuser_id": 184541,
      "entry_category": "custom_field",
      "entry_id": null,
      "action": "create",
      "payload": {
        "name": "Decimal number"
      },
      "host": "94.140.138.215",
      "user_agent": "Apache-HttpClient/4.1.1 (java 1.5)",
      "action_date": "2020-12-21 17:54:01"
    }
  ]
}
```

#### Errors

* [General](https://navixy.com/docs/navixy-api/user-api/errors#error-codes) types only.


---

# Agent Instructions: 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:

```
GET https://navixy.com/docs/navixy-api/user-api/backend-api/resources/commons/user/audit/audit_log.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
