Counterparties: the people and businesses you pay or collect from, with their external accounts. Counterparty bodies can carry bank account and routing numbers and tax ids: don't log them.

Functions

collect-account-details

fn (counterparty-id: Str, direction: Str): Map
fn (counterparty-id: Str, direction: Str, params: Map, opts: Map): Map

POST /api/counterparties/{id}/collect_account: ask the counterparty to enter their own bank details through a Modern Treasury form, so the numbers never pass through you. direction is "credit" (you will pay them) or "debit" (you will pull from them). params: send_email (default true), fields, custom_redirect. Returns {id, form_link, is_resend}.

Example

request ::modern-treasury::counterparties/collect-account-details("b7d3a9c2-6f41-4e0a-8a55-1c9e0f2d7b31", "credit")
request.form_link

// No email: hand out the link yourself
::modern-treasury::counterparties/collect-account-details("b7d3a9c2-6f41-4e0a-8a55-1c9e0f2d7b31", "credit", {send_email: false}, {})

create-counterparty

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

POST /api/counterparties: create a counterparty, optionally with its bank accounts. params needs name; optional email, external_id, metadata, send_remittance_advice, legal_entity_id or legal_entity, taxpayer_identifier, and accounts: [{account_type, party_name, party_type, account_details: [{account_number, account_number_type}], routing_details: [{routing_number, routing_number_type, payment_type}]}].

Example

::modern-treasury::counterparties/create-counterparty({
  name: "Kubernetes Supply Co",
  email: "ap@example.com",
  accounts: [{
    account_type: "checking",
    party_name: "Kubernetes Supply Co",
    account_details: [{account_number: "123456789"}],
    routing_details: [{routing_number: "021000021", routing_number_type: "aba"}]
  }]
}, {idempotency-key: "vendor-17"})

delete-counterparty

fn (counterparty-id: Str): Any
fn (counterparty-id: Str, opts: Map): Any

DELETE /api/counterparties/{id}: delete a counterparty. Returns null (204). Irreversible.

Example

::modern-treasury::counterparties/delete-counterparty("b7d3a9c2-6f41-4e0a-8a55-1c9e0f2d7b31")

get-counterparty

fn (counterparty-id: Str): Map
fn (counterparty-id: Str, opts: Map): Map

GET /api/counterparties/{id}: retrieve a counterparty with its accounts.

Example

party ::modern-treasury::counterparties/get-counterparty("b7d3a9c2-6f41-4e0a-8a55-1c9e0f2d7b31")
party.name

list-counterparties

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

GET /api/counterparties: one page ({items, after_cursor, per_page}). Filters: name, email, external_id, legal_entity_id, metadata: {key: value}, created_at_lower_bound, created_at_upper_bound, per_page, after_cursor.

Example

page ::modern-treasury::counterparties/list-counterparties({metadata: {vendor_id: "17"}, per_page: 50})
map(page.items, %.name)

update-counterparty

fn (counterparty-id: Str, params: Map): Map
fn (counterparty-id: Str, params: Map, opts: Map): Map

PATCH /api/counterparties/{id}: change name, email, external_id, metadata, send_remittance_advice, legal_entity_id or taxpayer_identifier.

Example

::modern-treasury::counterparties/update-counterparty("b7d3a9c2-6f41-4e0a-8a55-1c9e0f2d7b31", {email: "billing::modern-treasury::example.com"})