Sorry, no results found for "".
The Audit Logs API allows to monitor events happening in an Enterprise project. It ensures continued compliance, safeguarding against any inappropriate system access, and allows you to audit suspicious behavior within your enterprise.
You can use this part of the API to:
Please note that DatoCMS does not perform any kind of automated intrusion detection. The Audit Logs API will return the data but can not automatically determine or indicate whether an action was appropriate.
A single request might not return the full results. To get the remaining results, you can use the meta.next_token
of a response as a next_token
attribute for the next request, until the response returns null
as the next token.
You can use the filter
parameter to pass an SQL-like query (PartiQL) to filter events. Any attribute of the event payload can be used in a condition.
To filter for date, you can use the event id
attribute, which is an ULID (Universally Unique Lexicographically Sortable Identifier) together with the min_ulid()
function, which takes a Unix timestamp.
The following query returns actions performed in Q1 2021 (January to March):
Other query examples will follow:
-- Return actions of type 'items.update' onlyaction_name = 'items.update'
-- Returns actions whose name begins with 'fields'begins_with(action_name, 'fields') -- Includes `fields.update`, `fields.destroy`, etc,
-- Returns actions containing 'destroy'contains(action_name, 'update') -- Includes `fields.update`, `plugins.update`, `items.update`, etc.
-- Return actions performed by a collaboratoractor.type = 'user'
-- Return actions performed by a specific collaboratoractor.type = 'user' AND actor.id = '4845293'
-- Return publishing actions for the record 239408request.path = '/items/239408/publish'
-- Return all record creations for the model 855832action_name = 'items.create' AND request.payload.data.relationships.item_type.data.id = '855832'
An SQL-like expression to filter the events
"id > min_ulid(1624452728)"
Set this value to get remaining results, if a meta.next_token was returned in the previous query response
"E5188+SCXtvvXVUFkqmwtQJd3V3lJIOsZBjHvTYz"
Whether a detailed log complete with full request and response payload must be returned or not
Returns an array of resource objects of type audit_log_event
import { buildClient } from "@datocms/cma-client-node";
async function run() { const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const auditLogEvents = await client.auditLogEvents.query({});
for (const auditLogEvent of auditLogEvents) { // Check the 'Returned output' tab for the result ☝️ console.log(auditLogEvent); }}
run();
{ id: "01F8WDQJR03M4VC6NTK49R83QW", action_name: "items.publish", actor: { type: "user", id: "3845289", name: "mark@acme.com" }, role: { id: "455281", name: "Editor" }, environment: { id: "main", primary: true }, request: { id: "894f9f6c-a693-4f93-a3fb-452454b41313", method: "PUT", path: "/items/37823421/publish", payload: {}, }, response: { status: 200, payload: {} }, meta: { occurred_at: "2016-09-20T18:50:24.914Z" },}