Events

Events provide a complete audit trail of all activities in Crane Ledger. Every transaction, update, and system action is recorded as an event, providing full traceability and compliance capabilities.

The Event Object

GET/events/:entity_type/:entity_id
Auth required
{
  "id": "evt_xxxxxxxxxxxxxxxx",
  "object": "event",
  "organization_id": "org_xxxxxxxxxxxxxxxx",
  "entity_type": "transaction",
  "entity_id": "txn_xxxxxxxxxxxxxxxx",
  "event_type": "transaction.created",
  "description": "Transaction posted to general ledger",
  "user_id": "usr_xxxxxxxxxxxxxxxx",
  "api_key_id": "key_xxxxxxxxxxxxxxxx",
  "ip_address": "192.168.1.100",
  "user_agent": "CraneLedger/1.0",
  "metadata": {
    "amount": "500.00",
    "account_id": "act_xxxxxxxxxxxxxxxx"
  },
  "created_at": "2024-01-15T10:30:00Z"
}

Attributes

AttributeTypeDescription
idstringUnique identifier with evt_ prefix
organization_idstringThe organization this event belongs to
entity_typeenumType of entity (transaction, invoice, account, etc.)
entity_idstringID of the affected entity
event_typestringSpecific event type (e.g., transaction.created)
descriptionstringHuman-readable description
user_idstringUser who triggered the event (if applicable)
api_key_idstringAPI key used for the request
ip_addressstringIP address of the request
user_agentstringUser agent string
metadataobjectAdditional event-specific data
created_atdatetimeWhen the event occurred

List Events

GET/organizations/:organization_id/events
Auth required

Returns a paginated list of events for the organization.

Path Parameters

ParameterTypeRequiredDescription
organization_idstringYesThe organization ID

Query Parameters

ParameterTypeDescription
entity_typeenumFilter by entity type
entity_idstringFilter by specific entity
event_typestringFilter by event type
user_idstringFilter by user
api_key_idstringFilter by API key
from_datedatetimeStart date for events
to_datedatetimeEnd date for events
limitintegerNumber of results (default: 20, max: 100)
offsetintegerPagination offset

Response

{
  "object": "list",
  "data": [
    {
      "id": "evt_xxxxxxxxxxxxxxxx",
      "entity_type": "transaction",
      "entity_id": "txn_xxxxxxxxxxxxxxxx",
      "event_type": "transaction.created",
      "description": "Transaction posted to general ledger",
      "user_id": "usr_xxxxxxxxxxxxxxxx",
      "created_at": "2024-01-15T10:30:00Z"
    },
    {
      "id": "evt_yyyyyyyyyyyyyyyy",
      "entity_type": "invoice",
      "entity_id": "inv_xxxxxxxxxxxxxxxx",
      "event_type": "invoice.sent",
      "description": "Invoice sent to customer",
      "api_key_id": "key_xxxxxxxxxxxxxxxx",
      "created_at": "2024-01-15T14:20:00Z"
    }
  ],
  "has_more": true,
  "total_count": 150
}

Get Entity Events

GET/events/:entity_type/:entity_id
Auth required

Returns all events related to a specific entity (transaction, invoice, account, etc.).

Path Parameters

ParameterTypeRequiredDescription
entity_typestringYesType of entity (transaction, invoice, account, etc.)
entity_idstringYesThe entity ID

Query Parameters

ParameterTypeDescription
limitintegerNumber of results (default: 20, max: 100)
offsetintegerPagination offset

Response

{
  "object": "list",
  "entity_type": "transaction",
  "entity_id": "txn_xxxxxxxxxxxxxxxx",
  "data": [
    {
      "id": "evt_xxxxxxxxxxxxxxxx",
      "event_type": "transaction.created",
      "description": "Transaction created",
      "user_id": "usr_xxxxxxxxxxxxxxxx",
      "created_at": "2024-01-15T10:25:00Z"
    },
    {
      "id": "evt_yyyyyyyyyyyyyyyy",
      "event_type": "transaction.posted",
      "description": "Transaction posted to general ledger",
      "user_id": "usr_xxxxxxxxxxxxxxxx",
      "metadata": {
        "debit_entries": 2,
        "credit_entries": 2,
        "total_amount": "1250.00"
      },
      "created_at": "2024-01-15T10:30:00Z"
    }
  ],
  "has_more": false,
  "total_count": 2
}

Event Types

Transaction Events

  • transaction.created - Transaction initially created
  • transaction.updated - Transaction modified
  • transaction.posted - Transaction posted to ledger
  • transaction.reversed - Transaction reversed
  • transaction.deleted - Transaction deleted

Invoice Events

  • invoice.created - Invoice created
  • invoice.updated - Invoice modified
  • invoice.sent - Invoice marked as sent
  • invoice.viewed - Invoice viewed by customer
  • invoice.payment_received - Payment recorded
  • invoice.paid - Invoice fully paid
  • invoice.cancelled - Invoice cancelled
  • invoice.deleted - Invoice deleted

Account Events

  • account.created - Account created
  • account.updated - Account modified
  • account.deleted - Account deleted

Contact Events

  • contact.created - Contact created
  • contact.updated - Contact modified
  • contact.deleted - Contact deleted

API Key Events

  • api_key.created - API key created
  • api_key.updated - API key modified
  • api_key.rotated - API key rotated
  • api_key.revoked - API key revoked

System Events

  • organization.created - Organization created
  • user.invited - User invited to organization
  • settings.updated - Organization settings changed

Event Metadata

Events include contextual metadata depending on the event type:

Transaction Events

{
  "amount": "500.00",
  "currency": "USD",
  "debit_entries": 2,
  "credit_entries": 2,
  "description": "Office supplies purchase"
}

Invoice Events

{
  "invoice_number": "INV-2024-001",
  "amount": "1250.00",
  "customer_id": "con_xxxxxxxxxxxxxxxx",
  "due_date": "2024-02-14"
}

Payment Events

{
  "payment_amount": "1250.00",
  "payment_date": "2024-01-20",
  "payment_method": "check",
  "reference": "CHK-12345"
}

Audit Trail Best Practices

Compliance Requirements

  • Maintain events for regulatory retention periods
  • Implement automated archival for old events
  • Secure event data against unauthorized modification
  • Provide audit reports for compliance reviews

Monitoring and Alerts

  • Set up alerts for unusual activity patterns
  • Monitor API key usage and failed authentication
  • Track configuration changes and sensitive operations
  • Generate regular audit reports

Performance Considerations

  • Events are append-only for data integrity
  • Use appropriate indexing for common query patterns
  • Implement pagination for large result sets
  • Consider event aggregation for high-volume operations

Data Retention

  • Retain events for minimum regulatory periods
  • Implement automated cleanup policies
  • Archive old events to separate storage
  • Maintain backup copies for disaster recovery

Security Measures

  • Encrypt sensitive data in event metadata
  • Implement access controls for event viewing
  • Log access to audit trails themselves
  • Use tamper-proof storage mechanisms

Event Immutability

Events are immutable once created. They cannot be modified or deleted to ensure the integrity of the audit trail. This is critical for regulatory compliance and forensic analysis.


Need help?

Create a free account to access our support portal. Once signed in, use the Support tab in your dashboard to submit a support ticket — our team typically responds within 24 hours.