AggregateDocs
Reference

Custom API: connect your own system

Short answer: if some of your money lives in a system no connector covers (your own platform, an internal tool, a side business's checkout), you can build a small endpoint that answers three GET requests, and Aggregate reads it like any other connection. Any AI assistant or agent can write the endpoint from this page. You choose what to expose. Aggregate only ever sends GET requests and can't change anything in your system, and it can't move money.

Questions: support@aggregate.finance.

The spec as a file: openapi.yaml (OpenAPI 3.1). In Aggregate, Copy instructions for your agent on the Custom API card copies a short version of this page to paste into your AI assistant or agent.

How it works

  1. Build the endpoint: three routes under one base URL, for example https://api.example.com/aggregate.
  2. Make a key just for Aggregate. Your endpoint checks it in the Authorization: Bearer <key> header.
  3. In Aggregate, add a Custom API connection: give it a name (rows show as "Custom: <name>"), paste the base URL and the key. Aggregate reads all three routes once and connects only if every answer matches the spec.

After that it reads again on every sync, a few times a day. Each endpoint is one connection; you can add several.

The spec

All three routes answer JSON (Content-Type: application/json). Amounts are decimal strings in the currency's major units ("12.50"), never JSON numbers: an optional -, no +, exponent or grouping, at most the currency's own decimal places. Money in is positive, money out negative. Currencies are ISO 4217 codes (USD).

GET /accounts

A JSON array of accounts.

Field
idrequiredYour id for the account; never changes.
namerequiredA name people recognise (kept at most 80 characters).
currencyrequiredEvery row of the account is in it.
kindrequiredbalance or direct (see below).
balanceoptionalBalance accounts only: the money held now. When given, each sync checks the rows add up to it, and posts them only once they do.

GET /transactions?since=&cursor=

{"data": [...], "next_cursor": "..." | null}, oldest first, up to 1,000 rows a page. Send null on the last page.

Field
idrequiredYour id for the row; never changes, unique in the account.
account_idrequiredAn id from /accounts.
daterequiredYYYY-MM-DD, or a date and time with its offset (2026-11-02T14:30:00-05:00).
amountrequiredSigned. With gross, fee or refund given, it must equal gross − fee − refund (a missing one counts as 0).
currencyrequiredThe account's currency.
descriptionoptionalShown as written, as data (kept at most 200 characters).
typeoptionalsale, refund, fee or adjustment. Left out, it's an adjustment: Aggregate never guesses.
grossoptionalThe sale before fees and refunds.
feeoptionalFees taken from it (positive).
refundoptionalRefunded from it (positive).
payout_idoptionalThe payout that paid it out, if known.

since is a day (YYYY-MM-DD). Send every row whose date part, as your endpoint writes it, is on or after it, with no time zone change: a row dated 2026-11-02T23:30:00-05:00 is on 2026-11-02. With no since, send every row.

Payouts are not transactions. A payout appears in /payouts only, never also as a row here, or the money would leave the balance twice.

GET /payouts?since=&cursor= (optional)

The same page shape. Answer 404 if your system has no payouts.

Field
idrequiredYour id for the payout; never changes.
account_idrequiredA balance account from /accounts.
date_arrivesrequiredYYYY-MM-DD the money reaches the bank.
grossrequiredWhat leaves the balance.
feesrequiredWhat the payout itself cost.
netrequiredWhat reaches the bank: gross − fees.
currencyrequiredThe account's currency.

A payout takes gross out of the balance, and net reaches the bank. Aggregate matches net and date_arrives to the deposit in your bank account, so the sales count once as revenue and the deposit counts once as cash.

Any other field is ignored and never stored. There's no counterparty field: Aggregate doesn't need to know who paid.

Balance or direct

Each account picks one, and it can't change later.

If your system batches several sales into one deposit, or takes refunds back out, make it a balance account and serve /payouts.

What's refused, and why

Aggregate refuses a whole answer rather than repair a row, because a total that might be wrong is worse than a sync that stops and says why. Every refusal names the place (transactions[3].amount: not a decimal) and never repeats what your endpoint sent. Fix the endpoint and the next sync carries on.

Limits

IP addresses

If your endpoint only lets known IP addresses in, allow the hosted service's two fixed addresses:

Privacy

Aggregate stores only what your endpoint returns, and only the fields above; anything else is dropped as it arrives. The base URL and key are kept encrypted. Disconnecting deletes Aggregate's copy of the key and everything that connection brought in, right away. To turn the key off as well, remove it from your endpoint. See the privacy policy.

A minimal endpoint

Plain Node.js (18 or later), no packages. Run it behind HTTPS (your host's TLS, or a proxy such as Caddy), with AGGREGATE_KEY set to the key you'll paste into Aggregate. Replace the three lists with reads from your own data.

// server.mjs: AGGREGATE_KEY=... node server.mjs
import { createHash, timingSafeEqual } from 'node:crypto'
import { createServer } from 'node:http'

const KEY = process.env.AGGREGATE_KEY ?? ''
const PAGE = 1000

// One balance account: 96.80 + 38.54 − 20.00 in sales and a refund, less the 100.00 paid out, leaves 15.34.
const accounts = [{ id: 'shop', name: 'Shop balance', currency: 'USD', kind: 'balance', balance: '15.34' }]
const transactions = [
  { id: 't1', account_id: 'shop', date: '2026-11-02T14:30:00-05:00', amount: '96.80', currency: 'USD', type: 'sale', gross: '100.00', fee: '3.20', payout_id: 'p1' },
  { id: 't2', account_id: 'shop', date: '2026-11-03', amount: '38.54', currency: 'USD', type: 'sale', gross: '40.00', fee: '1.46' },
  { id: 't3', account_id: 'shop', date: '2026-11-04', amount: '-20.00', currency: 'USD', type: 'refund', description: 'Refund for order 1042' },
]
const payouts = [{ id: 'p1', account_id: 'shop', date_arrives: '2026-11-06', gross: '100.00', fees: '0.25', net: '99.75', currency: 'USD' }]

const digest = (s) => createHash('sha256').update(s).digest()
const authorized = (header) => KEY.length >= 8 && timingSafeEqual(digest(header ?? ''), digest(`Bearer ${KEY}`))

// Rows on or after since (by the date part as written), 1,000 a page; the cursor is the next row's position.
function page(rows, dateField, query) {
  const since = query.get('since')
  const kept = rows.filter((r) => !since || r[dateField].slice(0, 10) >= since)
  const start = Number(query.get('cursor') ?? 0) || 0
  return { data: kept.slice(start, start + PAGE), next_cursor: start + PAGE < kept.length ? String(start + PAGE) : null }
}

export function handle(req, res) {
  const send = (status, body) => {
    res.writeHead(status, { 'content-type': 'application/json' })
    res.end(JSON.stringify(body))
  }
  if (req.method !== 'GET') return send(405, { error: 'GET only' })
  if (!authorized(req.headers.authorization)) return send(401, { error: 'unauthorized' })
  const url = new URL(req.url, 'http://localhost')
  if (url.pathname === '/accounts') return send(200, accounts)
  if (url.pathname === '/transactions') return send(200, page(transactions, 'date', url.searchParams))
  if (url.pathname === '/payouts') return send(200, page(payouts, 'date_arrives', url.searchParams))
  return send(404, { error: 'not found' })
}

createServer(handle).listen(Number(process.env.PORT ?? 8080))

Served at https://shop.example.com, the base URL is https://shop.example.com. Served under a path (for example /aggregate/accounts), the base URL includes the path: https://shop.example.com/aggregate.

A system with no payouts leaves payouts out and answers /payouts with 404, and its accounts are direct, with no balance and no refund rows.

© 2026 Aggregate Finance LLC