Transactions

Transactions are the core of Crane Ledger's double-entry accounting system. Each transaction represents a financial event that affects multiple accounts through balanced debit and credit entries.

The Transaction Object

GET/organizations/:organization_id/transactions/:id
Auth required

A transaction represents a financial event with balanced journal entries.

{
  "id": "txn_xxxxxxxxxxxxxxxx",
  "object": "transaction",
  "organization_id": "org_xxxxxxxxxxxxxxxx",
  "type": "income",
  "reference_number": "INV-001",
  "description": "Cash sale to customer",
  "transaction_date": "2024-01-15",
  "posting_date": "2024-01-15T10:30:00Z",
  "status": "posted",
  "total_debits": "100.00",
  "total_credits": "100.00",
  "currency_id": "CUR_USD",
  "amount": "100.00",
  "account_id": "act_xxxxxxxxxxxxxxxx",
  "contact_id": "con_xxxxxxxxxxxxxxxx",
  "category_id": "cat_xxxxxxxxxxxxxxxx",
  "document_id": null,
  "document_type": null,
  "payment_method": "cash",
  "reconciled": false,
  "created_by": "usr_xxxxxxxxxxxxxxxx",
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:30:00Z",
  "metadata": {
    "source": "api",
    "batch_id": "batch_001"
  }
}

Attributes

AttributeTypeDescription
idstringUnique identifier with txn_ prefix
organization_idstringThe organization this transaction belongs to
typestringTransaction type: income, expense, transfer
reference_numberstringUser-provided reference number
descriptionstringTransaction description
transaction_datedateBusiness date of the transaction
posting_datedatetimeWhen the transaction was posted
statusenumpending, posted, failed, reversed
total_debitsstringTotal debits in base currency
total_creditsstringTotal credits in base currency
currency_idstringTransaction currency
amountstringTransaction amount
account_idstringPrimary account ID
contact_idstringRelated contact ID
category_idstringTransaction category
reconciledbooleanWhether transaction is reconciled
metadataobjectAdditional transaction data

Create Transaction

POST/organizations/:organization_id/transactions
Auth required
2 credits

Creates a new transaction with journal entries. The entries must balance (total debits = total credits).

Path Parameters

ParameterTypeRequiredDescription
organization_idstringYesThe ID of the organization

Request Body

ParameterTypeRequiredDescription
descriptionstringYesTransaction description
transaction_datedateYesBusiness date (YYYY-MM-DD)
currency_idstringYesCurrency ID
entriesarrayYesArray of journal entries
typestringNoTransaction type (income, expense, transfer)
reference_numberstringNoCustom reference number
contact_idstringNoRelated contact ID
category_idstringNoCategory ID
payment_methodstringNoPayment method

Entry Structure

Each entry in the entries array:

ParameterTypeRequiredDescription
account_idstringYesAccount ID to affect
entry_typeenumYesdebit or credit
amountnumberYesEntry amount (positive)
descriptionstringNoLine item description
referencestringNoExternal reference

Response

{
  "request_id": "req_xxxxxxxxxxxxxxxx",
  "success": true,
  "data": {
    "status": "queued",
    "estimated_completion": "2024-01-15T10:30:05Z"
  },
  "error": null,
  "duration_ms": 0,
  "credit_cost": 2
}

List Transactions

GET/organizations/:organization_id/transactions
Auth required

Returns a list of transactions for the organization with optional filtering.

Path Parameters

ParameterTypeRequiredDescription
organization_idstringYesThe organization ID

Query Parameters

ParameterTypeDescription
statusenumFilter by status (pending, posted, failed, reversed)
typestringFilter by type (income, expense, transfer)
account_idstringFilter by account
contact_idstringFilter by contact
from_datedateStart date for transaction_date
to_datedateEnd date for transaction_date
limitintegerNumber of results (default: 20, max: 100)
offsetintegerPagination offset

Response

