API reference
Everything the UI does goes through this API, so you can test it directly with Postman, curl or Robot Framework. The UI and the API enforce the same rules.
Contents
- Conventions · Authentication & sessions · Rate limiting · Error codes
- Auth: register, login, logout
- User: GET /api/me, POST /api/me/reset
- Accounts: list, open, details, close
- Transfers: recipient lookup, create, details
- History: list, CSV export · health
Conventions
- Base path
/apion the same host as this page. JSON in, JSON out (Content-Type: application/json). - Money is Philippine pesos. Responses return amounts as strings with exactly 2 decimals, e.g.
"50000.00","-19.99". Requests accept a string or number with at most 2 decimals ("1500.5",1500.50). No thousands separators, no currency sign. - Timestamps are ISO 8601 in UTC (
2026-11-25T06:15:00.000Z). The UI shows Asia/Manila time. Date filters (from,to) are Manila calendar dates. - Account numbers are 10 digits. Lists return them masked (
******1234); account details return the full number. - Text inputs are trimmed before validation (except passwords).
- You only ever see your own data. Another user's account or transfer returns
404, never403.
Authentication & sessions
- Log in with
POST /api/auth/login. The response has atoken; send it asAuthorization: Bearer <token>. The browser UI uses the HttpOnly cookiebb_sessionset by the same call. - Sessions expire after 30 minutes idle or 8 hours absolute. Activity is recorded at most once a minute, so idle expiry is accurate to about ±1 minute.
- Every endpoint except
/api/health, register and login needs a valid session. - Lockout: 5 consecutive wrong passwords lock the account for 15 minutes (the 5th attempt already returns
ACCOUNT_LOCKED). While locked, even the correct password is rejected. A successful login resets the counter. Unknown usernames do not count.
Rate limiting
60 requests per minute per IP address across all /api endpoints, in fixed 1-minute windows (the window resets at the start of each clock minute). Request 61 in a window returns 429 RATE_LIMITED with a Retry-After header in seconds.
Errors
Every error has the same shape. Messages are deterministic: the same input gives the same text.
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Amount must be at least ₱1.00.",
"fields": { "amount": "Amount must be at least ₱1.00." }
}
}
fields appears on validation errors (one message per invalid field; message is the first one). Some errors add extra properties, listed below.
| HTTP | Code | When |
|---|---|---|
| 400 | INVALID_JSON | Body is not a JSON object |
| 400 | VALIDATION_ERROR | One or more fields fail format rules (see fields) |
| 401 | UNAUTHORIZED | No token, or unknown / logged-out token |
| 401 | SESSION_EXPIRED | Idle for 30+ minutes or older than 8 hours |
| 401 | INVALID_CREDENTIALS | Wrong username/email or password. Adds attemptsRemaining when the user exists |
| 403 | ACCOUNT_LOCKED | Too many failed logins. Adds lockedUntil, retryAfterSeconds |
| 404 | NOT_FOUND | Unknown endpoint |
| 404 | ACCOUNT_NOT_FOUND | Account id does not exist or is not yours |
| 404 | RECIPIENT_NOT_FOUND | No account with that account number |
| 404 | TRANSFER_NOT_FOUND | Reference does not exist or you are neither sender nor recipient |
| 405 | METHOD_NOT_ALLOWED | Endpoint exists but not for this method (see Allow header) |
| 409 | EMAIL_TAKEN | Email already registered (case-insensitive) |
| 409 | USERNAME_TAKEN | Username already registered (case-insensitive) |
| 409 | ACCOUNT_ALREADY_CLOSED | Closing an account that is already closed |
| 422 | INSUFFICIENT_FUNDS | Source balance is lower than the amount |
| 422 | DAILY_LIMIT_EXCEEDED | Transfer would take today's total above ₱100,000.00. Adds usedToday, remainingToday |
| 422 | SAME_ACCOUNT | Source and destination are the same account |
| 422 | ACCOUNT_CLOSED | Source account is closed |
| 422 | DESTINATION_CLOSED | Destination account is closed |
| 422 | MAX_ACCOUNTS_REACHED | Already 5 open accounts |
| 422 | BELOW_MINIMUM_DEPOSIT | Opening deposit below ₱500.00 (Savings) / ₱1,000.00 (Checking) |
| 422 | ACCOUNT_NOT_EMPTY | Closing an account whose balance is not ₱0.00 |
| 422 | LAST_ACCOUNT | Closing your only open account |
| 429 | RATE_LIMITED | More than 60 requests in the current minute. Adds retryAfterSeconds |
| 500 | INTERNAL_ERROR | Unexpected server error (please report it) |
Auth
POST /api/auth/register
Creates a user and a Savings account with ₱50,000.00 demo funds (OPENING_BALANCE). Does not log in.
fullName: 2–50 chars; letters, spaces,-and'only. Repeated spaces are collapsed.email: valid format, max 254 chars, unique (case-insensitive). Stored lowercase.username: 4–20 chars; letters, digits, underscore. Unique (case-insensitive).password: 8–64 chars, at least one uppercase, one lowercase, one digit and one special character; must not contain the username (case-insensitive).confirmPassword: must equalpassword.
POST /api/auth/register
{ "fullName": "Juan Dela Cruz", "email": "juan@example.com", "username": "juan_qa",
"password": "Str0ng!Pass", "confirmPassword": "Str0ng!Pass" }
201 Created
{ "user": { "id": 7, "fullName": "Juan Dela Cruz", "username": "juan_qa",
"email": "juan@example.com", "createdAt": "2026-11-25T06:15:00.000Z" } }
Errors: 400 VALIDATION_ERROR, 409 EMAIL_TAKEN, 409 USERNAME_TAKEN. Email is checked before username.
POST /api/auth/login
identifier is a username or an email (anything containing @ is treated as an email). Both are case-insensitive.
POST /api/auth/login
{ "identifier": "juan_qa", "password": "Str0ng!Pass" }
200 OK (also sets the bb_session cookie)
{ "token": "q2v...Xc", "tokenType": "Bearer", "expiresAt": "2026-11-25T14:15:00.000Z",
"idleTimeoutSeconds": 1800, "user": { ... } }
401 { "error": { "code": "INVALID_CREDENTIALS", "message": "Invalid username/email or password.", "attemptsRemaining": 3 } }
403 { "error": { "code": "ACCOUNT_LOCKED", "message": "Account is locked due to too many failed login attempts. Try again later.",
"lockedUntil": "2026-11-25T06:30:00.000Z", "retryAfterSeconds": 900 } }
POST /api/auth/logout
Invalidates the current token server-side and clears the cookie. Using the token afterwards returns 401 UNAUTHORIZED.
200 OK
{ "message": "Logged out." }
User
GET /api/me
200 OK
{ "user": { "id": 7, "fullName": "Juan Dela Cruz", "username": "juan_qa", "email": "juan@example.com",
"createdAt": "2026-11-25T06:15:00.000Z" } }
POST /api/me/reset
Deletes all your accounts, transactions and transfers (so today's transfer-limit usage is cleared too), then creates a fresh Savings account with ₱50,000.00. Other users are not affected; transactions already in their accounts stay. No body. Returns the same shape as GET /api/accounts.
Accounts
GET /api/accounts
Your open accounts, oldest first, with masked numbers. totalBalance is the sum of all open accounts.
200 OK
{ "accounts": [
{ "id": 12, "accountNumber": "******4821", "maskedAccountNumber": "******4821", "type": "SAVINGS",
"nickname": null, "balance": "48500.00", "status": "OPEN",
"createdAt": "2026-11-25T06:15:00.000Z", "closedAt": null } ],
"totalBalance": "48500.00" }
POST /api/accounts
type:"SAVINGS"or"CHECKING"(exact, uppercase).nickname: optional, 1–20 chars. Empty or whitespace means no nickname.sourceAccountId: one of your open accounts; the opening deposit is moved from it.openingDeposit: at least ₱500.00 (Savings) or ₱1,000.00 (Checking), at most the source balance. Opening deposits do not count toward the daily transfer limit or the ₱50,000.00 per-transfer maximum.- Maximum 5 open accounts per user (closed ones don't count).
Creates two transactions sharing one reference: TRANSFER_OUT on the source and OPENING_BALANCE on the new account.
POST /api/accounts
{ "type": "CHECKING", "nickname": "Bills", "sourceAccountId": 12, "openingDeposit": "1000.00" }
201 Created
{ "account": { "id": 13, "accountNumber": "5038816620", "maskedAccountNumber": "******6620", "type": "CHECKING",
"nickname": "Bills", "balance": "1000.00", "status": "OPEN", ... },
"reference": "BB-20261125-7KQ2ZD" }
Check order: 400 VALIDATION_ERROR → 422 MAX_ACCOUNTS_REACHED → 404 ACCOUNT_NOT_FOUND (source) → 422 ACCOUNT_CLOSED → 422 BELOW_MINIMUM_DEPOSIT → 422 INSUFFICIENT_FUNDS.
GET /api/accounts/:id
One of your accounts (open or closed) with the full account number. 404 ACCOUNT_NOT_FOUND otherwise.
200 OK
{ "account": { "id": 13, "accountNumber": "5038816620", "maskedAccountNumber": "******6620", ... } }
DELETE /api/accounts/:id
Closes the account. It must have a balance of exactly ₱0.00 and must not be your only open account. Closed accounts disappear from lists but their history stays.
Check order: 404 ACCOUNT_NOT_FOUND → 409 ACCOUNT_ALREADY_CLOSED → 422 LAST_ACCOUNT → 422 ACCOUNT_NOT_EMPTY.
200 OK
{ "account": { "id": 13, "status": "CLOSED", "closedAt": "2026-11-25T07:00:00.000Z", ... } }
Transfers
GET /api/recipients/lookup?accountNumber=5038816620
Shows who you are about to pay, for the confirmation screen. Returns only the recipient's first name.
200 OK
{ "maskedAccountNumber": "******6620", "firstName": "Maria", "isOwnAccount": false }
Errors: 400 VALIDATION_ERROR (field accountNumber), 404 RECIPIENT_NOT_FOUND, 422 DESTINATION_CLOSED.
POST /api/transfers
Same endpoint for own-account and external transfers: the destination is always an account number. kind in the response is OWN if the destination is yours, else EXTERNAL.
fromAccountId: one of your open accounts.toAccountNumber: exactly 10 digits; must exist and be open; not the source account.amount: ₱1.00 to ₱50,000.00 inclusive, max 2 decimals. Zero, negative and non-numeric values are rejected.note: optional, up to 100 chars after trimming.- Daily limit: ₱100,000.00 of transfers per user per day, summed across all your accounts (own and external transfers both count). The day resets at 00:00 Asia/Manila.
Creates a TRANSFER_OUT on the source and a TRANSFER_IN on the destination, atomically, sharing a reference BB-YYYYMMDD-XXXXXX (Manila date + 6 uppercase letters/digits).
POST /api/transfers
{ "fromAccountId": 12, "toAccountNumber": "5038816620", "amount": "1500.00", "note": "Rent share" }
201 Created
{ "transfer": { "reference": "BB-20261125-Q8M3TA", "kind": "EXTERNAL", "direction": "OUT", "status": "COMPLETED",
"fromAccount": { "id": 12, "maskedAccountNumber": "******4821" },
"toAccount": { "maskedAccountNumber": "******6620" },
"senderFirstName": "Juan", "recipientFirstName": "Maria",
"amount": "1500.00", "note": "Rent share", "createdAt": "2026-11-25T06:20:00.000Z",
"sourceBalanceAfter": "47000.00" } }
Check order: 400 VALIDATION_ERROR → 404 ACCOUNT_NOT_FOUND → 422 ACCOUNT_CLOSED → 404 RECIPIENT_NOT_FOUND → 422 DESTINATION_CLOSED → 422 SAME_ACCOUNT → 422 INSUFFICIENT_FUNDS → 422 DAILY_LIMIT_EXCEEDED.
GET /api/transfers/:reference
Visible to the sender and the recipient. direction is from your point of view. Account ids are only included for your own side.
Transaction history
GET /api/transactions
Your transactions across all your accounts (including closed ones), 10 per page.
| Param | Values | Default |
|---|---|---|
accountId | One of your account ids | all |
type | OPENING_BALANCE, TRANSFER_IN, TRANSFER_OUT | all |
from, to | YYYY-MM-DD (Manila dates, inclusive). Not in the future; from ≤ to; span at most 1 year (to ≤ from + 1 year). Either may be used alone. | none |
q | Partial, case-insensitive match on reference or description. Max 100 chars. | none |
sort | date or amount (signed: debits sort below credits) | date |
order | asc or desc | desc |
page | Integer ≥ 1. A page past the end returns an empty items array. | 1 |
GET /api/transactions?type=TRANSFER_OUT&sort=amount&order=asc&page=1
200 OK
{ "items": [
{ "id": 88, "createdAt": "2026-11-25T06:20:00.000Z", "reference": "BB-20261125-Q8M3TA",
"description": "Transfer to Maria ******6620", "type": "TRANSFER_OUT",
"amount": "-1500.00", "runningBalance": "47000.00", "note": "Rent share",
"account": { "id": 12, "maskedAccountNumber": "******4821" } } ],
"page": 1, "pageSize": 10, "totalItems": 1, "totalPages": 1 }
runningBalance is the balance of that row's account right after the transaction. Errors: 400 VALIDATION_ERROR (fields named after the params), 404 ACCOUNT_NOT_FOUND.
GET /api/transactions/export
Same filters, search and sort as the list, without pagination (all matching rows). Returns text/csv as an attachment named buggybank-transactions-YYYYMMDD.csv.
Date (Asia/Manila),Reference,Description,Type,Amount,Running Balance,Account 2026-11-25 14:20:00,BB-20261125-Q8M3TA,Transfer to Maria ******6620,TRANSFER_OUT,-1500.00,47000.00,******4821
GET /api/health
No auth. mode tells you whether this deployment has the seeded bugs switched on.
200 OK
{ "status": "ok", "mode": "buggy", "time": "2026-11-25T06:20:00.000Z" }