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
- Build the endpoint: three routes under one base URL, for example
https://api.example.com/aggregate. - Make a key just for Aggregate. Your endpoint checks it in the
Authorization: Bearer <key>header. - 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 | ||
|---|---|---|
id | required | Your id for the account; never changes. |
name | required | A name people recognise (kept at most 80 characters). |
currency | required | Every row of the account is in it. |
kind | required | balance or direct (see below). |
balance | optional | Balance 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 | ||
|---|---|---|
id | required | Your id for the row; never changes, unique in the account. |
account_id | required | An id from /accounts. |
date | required | YYYY-MM-DD, or a date and time with its offset (2026-11-02T14:30:00-05:00). |
amount | required | Signed. With gross, fee or refund given, it must equal gross − fee − refund (a missing one counts as 0). |
currency | required | The account's currency. |
description | optional | Shown as written, as data (kept at most 200 characters). |
type | optional | sale, refund, fee or adjustment. Left out, it's an adjustment: Aggregate never guesses. |
gross | optional | The sale before fees and refunds. |
fee | optional | Fees taken from it (positive). |
refund | optional | Refunded from it (positive). |
payout_id | optional | The 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 | ||
|---|---|---|
id | required | Your id for the payout; never changes. |
account_id | required | A balance account from /accounts. |
date_arrives | required | YYYY-MM-DD the money reaches the bank. |
gross | required | What leaves the balance. |
fees | required | What the payout itself cost. |
net | required | What reaches the bank: gross − fees. |
currency | required | The 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.
- balance: money is held in your system and paid out to a bank later, like a Stripe balance. Serve /payouts. Sales, fees and refunds move the balance; payouts move it to the bank. If you give
balancein /accounts, every sync checks that the rows add up to it, and posts that account's rows only once they do: Aggregate reads the pages, checks the total, then reads the same pages again and posts them all at once. A sync that doesn't add up posts none of them and stops, showing both figures; the next sync that adds up posts them. A sync with more than 5,000 of that account's rows, or more than 10 pages, posts them page by page instead; until it finishes, the connection says "Partially synced, finishing next run". - direct: each row is one deposit (or one payment) of its own at the bank, like a checkout that settles every sale separately. Aggregate matches each row to its own bank row, and until the bank shows it, the row waits as "seen in your system, not yet at the bank", never as cash.
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.
- Refunds, fees paid back and negative sales on a direct account (or on any account when there's no /payouts): "refunds need a balance account with /payouts". Without a balance account, Aggregate can't match a refund to the money leaving your bank, so it refuses the row rather than guess.
- Amounts that don't add up:
amountthat isn't gross − fee − refund, or a payout'snetthat isn't gross − fees. - Amounts as numbers, with too many decimal places for the currency, or with an exponent or grouping.
- Rows before
since, rows in another currency than their account, ids that repeat, anaccount_idthat isn't in /accounts, a payout for a direct account, or a direct account with abalance. - An account that changes kind or currency: add it as a new account id instead.
- Rows that changed between the check and the post (twice in one sync): none of them are posted, and the next sync tries again.
Limits
- 10 seconds per request, 5 MB per response, JSON only.
- 1,000 rows per page (and accounts in /accounts), 200 pages per sync.
- HTTPS on port 443 at a public host name (no IP addresses, no
.localor internal names). Redirects aren't followed: use the final address. - Ids up to 128 characters;
next_cursorup to 512, and never the same one twice in a row. - Aggregate sends only
Authorization,Accept: application/json,Accept-Encoding: identityandUser-Agent: Aggregate (+https://aggregate.finance). No cookies, nothing else.
IP addresses
If your endpoint only lets known IP addresses in, allow the hosted service's two fixed addresses:
209.71.116.2342a09:8280:e618:1:0:1b0:a37b:0
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