Core
IoT Platform v2.x
2

search #

Searches audit trail entries in a tenant index with optional filters.


Query Syntax #

HTTP #

URL: http://kuzzle:7512/_/auditTrail/:index/_search
Method: POST
Body:
{
  "from": 0,
  "size": 10,
  "filter": {
    "globalSearch": "string",
    "actions": ["string"],
    "statuses": ["string"],
    "userIds": ["string"],
    "dateOrder": "asc | desc",
    "dateRange": {
      "startDate": "string | null",
      "endDate": "string | null"
    }
  }
}

Javascript #

kuzzle.query({
  controller: 'audit-trail',
  action: 'search',
  index: '<tenant-index>',
  body: {
    from: 0,
    size: 10,
    filter: {
      globalSearch: '',
      actions: [],
      statuses: [],
      userIds: [],
      dateOrder: 'desc',
      dateRange: {
        startDate: null,
        endDate: null,
      },
    },
  },
});

Arguments #

ArgumentTypeDescription
index
string
Tenant index name

Body Properties #

PropertyTypeDefaultDescription
from
number
0Offset for pagination
size
number
10Number of results to return
filter
object
{}Filter object (see Filter Properties below)

Filter Properties #

PropertyTypeDefaultDescription
globalSearch
string
""Full-text search applied across all fields
actions
string[]
[]Restrict to entries matching one of these action keys
statuses
string[]
[]Restrict to entries matching one of these status keys
userIds
string[]
[]Restrict to entries for the given user kuids
dateOrder
string
"desc"Sort order on createdAt. Accepted values: "asc", "desc"
dateRange
object
ISO 8601 date boundaries. Both fields accept null (unbounded)

Response #

Returns a paginated list of audit trail documents.

{
  "hits": [
    {
      "_id": "<document-id>",
      "_source": {
        "action": { "name": "kzCreateAsset" },
        "status": { "name": "kzOk" },
        "createdAt": "2024-01-15T10:30:00.000Z",
        "user": {
          "kuid": "user-id",
          "fullName": "Jane Doe"
        },
        "object": {
          "id": "asset-id",
          "type": "kzAsset"
        },
        "customData": {},
        "schemaVersion": 1
      }
    }
  ],
  "total": 1
}