Ledga
POST /transactions/search/totals

Count and sum the transactions a filter matches

The totals request of the report specification v2: version and filter only. count counts each matching transaction once, however many attribute groups it matches; total_amount sums their stored totals in major units. Before the ledger's stored totals are verified, total_amount is null and meta.total_amount_unavailable is AMOUNT_NOT_READY; the count is still given.

Request bodyrequired

FieldTypeDescription
versionrequired integer
enum: 2
filter ReportFilter Which transactions match the report specification v2; every member present must match. Absent or {}: every transaction created in the last 30 days.
filter.created_at ReportWindow An inclusive window: a preset, or both bounds as local days (YYYY-MM-DD, in the ledger's timezone) or as ISO 8601 instants with an offset or Z. At most 12 months.
filter.effective_date ReportWindow An inclusive window: a preset, or both bounds as local days (YYYY-MM-DD, in the ledger's timezone) or as ISO 8601 instants with an offset or Z. At most 12 months.
filter.amount object Bounds on the stored total in major units: a non-negative integer, or a decimal string such as "100.00"; once the ledger's stored totals are verified
filter.status string[]
min items: 1
filter.layer string[]
min items: 1
filter.any_of ReportAttributeGroup[]
min items: 1 · max items: 5
Groups, ORed; at most 250 in values over the whole filter
filter.account_id string
uuid
filter.account_set_id string
uuid
filter.transaction_code_id string
uuid
filter.journal_id string
uuid
filter.correlation_id string
min length: 1 · max length: 50
Only the transactions with this correlation handle: those given this correlation_id, and the one with this id that was given none. Valid UTF-8, no NUL, and not whitespace alone
filter.text string
min length: 3 · max length: 100
A prefix of the reference, external id or correlation id, or a part of the description; at least three letters or digits
filter.is_reversal boolean
filter.has_reversal boolean
filter.is_voided boolean

Responses

200The totals
{
  "success": true,
  "meta": {
    "total_amount_unavailable": "AMOUNT_NOT_READY"
  },
  "data": {
    "count": 1234,
    "total_amount": "98765.43"
  }
}
401Unauthenticated
{
  "success": false,
  "message": "Validation failed",
  "code": "VALIDATION_ERROR"
}
403Forbidden (no ledger context)
{
  "success": false,
  "message": "Validation failed",
  "code": "VALIDATION_ERROR"
}
422A filter outside the specification or its limits; INVALID_REFERENCE, AMOUNT_NOT_READY (an amount filter on a ledger not ready) or SEARCH_NOT_READY as for the search; or TOTALS_TOO_BROAD when the totals ran past their own 5 s statement timeout
{
  "success": false,
  "message": "Validation failed",
  "code": "VALIDATION_ERROR"
}
429The search's rate limit, which totals count against
{
  "success": false,
  "message": "Validation failed",
  "code": "VALIDATION_ERROR"
}

Examples

curl -X POST https://ledga.io/api/v1/transactions/search/totals \
  -H "Authorization: Bearer sk_xxxxxxxx_your_secret" \
  -H "Content-Type: application/json" \
  -d '{
  "version": 2,
  "filter": {
    "created_at": {
      "preset": "this_month"
    },
    "is_voided": false
  }
}'

← All endpoints