Unit — Production-grade Elixir client for the Unit embedded banking API.

Overview

Full Unit API coverage across all 24 resource domains:

DomainModule
Applications (KYC/KYB)Unit.API.Applications
CustomersUnit.API.Customers
AccountsUnit.API.Accounts
CardsUnit.API.Cards
AuthorizationsUnit.API.Authorizations
PaymentsUnit.API.Payments
Recurring PaymentsUnit.API.RecurringPayments
TransactionsUnit.API.Transactions
CounterpartiesUnit.API.Counterparties
RepaymentsUnit.API.Repayments
Recurring RepaymentsUnit.API.RecurringRepayments
Check DepositsUnit.API.CheckDeposits
Check PaymentsUnit.API.CheckPayments
Stop PaymentsUnit.API.StopPayments
ChargebacksUnit.API.Chargebacks
DisputesUnit.API.Disputes
RewardsUnit.API.Rewards
FeesUnit.API.Fees
StatementsUnit.API.Statements
Tax FormsUnit.API.TaxForms
WebhooksUnit.API.Webhooks
EventsUnit.API.Events
TokensUnit.API.Tokens
InstitutionsUnit.API.Institutions
ATM LocationsUnit.API.AtmLocations
Account End-of-DayUnit.API.AccountEndOfDay
Account Limit OverridesUnit.API.AccountLimitOverrides
SandboxUnit.API.Sandbox

Configuration

# config/runtime.exs
config :unit,
  api_token: System.get_env("UNIT_API_TOKEN"),
  environment: :sandbox   # :sandbox | :production

Quick start

# 1. Onboard an individual customer
{:ok, app} = Unit.API.Applications.create_individual(%{
  full_name: %{first: "Jane", last: "Doe"},
  ssn: "000000002",
  date_of_birth: ~D[1990-01-15],
  address: %{street: "123 Main St", city: "SF", state: "CA",
             postal_code: "94105", country: "US"},
  email: "jane@example.com",
  phone: %{country_code: "1", number: "5555550100"},
  ip: "127.0.0.1"
})

# 2. Open accounts
{:ok, account} = Unit.API.Accounts.create_deposit(app.customer_id, "checking")
{:ok, credit}  = Unit.API.Accounts.create_credit(app.customer_id, "basic-credit")

# 3. Issue a virtual debit card
{:ok, card} = Unit.API.Cards.create_individual_virtual_debit(%{
  customer_id: app.customer_id,
  account_id: account.id
})

# 4. Send money
{:ok, payment} = Unit.API.Payments.create_ach(%{
  account_id: account.id,
  amount: 10_000,
  direction: "Credit",
  description: "Payroll",
  counterparty: %{routing_number: "812345678",
                  account_number: "1000000002",
                  account_type: "Checking", name: "Jane Doe"}
})

# 5. Set up recurring payments
{:ok, _} = Unit.API.RecurringPayments.create_credit_ach(%{
  account_id: account.id,
  amount: 5_000,
  description: "Monthly savings transfer",
  counterparty_id: counterparty.id,
  schedule: %{interval: "Monthly", day_of_month: 1,
              start_time: ~D[2024-02-01]}
})

# 6. Reward the customer
{:ok, _} = Unit.API.Rewards.create(%{
  amount: 500,
  description: "Sign-up bonus",
  receiving_account_id: account.id,
  funding_account_id: revenue_account_id
})

Error handling

All functions return {:ok, result} or {:error, %Unit.Error{}}:

case Unit.API.Payments.create_ach(params) do
  {:ok, payment} ->
    Logger.info("Payment created: #{payment.id}")
  {:error, %Unit.Error{type: :validation_error, errors: errors}} ->
    Logger.warning("Validation: #{inspect(errors)}")
  {:error, %Unit.Error{type: :auth_error}} ->
    Logger.error("Invalid token")
  {:error, %Unit.Error{type: :network_error}} ->
    Logger.error("Network failure — will retry automatically")
end

Per-request overrides

