vsmsconnect — API — audit

← all endpoints

GET/api/v1/businesses/:businessId/audit-events auth: jwt (administrator | view_audit)

Paginated audit log for a business. Supports filters by eventType (comma-separated → IN clause), outcome (comma-separated), actorType, provider, resourceType, resourceId, dateFrom/dateTo (epoch ms), and a search term (matches ResourceId, ActorName, ActorEmail or the event name with %term%). Each item carries actorName (an agent's API key label or a user's full name — never an email), actorType, outcome, provider, requestId and a one-line summary. Returns items + total + stats (fiscalised/failed/actors counts). Fires VIEW_AUDIT_LOG fire-and-forget after the response is sent.

handlers: AuditController.list

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID. Caller's JWT businessId must match (Administrator bypasses via requireBusinessAccess).
page query
int
no11-based page number; clamped to >= 1.
pageSize query
int
no20Page size, clamped 1..100.
eventType query
string
no—AuditEventType, optionally comma-separated for IN().
resourceType query
string
no—Filter by ResourceType (INVOICE, USER, XERO_CONNECTION, ...).
resourceId query
string
no—Filter by exact ResourceId.
dateFrom query
int (epoch ms)
no—Inclusive lower bound on CreatedAt.
dateTo query
int (epoch ms)
no—Inclusive upper bound on CreatedAt.
search query
string
no—Substring match against ResourceId, ActorName, ActorEmail or the event name.
outcome query
string
no—How the action ended — success, failure or rejected; comma-separated for several. Unknown values are ignored.
actorType query
string
no—user, agent (an on-premise agent or the HTTP connector, authenticated by API key) or system. Any other value is ignored.
provider query
string
no—Filter by the connector the event concerns (sage100, amicus, xero, ...).

Outputs

200
APIResponseDataObject<{ items: AuditLogDTO[]; total: number; page: number; totalPages: number; stats: { fiscalised: number; failed: number; actors: number } }>
Paginated items plus computed stats.
403
APIError
USER_FORBIDDEN — businessId mismatch (non-Administrator) or insufficient role.
GET/api/v1/businesses/:businessId/audit-events/export auth: jwt (administrator)

Stream all matching audit events as CSV (Content-Disposition: attachment; filename=audit-log-<businessId>-<yyyy-mm-dd>.csv). Same filters as the list endpoint; Administrator only (requireAdmin). Registered before /:id so Express does not treat 'export' as an id param.

handlers: AuditController.export

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID. Administrator bypasses requireBusinessAccess.
eventType query
string
no—AuditEventType, optionally comma-separated.
resourceType query
string
no—Filter by ResourceType.
resourceId query
string
no—Filter by exact ResourceId.
dateFrom query
int (epoch ms)
no—Inclusive lower bound on CreatedAt.
dateTo query
int (epoch ms)
no—Inclusive upper bound on CreatedAt.
search query
string
no—Substring match against ResourceId, ActorName, ActorEmail or the event name.
outcome query
string
no—success, failure or rejected; comma-separated for several.
actorType query
string
no—user, agent or system.
provider query
string
no—Filter by the connector the event concerns.

Outputs

200 text/csv
text/csv
CSV stream with columns Id,CreatedAt,EventType,Outcome,Summary,ActorName,ActorEmail,ActorRole,ActorType,Provider,ResourceType,ResourceId,RequestId,IpAddress,Payload.
403
APIError
USER_FORBIDDEN — caller is not Administrator.
GET/api/v1/businesses/:businessId/audit-events/:id auth: jwt (administrator | view_audit)

Fetch a single audit log entry by its BIGINT AuditLogId. Scoped to the business.

handlers: AuditController.getById

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.
id path
int (BIGINT)
yes—AuditLogs.AuditLogId — numeric, parsed via parseInt.

Outputs

200
APIResponseDataObject<AuditLogDTO>
Single audit log entry.
400
APIError
Invalid audit event id (id not parseable as integer).
403
APIError
USER_FORBIDDEN — businessId mismatch or insufficient role.
404
APIError
Audit event not found.
GET/api/v1/businesses/:businessId/audit-events/:id/related auth: jwt (administrator | view_audit)

The audit events that share the requested event's request id, oldest first and including the event itself — for example an agent push, the fiscalisation jobs it dispatched and the receipts they printed. Capped at 100. An event with no request id answers with an empty list rather than an error. Scoped to the business.

handlers: AuditController.getRelated

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.
id path
int (BIGINT)
yes—AuditLogs.AuditLogId of the event whose request chain to fetch.

Outputs

200
APIResponseDataObject<{ requestId: string | null; items: AuditLogDTO[] }>
The request id and the events that share it.
400
APIError
Invalid audit event id (id not parseable as integer).
403
APIError
USER_FORBIDDEN — businessId mismatch or insufficient role.
404
APIError
Audit event not found.