List Audit Events

Beta
GET/v1/core/audit-events

This endpoint is idempotent. Learn more

Returns a paginated list of audit events, newest first.

Results cover every change where your account is either the acting account or the account that was acted upon, so a customer's or supplier's changes to your records appear alongside your own. The q parameter searches the resource type, action, resource ID, and originating request ID.

Permissions requiredValues:audit_events:read
The role behind your API key or agent must grant every one of these permissions.
cursoroptional string

Opaque cursor token identifying where the page of results starts.

Use the cursor value embedded in a previous response's next_page_url or previous_page_url to fetch the adjacent page. Omit to start from the first page.

limitoptional integer

Maximum number of results to return in a single page.

qoptional string

Free-text search term used to filter results.

Which fields are matched against the term varies by endpoint.

starts_atoptional string (date-time)

Restricts results to audit events on or after this timestamp.

ends_atoptional string (date-time)

Restricts results to audit events on or before this timestamp.

resource_types[]optional arrayenumValues:accountactorentity

Filter by the resource type of the audited entity.

The full set of valid values is available from the List Audit Event Resource Types endpoint.

resource_ids[]optional array

Filter by the audited resource IDs.

root_resource_typeoptional stringenumValues:accountactorentity

Scope results to a root record's entire history tree.

Returns every event whose root resource matches, covering the root record itself and all of its descendants — for example a sales order together with its lines, picks, shipments, and invoices. Both root_resource_type and root_resource_id must be supplied together; supplying only one has no effect.

root_resource_idoptional string

ID of the root record whose history tree to return.

Only applied when paired with root_resource_type.

actor_ids[]optional array

Filter by the actor identifier.

Matches the event's actor.id: a user ID for user actors, an API key ID for api_key actors, or an agent ID for agent actors.

actor_types[]optional arrayenumValues:userapi_keyagent

Filter by the actor type.

Events are recorded for actors of type user, api_key, and agent — the last covering changes an OpenMRP agent made on your account's behalf.

actions[]optional arrayenumValues:createupdateupsert

Filter by the mutation type recorded on the event.

actor_account_ids[]optional array

Filter by the acting account: the account that performed the mutation.

Results are always scoped to events where your account is either the acting account or the target account; this narrows that set to specific acting accounts — for example a specific customer's account that mutated a resource on your account.

target_account_ids[]optional array

