← Back to Billbook

Remote Bookkeeping API

Last updated: November 25, 2026

Log and look up entries from cURL, iOS Shortcuts, automation scripts, or AI bots using a personal API token. The token can insert transactions, read transactions dated within the last 14 days, and read the category / tag lists. It cannot edit or delete anything, and it cannot reach older entries.

1. Get a token

Sign in, open Settings → 🔑 Remote Bookkeeping API, and click "Generate token".

The plaintext token is shown exactly once — copy it immediately. The server only stores its SHA-256 hash, so a lost token can only be replaced by rotating (which invalidates the old one).

Token format: bb_<userId>_<secret>. Send it on every request as Authorization: Bearer <token>.

2. POST /api/ingest — insert one transaction

Request body is a JSON object with these fields:

  • title (string, required) — transaction name
  • amount (number, required) — must be positive
  • type (string, optional, default expense) — one of expense / income / prepaid_expense / pending_income
  • category (string, optional) — category name
  • note (string, optional) — free-form note
  • created_at (string, optional) — ISO 8601; defaults to now. Must fall within the last 14 days (up to tomorrow), otherwise 400
curl -X POST https://billbook.me/api/ingest \
  -H "Authorization: Bearer bb_<userId>_<secret>" \
  -H "Content-Type: application/json" \
  -d '{"title":"Coffee","amount":120,"type":"expense","category":"Food"}'

# response: 201
{ "id": "...", "created_at": "..." }

3. GET /api/ingest — read the last 14 days

Returns transactions dated within the last 14 days (up to tomorrow), newest first. Trashed entries are excluded. Query parameters:

  • from / to (ISO 8601, optional) — narrow the range; anything outside the last 14 days is clamped off
  • limit (optional, default 200, max 1000) — truncated: true in the response means more rows exist; narrow from / to and query again
  • Scope matches the dashboard: a staff token sees only its owner's entries; an admin / manager token sees the whole organization
  • Fields per entry: id, created_at, title, amount, type, category, note, mine (whether the token owner logged it)
curl "https://billbook.me/api/ingest?limit=50" \
  -H "Authorization: Bearer bb_<userId>_<secret>"

# response: 200
{
  "from": "...", "to": "...", "truncated": false,
  "transactions": [
    { "id": "...", "created_at": "...", "title": "Coffee", "amount": 120,
      "type": "expense", "category": "Food", "note": null, "mine": true }
  ]
}

4. GET /api/ingest/categories — list categories

Returns the admin's category names in dashboard dropdown order. Response contains only the names — no ids, user ids, or transaction data.

curl https://billbook.me/api/ingest/categories \
  -H "Authorization: Bearer bb_<userId>_<secret>"

# response: 200
{ "categories": ["Food", "Rent", "..."] }

5. GET /api/ingest/tags — recently used tag prefixes

Returns the most recently updated tag prefixes (the #XXX markers embedded in titles). Defaults to 20 entries; pass ?limit= to override (max 100).

Returns an empty array instead of an error if the tag_prefixes table doesn't exist yet.

curl "https://billbook.me/api/ingest/tags?limit=20" \
  -H "Authorization: Bearer bb_<userId>_<secret>"

# response: 200
{ "tags": ["#management-fee", "#travel", "..."] }

6. Error codes

All errors are JSON: { "error": "message" }.

  • 400 — invalid body or query, or created_at / range outside the last 14 days
  • 401 — missing authorization, malformed token, or token revoked / mismatched
  • 402 — subscription expired; renewal required to write
  • 405 — method not supported (e.g. DELETE on /api/ingest)
  • 501 — server is missing SUPABASE_SERVICE_ROLE_KEY
  • 500 — other internal error

7. Security and limits

The token only reaches its own organization, and only recent entries:

  • user_id is always set to the token owner; it can't be forged
  • org_id is always the owner's org; cross-org writes are impossible
  • Every member (admin / manager / staff) gets their own token; entries are recorded under that member
  • Reads and inserts are limited to transactions dated within the last 14 days, so reconciled months can't be changed through the API
  • Revocation is immediate; rotate any time from Settings
  • No edit or delete; an insert only returns { id, created_at }

8. iOS Shortcut example

Add a "Get Contents of URL" action, set URL to https://billbook.me/api/ingest, method POST, headers Authorization: Bearer bb_... and Content-Type: application/json, and request body as JSON: {"title":"Coffee","amount":120,"type":"expense"}. Wire title and amount to Shortcut input or Ask Each Time variables.

This document is a quick reference; the backend code is the source of truth for actual behavior.