Skip to main content

Overview

The compliance sub-client provides tools for regulatory compliance: organization-wide summaries, bulk exports of grants and audit entries, and full evidence packs with chain integrity verification.
const summary = await grantex.compliance.getSummary();
console.log(summary.agents.active);       // 12
console.log(summary.grants.active);       // 1024
console.log(summary.auditEntries.total);  // 50432

compliance.getSummary()

Get an organization-wide compliance summary with aggregate counts for agents, grants, audit entries, and policies.
const summary = await grantex.compliance.getSummary({
  since: '2026-01-01T00:00:00Z',
  until: '2026-02-28T23:59:59Z',
});

console.log(summary.generatedAt);           // '2026-02-28T12:00:00Z'
console.log(summary.agents.total);           // 15
console.log(summary.agents.active);          // 12
console.log(summary.agents.suspended);       // 2
console.log(summary.agents.revoked);         // 1
console.log(summary.grants.total);           // 2048
console.log(summary.grants.active);          // 1024
console.log(summary.grants.revoked);         // 512
console.log(summary.grants.expired);         // 512
console.log(summary.auditEntries.total);     // 50432
console.log(summary.auditEntries.success);   // 49000
console.log(summary.auditEntries.failure);   // 1200
console.log(summary.auditEntries.blocked);   // 232
console.log(summary.policies.total);         // 8
console.log(summary.plan);                   // 'pro'

Parameters

since
string
ISO 8601 start date for the summary window.
until
string
ISO 8601 end date for the summary window.

Response: ComplianceSummary

generatedAt
string
ISO 8601 timestamp when the summary was generated.
agents
object
Agent counts: { total, active, suspended, revoked }.
grants
object
Grant counts: { total, active, revoked, expired }.
auditEntries
object
Audit entry counts: { total, success, failure, blocked }.
policies
object
Policy counts: { total }.
plan
string
The organization’s current plan.

compliance.exportGrants()

Export all grants, optionally filtered by status and date range.
const exported = await grantex.compliance.exportGrants({
  status: 'active',
});

console.log(exported.generatedAt); // '2026-02-28T12:00:00Z'
console.log(exported.total);       // 1024
console.log(exported.grants);      // Grant[]

Parameters

since
string
ISO 8601 start date filter.
until
string
ISO 8601 end date filter.
status
'active' | 'revoked' | 'expired'
Filter by grant status.

Response: ComplianceGrantsExport

generatedAt
string
ISO 8601 timestamp when the export was generated.
total
number
Total number of exported grants.
grants
Grant[]
Array of grant objects.

compliance.exportAudit()

Export all audit entries, optionally filtered by date range, agent, or status.
const exported = await grantex.compliance.exportAudit({
  since: '2026-02-01T00:00:00Z',
  agentId: 'ag_01HXYZ...',
});

console.log(exported.total);    // 5432
console.log(exported.entries);  // AuditEntry[]

Parameters

since
string
ISO 8601 start date filter.
until
string
ISO 8601 end date filter.
agentId
string
Filter by agent ID.
status
'success' | 'failure' | 'blocked'
Filter by action status.

Response: ComplianceAuditExport

generatedAt
string
ISO 8601 timestamp when the export was generated.
total
number
Total number of exported entries.
entries
AuditEntry[]
Array of audit entry objects.

compliance.evidencePack()

Generate a full evidence pack for compliance frameworks (SOC 2, GDPR, or both). Includes a summary, all grants, audit entries, policies, and chain integrity verification.
const pack = await grantex.compliance.evidencePack({
  framework: 'soc2',
  since: '2026-01-01T00:00:00Z',
});

console.log(pack.meta.schemaVersion);       // '1.0'
console.log(pack.meta.framework);            // 'soc2'
console.log(pack.summary.agents.total);      // 15
console.log(pack.grants.length);             // 2048
console.log(pack.auditEntries.length);       // 50432
console.log(pack.policies.length);           // 8
console.log(pack.chainIntegrity.valid);      // true
console.log(pack.chainIntegrity.checkedEntries); // 50432

Parameters

framework
'soc2' | 'gdpr' | 'all'
The compliance framework to generate evidence for. Defaults to 'all'.
since
string
ISO 8601 start date for the evidence window.
until
string
ISO 8601 end date for the evidence window.

Response: EvidencePack

meta
object
Metadata: { schemaVersion, generatedAt, since?, until?, framework }.
summary
object
Aggregate counts for agents, grants, audit entries, policies, and plan.
grants
Grant[]
All grants in the evidence window.
auditEntries
AuditEntry[]
All audit entries in the evidence window.
policies
Policy[]
All active policies.
chainIntegrity
ChainIntegrity
Chain integrity verification result.

ChainIntegrity

valid
boolean
Whether the hash chain is intact.
checkedEntries
number
Number of entries verified.
firstBrokenAt
string | null
ISO 8601 timestamp of the first broken link, or null if the chain is intact.