# Use a customer-scoped token
Unit.API.Accounts.list(api_token: customer_token)

# Point to a custom base URL
Unit.API.Sandbox.receive_ach(params, base_url: "http://localhost:8080")

Telemetry

:telemetry.attach("unit-log", [:unit, :request, :stop],
  fn _evt, %{duration: d}, %{resource: r, action: a, status: s}, _ ->
    Logger.info("[Unit] #{r}.#{a}#{s} (#{div(d, 1_000_000)}ms)")
  end, nil)

Summary

Functions

Functions

cancel_payment(id, opts \\ [])

See Unit.API.Payments.cancel/2.

close_account(id, params, opts \\ [])

See Unit.API.Accounts.close/3.

create_ach_payment(params, opts \\ [])

See Unit.API.Payments.create_ach/2.

create_book_payment(params, opts \\ [])

See Unit.API.Payments.create_book/2.

create_business_application(params, opts \\ [])

See Unit.API.Applications.create_business/2.

create_counterparty(params, opts \\ [])

See Unit.API.Counterparties.create/2.

create_credit_account(customer_id, credit_terms, params \\ [], opts \\ [])

See Unit.API.Accounts.create_credit/4.

create_deposit_account(customer_id, deposit_product, params \\ [], opts \\ [])

See Unit.API.Accounts.create_deposit/4.

create_individual_application(params, opts \\ [])

See Unit.API.Applications.create_individual/2.

create_push_to_card_payment(params, opts \\ [])

See Unit.API.Payments.create_push_to_card/2.

create_recurring_ach(params, opts \\ [])

See Unit.API.RecurringPayments.create_credit_ach/2.

create_reward(params, opts \\ [])

See Unit.API.Rewards.create/2.

create_virtual_debit_card(params, opts \\ [])

See Unit.API.Cards.create_individual_virtual_debit/2.

create_wire_payment(params, opts \\ [])

See Unit.API.Payments.create_wire/2.

freeze_account(id, params \\ [], opts \\ [])

See Unit.API.Accounts.freeze/3.

freeze_card(id, opts \\ [])

See Unit.API.Cards.freeze/2.

get_account(id, opts \\ [])

See Unit.API.Accounts.get/2.

get_application(id, opts \\ [])

See Unit.API.Applications.get/2.

get_authorization(id, opts \\ [])

See Unit.API.Authorizations.get/2.

get_card(id, opts \\ [])

See Unit.API.Cards.get/2.

get_customer(id, opts \\ [])

See Unit.API.Customers.get/2.

get_institution(routing_number, opts \\ [])

See Unit.API.Institutions.get/2.

get_payment(id, opts \\ [])

See Unit.API.Payments.get/2.

get_transaction(account_id, transaction_id, opts \\ [])

See Unit.API.Transactions.get/3.

list_accounts(opts \\ [])

See Unit.API.Accounts.list/1.

list_applications(opts \\ [])

See Unit.API.Applications.list/1.

list_authorizations(opts \\ [])

See Unit.API.Authorizations.list/1.

list_cards(opts \\ [])

See Unit.API.Cards.list/1.

list_counterparties(opts \\ [])

See Unit.API.Counterparties.list/1.

list_customers(opts \\ [])

See Unit.API.Customers.list/1.

list_payments(opts \\ [])

See Unit.API.Payments.list/1.

list_recurring_payments(opts \\ [])

See Unit.API.RecurringPayments.list/1.

list_rewards(opts \\ [])

See Unit.API.Rewards.list/1.

list_transactions(opts \\ [])

See Unit.API.Transactions.list/1.

replace_card(id, params \\ %{}, opts \\ [])

See Unit.API.Cards.replace/3.

unfreeze_account(id, opts \\ [])

See Unit.API.Accounts.unfreeze/2.

unfreeze_card(id, opts \\ [])

See Unit.API.Cards.unfreeze/2.

update_customer(id, params, opts \\ [])

See Unit.API.Customers.update/3.