External accounts: counterparties' bank accounts, with micro-deposit verification (verify-external-account, then complete-verification with the amounts the counterparty sees) and a routing-number lookup. Create bodies carry account and routing numbers: don't log them.

Functions

complete-verification

fn (external-account-id: Str, amounts: Vec<Int>): Map
fn (external-account-id: Str, amounts: Vec<Int>, opts: Map): Map

POST /api/external_accounts/{id}/complete_verification: finish micro-deposit verification with the two amounts (in cents) the counterparty saw, e.g. [2, 4].

Example

account ::modern-treasury::external-accounts/complete-verification("5acec2ef-987b-4260-aa97-b719eeb0a8d5", [2, 4])
account.verification_status

create-external-account

fn (params: Map): Map
fn (params: Map, opts: Map): Map

POST /api/external_accounts: add a bank account to a counterparty. params needs counterparty_id; usually account_details: [{account_number}], routing_details: [{routing_number, routing_number_type}], account_type, party_name, party_type; optional name, metadata, party_address, plaid_processor_token, ledger_account.

Example

account ::modern-treasury::external-accounts/create-external-account({
  counterparty_id: "b7d3a9c2-6f41-4e0a-8a55-1c9e0f2d7b31",
  account_type: "checking",
  party_name: "Acme",
  account_details: [{account_number: "123456789"}],
  routing_details: [{routing_number: "021000021", routing_number_type: "aba"}]
})
account.id

delete-external-account

fn (external-account-id: Str): Any
fn (external-account-id: Str, opts: Map): Any

DELETE /api/external_accounts/{id}: delete an external account. Returns null (204).

Example

::modern-treasury::external-accounts/delete-external-account("5acec2ef-987b-4260-aa97-b719eeb0a8d5")

get-external-account

fn (external-account-id: Str): Map
fn (external-account-id: Str, opts: Map): Map

GET /api/external_accounts/{id}: retrieve an external account (its verification_status among the fields).

Example

account ::modern-treasury::external-accounts/get-external-account("5acec2ef-987b-4260-aa97-b719eeb0a8d5")
account.verification_status

list-external-accounts

fn (): Map
fn (params: Map): Map
fn (params: Map, opts: Map): Map

GET /api/external_accounts: one page. Filters: counterparty_id, party_name, external_id, metadata, per_page, after_cursor.

Example

page ::modern-treasury::external-accounts/list-external-accounts({counterparty_id: "b7d3a9c2-6f41-4e0a-8a55-1c9e0f2d7b31"})
map(page.items, %.id)

update-external-account

fn (external-account-id: Str, params: Map): Map
fn (external-account-id: Str, params: Map, opts: Map): Map

PATCH /api/external_accounts/{id}: change name, party_name, party_type, party_address, account_type, counterparty_id or metadata. Account and routing numbers can't be changed; create a new external account instead.

Example

::modern-treasury::external-accounts/update-external-account("5acec2ef-987b-4260-aa97-b719eeb0a8d5", {name: "Acme operating"})

validate-routing-number

fn (routing-number: Str, routing-number-type: Str): Map
fn (routing-number: Str, routing-number-type: Str, opts: Map): Map

GET /api/validations/routing_numbers: look up a routing number (routing-number-type e.g. "aba", "swift"), returning the bank name, address and supported payment types, or a 422 HttpError when it is invalid.

Example

bank ::modern-treasury::external-accounts/validate-routing-number("021000021", "aba")
bank.bank_name

verify-external-account

fn (external-account-id: Str, params: Map, opts: Map): Map

POST /api/external_accounts/{id}/verify: start micro-deposit verification. params needs originating_account_id (the internal account that sends the deposits) and payment_type (e.g. "ach", "rtp"); optional currency, priority, fallback_type. This sends small deposits from your account, so it needs an idempotency-key.

Example

::modern-treasury::external-accounts/verify-external-account("5acec2ef-987b-4260-aa97-b719eeb0a8d5", {
  originating_account_id: "0f8e3719-3dfd-4613-9bbf-c0333781b59f",
  payment_type: "ach"
}, {idempotency-key: "verify-acme-operating"})