Filter by the target account the mutation was performed against (the event's account).

Results are always scoped to events where your account is either the acting account or the target account; this narrows that set to specific target accounts — for example a specific customer's or supplier's account.

include[]optional arrayenumValues:accountactorchanges

Sub-objects to expand in the response. When omitted, sub-objects are returned as null.

objectstringenumValues:list

Resource type identifier.

page_infoobject

Pagination metadata.

next_page_urlstringnullable

Relative URL that fetches the next page of results.

previous_page_urlstringnullable

Relative URL that fetches the previous page of results.

has_next_pageboolean

Whether more results exist after this page.

has_prev_pageboolean

Whether results exist before this page.

dataarray of audit_event

Resources in this page.

idstring

Audit event ID.

objectstringenumValues:audit_event

Resource type identifier.

actionstringenumValues:createupdateupsert

The type of action this event records.

  • create: the resource was created.
  • update: one or more fields were changed.
  • delete: the resource was deleted.
  • restore: a previously deleted resource was restored.
  • archive: the resource was archived.
  • approve: a human approved a gated action, such as allowing a review-gated agent tool to run.
  • deny: a human denied a gated action, such as rejecting a review-gated agent tool.
resource_typestringenumValues:accountactorentity

Resource type of the audited entity.

resource_idstring

Audited resource ID.

actoractorExpandablenullable

Actor who performed the mutation.

idstring

Unique identifier of the actor.

objectstringenumValues:actor

Resource type identifier.

typestringenumValues:userapi_keyagent

Actor type.

  • user: a human user account.
  • api_key: a programmatic caller authenticating with an API key.
  • agent: an automated agent acting on the account's behalf.
  • group: a shared group identity, such as a "Customer Service" persona, rather than a single individual.
namestringnullable

The actor's display name.

handlestringnullable

Human-readable handle identifying the actor.

  • For user actors: the user's email address.
  • For api_key actors: the redacted key value.

Other actor types carry no handle.

avatar_urlstringnullable

URL of the actor's profile photo, if one is set.

Only populated for user actors.

rolerolenullable

The role the actor holds in the account, which determines what it is permitted to do.

Always returned as null in this endpoint.
accountaccountExpandablenullable

Account the audited mutation was performed against.

For a mutation on one of your own resources this is your account; when you act on a customer's or supplier's account, it is that account.

idstring

Account ID.

objectstringenumValues:account

Resource type identifier.

namestring

The account's display name.

default_billing_addressaddressnullable

The address billed by default on orders for this account.

Always returned as null in this endpoint.
default_shipping_addressaddressnullable

The address shipped to by default on orders for this account.

Always returned as null in this endpoint.
brandingaccount_brandingnullable

Customer-facing branding for the account, such as the logo, support contacts, and social links.

Always returned as null in this endpoint.
portalaccount_portalnullable

The account's customer portal settings, including the portal URL slug.

Always returned as null in this endpoint.
created_atstring (date-time)

Creation timestamp.

updated_atstring (date-time)

Last updated timestamp.

changeslistExpandablenullable

Field-level changes recorded for this event.

Only fields OpenMRP tracks for that resource type are compared, and only those whose value actually differs are listed. Actions that do not alter stored fields, such as approve and deny, generally record no changes.

objectstringenumValues:list

Resource type identifier.

page_infoobject

Pagination metadata.

next_page_urlstringnullable

Relative URL that fetches the next page of results.

previous_page_urlstringnullable

Relative URL that fetches the previous page of results.

has_next_pageboolean

Whether more results exist after this page.

has_prev_pageboolean

Whether results exist before this page.

dataarray of audit_field_change

Resources in this page.

objectstringenumValues:audit_field_change

Resource type identifier.

fieldstring

Name of the changed field.

Field names come from the audited record's stored representation and can differ slightly from the corresponding field on the API resource — for example commission_policy_code rather than commission_policy.

old_valueobjectnullable

Previous value as a JSON fragment.

null on create events, where the field had no prior value.

Encoded as a JSON value (object, array, string, number, boolean, or null), not a JSON-encoded string.

new_valueobjectnullable

New value as a JSON fragment.

null on delete events, where the field has no remaining value.

Encoded as a JSON value (object, array, string, number, boolean, or null), not a JSON-encoded string.

metadataobjectExpandablenullable

Arbitrary JSON metadata for the mutation (e.g. reason, source, tags).

Encoded as a JSON value (object, array, string, number, boolean, or null), not a JSON-encoded string.

requestrequest_logExpandablenullable

Log of the API request that caused the mutation.

Changes that did not originate from an API request have no originating request log.

idstring

Request log ID.

objectstringenumValues:request_log

Resource type identifier.

methodstringenumValues:GETPOSTPUT

HTTP method.

hoststring

Request host.

Usually api.openmrp.ai.

pathstring

The exact path the request was made to, including path parameter values.

normalized_routestring

The route template the request matched, with path parameters left as placeholders.

For example /v1/sales/customers/{id} is the normalized route for the request path /v1/sales/customers/ac_.... Falls back to the raw path when the request did not match a registered route.

query_paramsobjectnullable

Query-string parameters the request was made with, as a JSON object.

Encoded as a JSON value (object, array, string, number, boolean, or null), not a JSON-encoded string.

status_codeinteger

HTTP response status code (e.g. 200, 404).

latency_usinteger

Request latency in microseconds.

Measured at the API edge, from the moment the request was received until the response was written, so it excludes network time between your client and OpenMRP.

api_versionstringnullable

The API version the request was served with.

Taken from the OpenMRP-Version header the caller sent; requests rejected for omitting that header record no version.

client_ipstringnullable

Client IP address the request came from.

Not recorded for requests an OpenMRP agent made on your behalf, since those originate inside OpenMRP's own network.

user_agentstringnullable

User agent.

referrerstringnullable

Referrer header.

error_codestringnullableenumValues:expired_tokenapi_key_expiredapi_key_revoked

Machine-readable API error code.

Matches the code of the error response the caller received. Populated only for failed requests.

error_messagestringnullable

Human-readable error message.

The same message the caller received. Populated only for failed requests.

occurred_atstring (date-time)

When the request was received.

Request logs are ordered and date-filtered by this timestamp rather than by created_at.

created_atstring (date-time)

When the log entry was written.

accountaccountnullable

Account targeted by the request: the account the request acted upon.

Results are scoped to logs where your account is either the acting account or the target account. Use the target_account_ids query parameter to filter by which account was acted upon, and actor_account_ids to filter by who acted.

Always returned as null in this endpoint.
actoractornullable

Actor who made the request.

Always returned as null in this endpoint.
idempotency_keystringnullable

User-provided idempotency key.

request_bodyobjectnullable

The JSON body the request was sent with.

Sensitive values such as passwords, tokens, and secrets are redacted before the body is stored. Bodies larger than 256 KB are not stored in full; a small marker object with _truncated set to true is stored in their place.

Encoded as a JSON value (object, array, string, number, boolean, or null), not a JSON-encoded string.

response_bodyobjectnullable

The JSON body OpenMRP responded with.

Sensitive values such as generated API key secrets are redacted before the body is stored. Bodies larger than 256 KB are not stored in full; a small marker object with _truncated set to true is stored in their place.

Encoded as a JSON value (object, array, string, number, boolean, or null), not a JSON-encoded string.

idempotency_keystringnullable

Idempotency key of the originating request.

source_ipstringnullable

Originating client IP address.

occurred_atstring (date-time)

When the audited mutation occurred.

Audit events are ordered and date-filtered by this timestamp rather than by created_at.

created_atstring (date-time)

When the audit event record was written.

Slightly later than occurred_at, since events are recorded out of band from the request that caused them.

Responses

200

Successful response for List Audit Events