# TreasuryPrime v1.0.0 - Table of Contents

> An unofficial, complete Elixir client for the Treasury Prime banking API (Ledger product) -- accounts, ACH, wires, book transfers, FedNow, cards, KYC/account opening, check deposit, webhooks, sandbox simulations, and more.

## Pages

- [TreasuryPrime](readme.md)
- [Changelog](changelog.md)
- [LICENSE](license.md)

## Modules

- [TreasuryPrime.AverageBalance](TreasuryPrime.AverageBalance.md): A single month's average account balance, as returned by
`TreasuryPrime.Account.average_balances/3`. Not independently
listable/fetchable — always scoped to an account.

- [TreasuryPrime.DailyBalance](TreasuryPrime.DailyBalance.md): A single day's closing account balance, as returned by
`TreasuryPrime.Account.daily_balances/3`. Not independently
listable/fetchable — always scoped to an account.

- [TreasuryPrime.HTTP](TreasuryPrime.HTTP.md): Internal HTTP orchestration layer shared by every resource module. Not
part of the public API — use the resource modules
(`TreasuryPrime.Account`, `TreasuryPrime.Ach`, etc.) instead.
- [TreasuryPrime.HTTPClient](TreasuryPrime.HTTPClient.md): Behaviour for the HTTP transport used by `TreasuryPrime.Client`.
- [TreasuryPrime.HTTPClient.Httpc](TreasuryPrime.HTTPClient.Httpc.md): Default `TreasuryPrime.HTTPClient` adapter, built entirely on Erlang's
built-in `:httpc` (part of the `:inets` application) and `:ssl`. This means
`treasury_prime` has no required HTTP dependency at all — no Req, no
Finch, no Hackney.
- [TreasuryPrime.Resource](TreasuryPrime.Resource.md): Shared plumbing used internally by every resource module
(`TreasuryPrime.Account`, `TreasuryPrime.Ach`, `TreasuryPrime.Card`, ...)
to implement `list/2`, `get/2`, `create/2`, `update/3`, and `delete/2` in
terms of `TreasuryPrime.HTTP`.