{
  "object": "list",
  "data": [
    {
      "id": "txn_xxxxxxxxxxxxxxxx",
      "description": "Cash sale to customer",
      "transaction_date": "2024-01-15",
      "status": "posted",
      "amount": "500.00",
      "type": "income",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ],
  "has_more": false,
  "total_count": 1
}

Get Transaction

GET/organizations/:organization_id/transactions/:id
Auth required

Retrieves the details of a specific transaction including all journal entries.

Path Parameters

ParameterTypeRequiredDescription
organization_idstringYesThe organization ID
idstringYesThe transaction ID

Response

Returns the complete transaction object with all journal entries.


Update Transaction

PUT/organizations/:organization_id/transactions/:id
Auth required
1 credits

Updates an existing transaction. Only pending transactions can be modified.

Path Parameters

ParameterTypeRequiredDescription
organization_idstringYesThe organization ID
idstringYesThe transaction ID

Request Body

ParameterTypeDescription
descriptionstringTransaction description
transaction_datedateBusiness date
reference_numberstringReference number
contact_idstringRelated contact
category_idstringCategory
entriesarrayUpdated journal entries

Pending Only

Only transactions with status pending can be updated. Posted transactions must be reversed and re-created.


Delete Transaction

DELETE/organizations/:organization_id/transactions/:id
Auth required
1 credits

Deletes a pending transaction. Posted transactions cannot be deleted.

Path Parameters

ParameterTypeRequiredDescription
organization_idstringYesThe organization ID
idstringYesThe transaction ID

Post Transaction

POST/organizations/:organization_id/transactions/:id/post
Auth required
1 credits

Posts a pending transaction, making it final and affecting account balances.

Path Parameters

ParameterTypeRequiredDescription
organization_idstringYesThe organization ID
idstringYesThe transaction ID

Response

{
  "request_id": "req_xxxxxxxxxxxxxxxx",
  "success": true,
  "data": {
    "status": "queued",
    "message": "Transaction posting queued"
  },
  "credit_cost": 1
}

Balance Validation

The system validates that total debits equal total credits before posting. Unbalanced transactions will fail to post.


Reverse Transaction

POST/organizations/:organization_id/transactions/:id/reverse
Auth required
2 credits

Reverses a posted transaction by creating an offsetting transaction with opposite entries.

Path Parameters

ParameterTypeRequiredDescription
organization_idstringYesThe organization ID
idstringYesThe transaction ID

Request Body

ParameterTypeRequiredDescription
reasonstringNoReason for reversal
reversal_datedateNoDate for reversal (defaults to today)

Response

{
  "request_id": "req_xxxxxxxxxxxxxxxx",
  "success": true,
  "data": {
    "status": "queued",
    "message": "Transaction reversal queued",
    "reversal_transaction_id": "txn_yyyyyyyyyyyyyyyy"
  },
  "credit_cost": 2
}

Transaction Lifecycle

Status Flow

pending → posted → reversed
   ↓        ↓
 failed   (final)

Status Descriptions

StatusDescriptionActions Available
pendingDraft transaction awaiting postingEdit, delete, post
postedFinal transaction affecting balancesReverse only
failedTransaction failed validationEdit and retry, delete
reversedTransaction has been reversedView only

Double-Entry Validation

All transactions must satisfy the fundamental accounting equation:

Total Debits = Total Credits

Example: Complete Transaction

{
  "description": "Purchase office supplies with credit card",
  "transaction_date": "2024-01-15",
  "currency_id": "CUR_USD",
  "entries": [
    {
      "account_id": "act_office_supplies_5100",
      "entry_type": "debit",
      "amount": 250.00,
      "description": "Office supplies expense"
    },
    {
      "account_id": "act_credit_card_2100",
      "entry_type": "credit",
      "amount": 250.00,
      "description": "Credit card payable"
    }
  ]
}

Multi-Entry Transaction

Complex transactions can have multiple entries:

{
  "description": "Customer payment with discount",
  "entries": [
    {
      "account_id": "act_cash_1000",
      "entry_type": "debit",
      "amount": 950.00,
      "description": "Cash received"
    },
    {
      "account_id": "act_sales_discount_4200",
      "entry_type": "debit",
      "amount": 50.00,
      "description": "Sales discount given"
    },
    {
      "account_id": "act_accounts_receivable_1100",
      "entry_type": "credit",
      "amount": 1000.00,
      "description": "Clear customer balance"
    }
  ]
}

Validation: 950 + 50 = 1000 ✓


Common Transaction Patterns

Revenue Recognition

{
  "type": "income",
  "description": "Service revenue",
  "entries": [
    {"account_id": "act_ar", "entry_type": "debit", "amount": 1000.00},
    {"account_id": "act_revenue", "entry_type": "credit", "amount": 1000.00}
  ]
}

Expense Recording

{
  "type": "expense",
  "description": "Rent payment",
  "entries": [
    {"account_id": "act_rent_expense", "entry_type": "debit", "amount": 2000.00},
    {"account_id": "act_cash", "entry_type": "credit", "amount": 2000.00}
  ]
}

Asset Purchase

{
  "description": "Equipment purchase",
  "entries": [
    {"account_id": "act_equipment", "entry_type": "debit", "amount": 5000.00},
    {"account_id": "act_cash", "entry_type": "credit", "amount": 5000.00}
  ]
}

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.