Capxul Docs
HooksOrganizations

useCapxulOrganizationAuditLog

Query hook for an organization's audit log — administrative actions recorded against the org, scoped by org id.

Reads an organization's audit log — a list of administrative actions recorded against the org, each with an action name, actor, and human-readable summary. It sits alongside the other org-scoped reads such as useCapxulOrgMembers.

In the published alpha the underlying client method is not implemented: every fetch fails with a not-implemented CapxulError. The hook and its types are published so you can wire the surface today, but do not ship a screen that depends on this data yet. See Capability status.

Import

import { useCapxulOrganizationAuditLog } from "@capxul/sdk-react";

Usage

"use client";

import type { OrgId } from "@capxul/sdk";
import { useCapxulOrganizationAuditLog } from "@capxul/sdk-react";

function AuditLog({ orgId }: { orgId: OrgId }) {
  const auditLog = useCapxulOrganizationAuditLog(orgId);

  if (auditLog.isLoading) return <p>Loading audit log…</p>;
  if (auditLog.error) return <p>{auditLog.error.message}</p>;

  return (
    <ul>
      {auditLog.data.map((item) => (
        <li key={item.id}>
          {item.summary} {item.actor ? `— ${item.actor}` : null}
        </li>
      ))}
    </ul>
  );
}

Parameters

organizationId

OrgId | undefined

The organization whose audit log to read. The query stays disabled while organizationId is undefined, so you can pass the result of another query directly — no manual gating needed.

options

UseCapxulOrganizationAuditLogOptions | undefined

Prop

Type

Return type

import { type UseCapxulOrganizationAuditLogReturn } from "@capxul/sdk-react";
// UseQueryResult<readonly OrganizationAuditLogItem[], CapxulError>

data is a list of OrganizationAuditLogItem records:

FieldTypeDescription
idstringThe log entry's id.
organizationIdstringThe org the action was recorded against.
actionstringMachine-readable action name.
actorstring | nullWho performed the action, when known.
summarystringHuman-readable description of the action.
createdAtnumberNumeric timestamp of when the action was recorded.
metadataRecord<string, unknown> | undefinedOptional structured detail.

The hook returns TanStack Query's UseQueryResult. The most-used fields:

FieldDescription
dataThe query data (typed per hook, shown above). undefined until the first success.
errorA CapxulError when the last fetch failed, otherwise null.
status'pending' | 'error' | 'success'.
isLoadingtrue during the first fetch (no data yet).
isFetchingtrue whenever a fetch is in flight, including background refetches.
refetchManually refetch the query.

Capxul query hooks stay pending until the provider finishes bootstrapping — you do not need to gate them on useCapxul() yourself. The full field list is in the TanStack Query useQuery reference; see also the TanStack Query integration guide.

Query key

["capxul", "org", orgId, "auditLog"] — org-scoped, keyed under the same hierarchy as the org's other reads.

Errors

Today every fetch fails: the published client resolves a not-implemented CapxulError for this read. Treat error as the steady state until Capability status grades this capability as live.

Client method

This hook wraps client.org(orgId).auditLog() — the entity-scoped org bundle on the core SDK.

On this page