- Client
  - [TreasuryPrime](TreasuryPrime.md): An unofficial, complete Elixir client for the [Treasury Prime](https://www.treasuryprime.com)
banking API (the Ledger product) — bank accounts, ACH, wires, book
transfers, FedNow, cards, account opening / KYC, check deposit (RDC),
check issuing, webhooks, sandbox simulations, and more.
  - [TreasuryPrime.Client](TreasuryPrime.Client.md): Holds everything needed to talk to the Treasury Prime API: credentials,
which environment to call, and HTTP transport configuration.
  - [TreasuryPrime.Config](TreasuryPrime.Config.md): Optional convenience for building a `TreasuryPrime.Client` from
application configuration / environment variables, instead of constructing
one by hand at every call site.
  - [TreasuryPrime.Error](TreasuryPrime.Error.md): The exception struct raised/returned for every failure mode of this
library: HTTP-level errors returned by the Treasury Prime API, transport
failures (DNS, TLS, timeouts, connection refused), and client-side
validation errors (e.g. a missing required field) caught before a request
is even sent.
  - [TreasuryPrime.Idempotency](TreasuryPrime.Idempotency.md): Helpers for working with Treasury Prime's idempotency support.
  - [TreasuryPrime.Page](TreasuryPrime.Page.md): A single page of results from a `list/*` call, plus everything needed to
fetch subsequent pages.

- Account Opening
  - [TreasuryPrime.AccountApplication](TreasuryPrime.AccountApplication.md): The entry point for opening a new bank account. An account application
ties together one or more `TreasuryPrime.PersonApplication`s (for a
personal account) or a `TreasuryPrime.BusinessApplication` plus its
associated person applications (for a business account), an
`TreasuryPrime.AccountProduct`, and optionally an initial
`TreasuryPrime.Deposit`. Once approved, `account_id` is populated with
the newly created `TreasuryPrime.Account`.
  - [TreasuryPrime.AccountNumberReservation](TreasuryPrime.AccountNumberReservation.md): Reserves an account number / routing number pair ahead of an account
being fully opened — useful when you need to give a customer their
future account number immediately (e.g. to print on a welcome packet or
set up payroll direct deposit) before the underlying
`TreasuryPrime.AccountApplication` has finished processing.

  - [TreasuryPrime.AccountProduct](TreasuryPrime.AccountProduct.md): Account products are bank-configured templates (interest rate tiers, fee
schedules, eligibility rules) that `TreasuryPrime.Account`s are created
under. They're configured by your bank partner / in the Bank Console, so
this resource is read-only — use it to look up which products are
available to offer when submitting an `TreasuryPrime.AccountApplication`.

  - [TreasuryPrime.AdditionalPersonApplication](TreasuryPrime.AdditionalPersonApplication.md): Adds a new owner, signer, or authorized user to an *already open*
account (as opposed to `person_applications` passed at
`TreasuryPrime.AccountApplication.create/3` time, which is for people
added during initial account opening).
  - [TreasuryPrime.BusinessApplication](TreasuryPrime.BusinessApplication.md): Captures identifying/KYB information for a business as part of opening a
business account, including its beneficial owners, control persons, and
signers (each represented by a `TreasuryPrime.PersonApplication`). Once
approved, `business_id` is populated with the resulting
`TreasuryPrime.Business`.
  - [TreasuryPrime.Deposit](TreasuryPrime.Deposit.md): An initial funding deposit for a new account, created during account
opening and referenced via `deposit_id` on a
`TreasuryPrime.AccountApplication`. Once the account application is
approved, the deposit is processed and funds become the account's
opening balance.
  - [TreasuryPrime.Kyc](TreasuryPrime.Kyc.md): Triggers and tracks a KYC (Know Your Customer) / KYB (Know Your Business)
evaluation for a `TreasuryPrime.PersonApplication` or
`TreasuryPrime.BusinessApplication`, using one of your bank partner's
configured `TreasuryPrime.KycProduct`s (i.e. their chosen
identity-verification vendor integration).
  - [TreasuryPrime.KycProduct](TreasuryPrime.KycProduct.md): KYC products represent the identity-verification vendor integration(s)
your bank partner has configured (e.g. a specific KYC/KYB provider with
specific evaluation rules). Read-only — pass a `kyc_product_id` from
here to `TreasuryPrime.Kyc.create/3`.

  - [TreasuryPrime.PersonApplication](TreasuryPrime.PersonApplication.md): Captures identifying/KYC information for an individual as part of opening
an account — either the primary applicant on a personal account, or an
owner/signer/beneficial-owner on a business account. Once the associated
`TreasuryPrime.AccountApplication` (and any required
`TreasuryPrime.Kyc` evaluation) is approved, `person_id` is populated
with the resulting `TreasuryPrime.Person`.

- Accounts &amp; Parties
  - [TreasuryPrime.Account](TreasuryPrime.Account.md): Bank accounts: balances, ownership, locking, interest rates, statements,
tax documents, and transaction history.
  - [TreasuryPrime.AccountLock](TreasuryPrime.AccountLock.md): Read-only history of lock/unlock events for accounts. To actually lock or
unlock an account, use `TreasuryPrime.Account.lock/3` and
`TreasuryPrime.Account.unlock/2` (which `PATCH` the account itself) —
this resource only lets you list/inspect what happened, e.g. for an audit
trail.

  - [TreasuryPrime.Business](TreasuryPrime.Business.md): The canonical, current record for a business associated with one or more
accounts — created automatically when its `TreasuryPrime.BusinessApplication`
is approved.
  - [TreasuryPrime.Person](TreasuryPrime.Person.md): The canonical, current record for an individual associated with one or
more accounts (as an owner, signer, or authorized user) — created
automatically when their `TreasuryPrime.PersonApplication` is approved.
  - [TreasuryPrime.ReserveAccount](TreasuryPrime.ReserveAccount.md): Reserve accounts are special-purpose accounts (e.g. holding loss
reserves, prefunding, or program collateral) that you manage on behalf
of your program with your bank partner. Unlike `TreasuryPrime.Account`,
reserve accounts support `delete/2`.

  - [TreasuryPrime.StatementConfig](TreasuryPrime.StatementConfig.md): Configures the boilerplate content (legal name, support contact info,
APY/footnote disclosures required by Regulation DD, branding) used when
generating account statements via `TreasuryPrime.Account.generate_statement/3`.
Once configured, you no longer need to pass that boilerplate on every
statement generation call.

  - [TreasuryPrime.TaxDocument](TreasuryPrime.TaxDocument.md): A tax document (e.g. a 1099-INT) generated/filed for an account.
  - [TreasuryPrime.Transaction](TreasuryPrime.Transaction.md): Ledger transactions — the append-only record of everything that's
happened to an account's balance (deposits, withdrawals, holds, holds
being released, interest, fees, reversals, ...).

