> ## Documentation Index
> Fetch the complete documentation index at: https://docs.awokenlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exports

> Server-side functions other scripts call to read balances, move money, run charges, and check credit.

Awoken Banking exposes **server-side exports** so your other resources can read balances, move money, charge cards, run credit checks, and collect tax - all through the same ledger, fees, and history the bank itself uses.

<Warning>
  **Every export is server-side.** Call them from a server script only. Calling from the client won't work.
</Warning>

```lua server-side only theme={"dark"}
local balance = exports.awoken_banking:getAccountMoney('AWK-1234-5678')

-- Bill a customer 10% sales tax through the bank's tax engine
local taxTaken = exports.awoken_banking:chargeTax(customerCid, price, 'sales', { src = source })
```

## Account keys

Almost every export takes an **`accountKey`** - a loose reference to an account. Awoken Banking accepts any of these and figures out which account you mean. Anywhere an `accountKey` or `citizenid` is expected, you can also pass an online player's server id (a bare number).

| You can pass                                   | Example                                                               |
| ---------------------------------------------- | --------------------------------------------------------------------- |
| A readable account number                      | `'AWK-1234-5678'`                                                     |
| A player's citizen id (their personal account) | `'ABC12345'`                                                          |
| A job name (that job's shared account)         | `'police'`                                                            |
| A gang name (that gang's shared account)       | `'ballas'`                                                            |
| An internal id                                 | `'personal:ABC12345'`, `'job:police'`, `'gang:ballas'`, `'shared:42'` |

## Money and accounts

The core read/write API. `addAccountMoney`, `removeAccountMoney`, `transferMoney`, and `payAccount` all write to the ledger, so every change shows up in the account's history.

| Export                                          | What it does                                                                                                                                                                                                                                                                            |
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `getAccountMoney(accountKey)`                   | Returns the balance, or `false` if the account doesn't exist.                                                                                                                                                                                                                           |
| `addAccountMoney(accountKey, amount)`           | Credits the account. Returns a boolean.                                                                                                                                                                                                                                                 |
| `removeAccountMoney(accountKey, amount)`        | Debits the account. Returns a boolean.                                                                                                                                                                                                                                                  |
| `transferMoney(fromKey, toKey, amount, opts)`   | Moves money between two accounts - atomic and fee-aware. `opts` accepts `memo` and `issuer`. Returns a boolean.                                                                                                                                                                         |
| `payAccount(accountKey, amount, opts)`          | Pays money **into** an account as a billing destination and logs it. `opts` accepts `title`, `memo`, `from`. Returns a boolean.                                                                                                                                                         |
| `getAccount(accountKey)`                        | Returns `{ id, account_number, type, owner, label, balance }`, or `nil`.                                                                                                                                                                                                                |
| `accountExists(accountKey)`                     | Returns a boolean.                                                                                                                                                                                                                                                                      |
| `getAccountTransactions(accountKey)`            | Returns the account's recent transaction rows.                                                                                                                                                                                                                                          |
| `getStatement(accountKey, days)`                | Returns summarised statement rows over the last `days` (default 30).                                                                                                                                                                                                                    |
| `createSharedAccount(citizenid, label)`         | Opens a shared account owned by that player. Returns the new account number, or `false`.                                                                                                                                                                                                |
| `getAccountMembers(accountKey)`                 | Returns the account's members.                                                                                                                                                                                                                                                          |
| `setAccountMember(accountKey, citizenid, role)` | Adds or updates a member's role. Returns a boolean.                                                                                                                                                                                                                                     |
| `getAccountTier(accountKey)`                    | Returns the account's savings tier, or `nil`.                                                                                                                                                                                                                                           |
| `setAccountTier(accountKey, tierId)`            | Sets the account's savings tier (must be a valid tier id). Returns a boolean.                                                                                                                                                                                                           |
| `freezeAccount(accountKey, frozen, reason)`     | Legal hold - for DOJ / police scripts. `frozen` defaults to `true`; pass `false` to lift it. Optional `reason` is shown to the account holder. A frozen account moves **no** money through the bank (player ops, transfers in, cards, loan auto-pay, tax, interest). Returns a boolean. |
| `seizeFunds(fromKey, amount, opts)`             | Civil forfeiture - removes money from an account, working **even while it's frozen**. `opts` accepts `toKey` (destination account; omit to take it out of circulation), `reason`, and `by`. Seizes up to the balance. Returns `{ ok, amount, to }` or `{ ok = false, error }`.          |
| `closeAccount(accountKey)`                      | Closes the account. Returns a boolean.                                                                                                                                                                                                                                                  |

## Drop-in compatible (Renewed / qb-management)

Awoken Banking ships the same signatures as the de-facto standard banks, and answers under the `Renewed-Banking`, `qb-banking`, `qb-management`, and `esx_society` resource names - so scripts written for them keep working without a code change. The framework's own payroll and society systems read and write shared business accounts through these names, controlled by `Config.SocietyBridge`. See [Society accounts](/resources/awoken-banking/configuration/society).

| Export                                                                                     | What it does                                                                                                                                         |
| ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `handleTransaction(account, title, amount, message, issuer, receiver, transType, transID)` | Logs a transaction (Renewed-compatible - **log only**, it does not move money). Note the `message`-before-`issuer` argument order, matched verbatim. |
| `GetJobAccount(job)`                                                                       | Returns the raw account for a job.                                                                                                                   |
| `CreateJobAccount(job, balance)`                                                           | Creates a job's shared account, optionally seeded with `balance`.                                                                                    |
| `addAccountMember(accountKey, member)`                                                     | Adds a member. Returns a boolean.                                                                                                                    |
| `removeAccountMember(accountKey, member)`                                                  | Removes a member. Returns a boolean.                                                                                                                 |
| `changeAccountName(accountKey, newName)`                                                   | Renames the account.                                                                                                                                 |

## Cards

Charge and manage bank cards from shops or other resources. A charge respects the card's limits, expiry, frozen state, and PIN.

| Export                             | What it does                                                                                                               |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `hasCard(accountKey)`              | Returns a boolean - whether the account has any cards.                                                                     |
| `getCards(accountKey)`             | Returns the account's cards.                                                                                               |
| `chargeCard(cardId, amount, opts)` | Debits the card's linked account through its checks. `opts` accepts `pin`, `title`, `memo`, `merchant`. Returns a boolean. |
| `freezeCard(cardId, frozen)`       | Freezes or unfreezes a card. `frozen` defaults to `true`. Returns a boolean.                                               |
| `getCardPin(cardId)`               | Returns the card's PIN (for staff / admin tooling), or `nil`.                                                              |

## Loans and credit

A player's credit score drives **one** borrowing limit; all debt - bank loans and financed purchases - draws from it. Here `player` accepts either a server id (number) or a citizen id (string).

| Export                                        | What it does                                                                                                                                                                                               |
| --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GetCredit(player)`                           | Returns `{ score, limit, outstanding, available }`, or `nil`.                                                                                                                                              |
| `Quote(player, opts)`                         | Previews finance terms - a pure calculator, no commitment. Returns `{ ok, apr, perPayment, totalRepayable, … }`.                                                                                           |
| `Finance(player, opts)`                       | Books a loan. Returns `{ ok = true, loanId }` or `{ ok = false, error }`. `payTo` = `{ job }` / `{ account }` / `{ cid }` (omit for a cash loan); `confirm = true` shows the borrower the contract dialog. |
| `Repay(player, loanId, amount, fromAccount)`  | Repays a loan (defaults to the borrower's personal account). Returns `{ ok, outstanding }`.                                                                                                                |
| `Settle(loanId)`                              | Closes a loan early without a payment (refund / post-repossession). Returns `{ ok }`.                                                                                                                      |
| `getCreditScore(citizenid)`                   | Returns the score, or `nil`.                                                                                                                                                                               |
| `adjustCreditScore(citizenid, delta, reason)` | Nudges a score up or down. Returns a boolean.                                                                                                                                                              |
| `listLoans(citizenid)`                        | Returns the player's loan rows.                                                                                                                                                                            |
| `forcePayoff(loanId)`                         | Force-pays a loan off (alias of `Settle`). Returns a boolean.                                                                                                                                              |

`opts` for `Quote` / `Finance`: `amount` (required), `deposit`, `termDays`, `paymentEveryDays`, `apr` (a clamped override), `firstPaymentInDays`, and `schedule` (Quote only). `Finance` also takes `payTo`, `label`, `metadata`, `onDefault` (`'notify'` / `'overdraft'`), and `confirm`. `source` auto-fills to the calling resource, so the loan's default / paid-off events route back to you.

## Bills and requests

Raise "money owed" against a player - both land in their bank inbox (app + phone). A **request** is a one-off invoice the payer can pay or decline; a **bill** is a recurring / official obligation they can only pay. See [Bills & requests](/resources/awoken-banking/configuration/billing). All of these no-op when `Config.Bills.enabled` is off.

| Export                    | What it does                                                                                                                                                                                                                                                                                                                  |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `createInvoice(opts)`     | Raises a one-off **request**. `opts` = `{ to, from, amount, reason?, name?, expiresIn? }` - `to` is a citizenid or live server id, `from` is the account the payment lands in. Returns the request id, or `false`.                                                                                                            |
| `createBill(opts)`        | Raises a **bill**. `opts` = `{ owner, name, amount, issuer?, category?, to?, dueIn?, recurring?, everyDays? }` - `category` is one of `utility`/`rent`/`insurance`/`subscription`/`fine`/`tax`/`other`, `dueIn` is seconds until due, `recurring` + `everyDays` respawns it on each payment. Returns the bill id, or `false`. |
| `listInvoices(citizenid)` | Open requests owed by a player.                                                                                                                                                                                                                                                                                               |
| `listBills(citizenid)`    | Outstanding bills owed by a player.                                                                                                                                                                                                                                                                                           |
| `listDues(citizenid)`     | All outstanding dues owed by a player (both kinds).                                                                                                                                                                                                                                                                           |
| `cancelInvoice(id)`       | Retract a request you raised (issuer-side). Returns a boolean.                                                                                                                                                                                                                                                                |
| `cancelBill(id)`          | Retract a bill you raised (issuer-side). Returns a boolean.                                                                                                                                                                                                                                                                   |

## Stocks and investing

Register tradable tickers and drive their prices from real activity, or manage a business listing programmatically. See [Investing & stocks](/resources/awoken-banking/configuration/investing).

| Export                                   | What it does                                                                                                                                                                                                                                                                                       |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `registerStock(opts)`                    | Registers a ticker. `opts` = `{ symbol, name, kind, price, volatility?, ownerAccount?, totalShares?, floatShares?, minPrice?, maxPrice? }` - `kind` is `'ambient'` (Public), `'index'` (Sector), or `'business'`. `minPrice`/`maxPrice` cap a Public/Sector price. Returns the symbol, or `false`. |
| `adjustStockPrice(symbol, deltaPct)`     | Nudges a price by a fraction (e.g. `0.015` = +1.5%). Drive Sector / Business prices from work done. Returns a boolean.                                                                                                                                                                             |
| `setStockPrice(symbol, price)`           | Sets a price outright. Returns a boolean.                                                                                                                                                                                                                                                          |
| `delistStock(symbol)`                    | Removes a ticker; holders are cashed out at the current price. Returns a boolean.                                                                                                                                                                                                                  |
| `getPrice(symbol)`                       | The current price, or `nil`.                                                                                                                                                                                                                                                                       |
| `getHoldings(citizenid)`                 | A player's portfolio.                                                                                                                                                                                                                                                                              |
| `getShareholders(symbol)`                | Everyone holding a ticker.                                                                                                                                                                                                                                                                         |
| `getOrders(symbol)`                      | The open order book (asks / bids) for a ticker.                                                                                                                                                                                                                                                    |
| `setFloat(symbol, floatShares)`          | Business: release more / less of the primary float. Returns a boolean.                                                                                                                                                                                                                             |
| `payDividend(symbol, perShare)`          | Business: pay a one-off dividend per share from the business account. Returns a boolean.                                                                                                                                                                                                           |
| `setRecurringDividend(symbol, perShare)` | Business: set (or clear, with `0`) a recurring dividend. Returns a boolean.                                                                                                                                                                                                                        |
| `buyback(symbol, shares, price)`         | Business: post a buyback bid; filled shares return to the float and the business pays. Returns a boolean.                                                                                                                                                                                          |

## Tax

Route third-party charges through the bank's tax engine - the same rate table, destination splits, and revenue logging as the built-in taxes. `kind` picks a rate from `Config.Tax.rates` (falling back to `Config.Tax.rate`); add your own kinds such as `sales` or `business`. Custom kinds fire **only** when you call these exports, and work whenever the kind has a rate, independent of `Config.Tax.enabled`.

| Export                                    | What it does                                                                                                                                                                                                |
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `taxQuote(amount, kind)`                  | Returns the tax `amount` would incur at `kind`'s rate. Pure - no side effects.                                                                                                                              |
| `chargeTax(payerKey, amount, kind, opts)` | Debits `payerKey` and routes the tax to its destination. `opts.src` = the paying player's server id, used for job / citizen-id exemptions. Returns the tax actually taken (`0` if none / exempt / no rate). |