- Payments
  - [TreasuryPrime.Ach](TreasuryPrime.Ach.md): ACH transfers — electronic transfers between bank accounts at different
banks, originated through Treasury Prime (for incoming, externally
originated ACH, see `TreasuryPrime.IncomingAch`).
  - [TreasuryPrime.Book](TreasuryPrime.Book.md): Book transfers — instant transfers between two accounts at the *same*
bank (no ACH/wire rails involved, so they settle immediately and have no
network fees). Common uses: moving money between a customer's sub-accounts,
or from a customer account to your own operating/reserve account at the
same bank.
  - [TreasuryPrime.Check](TreasuryPrime.Check.md): Check issuing — mail a physical paper check from one of your accounts.
  - [TreasuryPrime.CheckDeposit](TreasuryPrime.CheckDeposit.md): Remote Deposit Capture (RDC) — deposit a check by uploading photos of the
front and back.
  - [TreasuryPrime.Counterparty](TreasuryPrime.Counterparty.md): A counterparty represents the external bank account on the other side of
an ACH or wire transfer — i.e. who you're sending money to, or pulling
money from. Created once and then referenced by `counterparty_id` from
`TreasuryPrime.Ach.create/3` and `TreasuryPrime.Wire.create/3`.
  - [TreasuryPrime.DepositSweep](TreasuryPrime.DepositSweep.md): Deposit sweep program enrollment — configures an account to automatically
sweep balances above/below target thresholds into a network of partner
banks, typically to extend FDIC insurance coverage beyond the standard
$250,000 per-bank limit (see also `TreasuryPrime.ReserveAccount` and the
Enhanced FDIC Insurance guide).
  - [TreasuryPrime.FedNow](TreasuryPrime.FedNow.md): FedNow instant payments — the Federal Reserve's real-time gross
settlement service. Supports both sending and receiving, 24/7/365, with
funds available within seconds. Unlike ACH and wire, FedNow payments are
irrevocable the moment they're sent and are not subject to banking-hours
cutoffs. Availability depends on your bank partner's FedNow
participation.
  - [TreasuryPrime.Greendot](TreasuryPrime.Greendot.md): Green Dot cash loads ("Prime Cash") — let your customers add cash to
their account at 90,000+ retail locations (Walmart, CVS, Walgreens, ...).
Your application generates a barcode for the customer to present at the
register; once the retailer accepts the cash, the load completes and
funds post to the account.
  - [TreasuryPrime.IncomingAch](TreasuryPrime.IncomingAch.md): Read-only visibility into ACH transfers originated by a *third party*
outside of Treasury Prime (the reverse of `TreasuryPrime.Ach`, which is
for transfers *you* originate).
  - [TreasuryPrime.IncomingWire](TreasuryPrime.IncomingWire.md): Read-only visibility into wires sent to you by a third party (the reverse
of `TreasuryPrime.Wire`, which is for wires you send). Funds from an
incoming wire post as a `TreasuryPrime.Transaction` on the recipient's
account. This resource is read-only — there's no way to create, update,
or return an incoming wire via the API (wires are irrevocable once sent).

  - [TreasuryPrime.InvoiceAccountNumber](TreasuryPrime.InvoiceAccountNumber.md): An invoice/virtual account number — an additional account number that
routes deposits into an existing `TreasuryPrime.Account`, without being a
separate ledger account itself. Useful for giving each customer/invoice
its own receiving account number so incoming ACH/wire credits can be
automatically reconciled to the right invoice or sub-customer, while all
the money ultimately lands in one underlying account.
  - [TreasuryPrime.ManualHold](TreasuryPrime.ManualHold.md): Manual holds place a temporary hold on funds in an account — reducing its
`available_balance` (but not `current_balance`) by `amount` until the
hold is released or it expires. Commonly used to reserve funds for a
pending obligation (e.g. a check that hasn't cleared yet, a disputed
transaction under investigation) without actually moving money.
  - [TreasuryPrime.NetworkTransfer](TreasuryPrime.NetworkTransfer.md): Network transfers move funds between two accounts you're authorized on,
whether they sit at the same bank or at different banks within your
Treasury Prime OneKey banking network — settling in near real time. They
are Treasury Prime's answer to "book transfer, but the two accounts don't
have to share a bank." Setting this up typically requires coordinating
reserve/settlement accounts with Treasury Prime and your bank partners.
  - [TreasuryPrime.Wire](TreasuryPrime.Wire.md): Outgoing domestic and international wire transfers. For wires sent to
you, see `TreasuryPrime.IncomingWire`.

- Cards
  - [TreasuryPrime.Card](TreasuryPrime.Card.md): Debit card issuance and lifecycle management (virtual and physical),
powered by Treasury Prime's card processor partnership (Marqeta).
  - [TreasuryPrime.CardAuthLoopEndpoint](TreasuryPrime.CardAuthLoopEndpoint.md): Registers a webhook-like HTTP endpoint that Treasury Prime calls
synchronously, in real time, for *every* authorization on a
`TreasuryPrime.CardProduct` that references it (via the card product's
`card_auth_loop_endpoint_id`) — letting you accept or reject each card
transaction yourself (e.g. for velocity limits, custom fraud rules, or
balance checks beyond what `card_controls` supports).
  - [TreasuryPrime.CardEvent](TreasuryPrime.CardEvent.md): Read-only log of every card network event — authorization requests,
authorization holds, captures/clearings, reversals, and declines (with a
decline reason). Each transaction's full lifecycle on the card network is
visible here, complementing the higher-level `TreasuryPrime.Transaction`
record on the account ledger.
  - [TreasuryPrime.CardProduct](TreasuryPrime.CardProduct.md): Card products are bank/processor-configured templates that
`TreasuryPrime.Card`s are issued under (network, BIN range, default
controls, the `card_auth_loop_endpoint_id` used for real-time
authorization decisions, etc.). Configured by your bank partner — this
resource lets you list/inspect them and update a small set of
fields (such as `card_auth_loop_endpoint_id`); there's no `create/2`.

  - [TreasuryPrime.DigitalWalletToken](TreasuryPrime.DigitalWalletToken.md): Represents a card provisioned into a mobile digital wallet (Apple Pay /
Google Pay) — called a "Token" in the Treasury Prime API reference, and
reachable at the `digital_wallet_token` path.
  - [TreasuryPrime.Marqeta.JS](TreasuryPrime.Marqeta.JS.md): Helper for the client access token step of Marqeta.js — the widget that
lets you display a Marqeta-issued virtual card's PAN/CVV directly to a
cardholder via secure iframes, without that data ever touching your
servers (reducing your PCI compliance scope).
  - [TreasuryPrime.Marqeta.UXToolkit](TreasuryPrime.Marqeta.UXToolkit.md): Helper for obtaining the single-use access token Marqeta's embedded
widgets (UX Toolkit, Activate Card, Set PIN, ...) need before they can be
instantiated on a page.

- Utilities
  - [TreasuryPrime.Document](TreasuryPrime.Document.md): Associates an uploaded `TreasuryPrime.File` with a person, business, or
account application as supporting documentation (e.g. a government ID,
articles of incorporation, or a proof-of-address letter) — typically
used to satisfy a manual KYC/KYB review request.
  - [TreasuryPrime.File](TreasuryPrime.File.md): Raw file storage, used as the building block for check deposit images
(`TreasuryPrime.CheckDeposit`) and supporting KYC/KYB documentation
(`TreasuryPrime.Document`).
  - [TreasuryPrime.RoutingNumber](TreasuryPrime.RoutingNumber.md): Look up information about a bank by ABA routing number — useful for
validating a routing number before creating a `TreasuryPrime.Counterparty`,
or for displaying the receiving bank's name in your UI.

  - [TreasuryPrime.Webhook](TreasuryPrime.Webhook.md): Registers a URL to be notified whenever a given `event` fires. See
`TreasuryPrime.WebhookEvent` for the shape of what gets POSTed to your
`url`, and `TreasuryPrime.WebhookSignature` for verifying authenticity.
  - [TreasuryPrime.WebhookEvent](TreasuryPrime.WebhookEvent.md): Represents the body of an incoming webhook notification from Treasury
Prime.
  - [TreasuryPrime.WebhookSignature](TreasuryPrime.WebhookSignature.md): Validates that an incoming webhook request genuinely originated from
Treasury Prime.

- Testing
  - [TreasuryPrime.Testing.Simulation](TreasuryPrime.Testing.Simulation.md): Drives Treasury Prime's **sandbox-only** simulation endpoint, which lets
you force state transitions and synthetic events that would otherwise
require waiting on a real bank/network partner — e.g. moving an ACH
straight to `"settled"`, simulating a card authorization request,
triggering a FedNow receipt, or completing a Green Dot cash load.

