Elixir client for the Lithic API.
Installation
Add to your mix.exs:
{:lithic, "~> 1.0"}Configuration
# config/config.exs
config :lithic,
api_key: System.get_env("LITHIC_API_KEY"),
environment: :production # or :sandboxQuick Start
# Cards
{:ok, card} = Lithic.Cards.create(%{type: "VIRTUAL"})
{:ok, page} = Lithic.Cards.list(page_size: 25)
Lithic.Cards.stream() |> Enum.take(50)
# Payments
{:ok, payment} = Lithic.Payments.create(%{
financial_account_token: "fa_token",
external_bank_account_token: "eba_token",
amount: 5000,
direction: "DEBIT",
method: "ACH_NEXT_DAY",
method_attributes: %{sec_code: "PPD"},
type: "PAYMENT"
})
# Per-request client override
client = Lithic.Client.new(api_key: "other_key", environment: :sandbox)
{:ok, card} = Lithic.Cards.create(%{type: "VIRTUAL"}, client: client)Pagination
# Cursor-based page
{:ok, page} = Lithic.Cards.list()
page.has_more #=> true
{:ok, next} = Lithic.Page.next(page)
# Lazy stream
Lithic.Transactions.stream(card_token: "tok_...")
|> Stream.filter(&(&1["result"] == "APPROVED"))
|> Enum.take(100)
# Collect all (use carefully on large datasets)
{:ok, all} = Lithic.Cards.list() |> then(fn {:ok, p} -> Lithic.Page.collect_all(p) end)Webhooks
# In your Plug/Phoenix controller:
Lithic.Webhook.verify(raw_body, signature_header, timestamp_header, secret: "whsec_...")Telemetry
All requests emit:
[:lithic, :request_start]— before the request[:lithic, :request_stop]— after success, includes:duration[:lithic, :request_exception]— on error, includes:error
Resources
| Module | Description |
|---|---|
| Lithic.Cards | Card lifecycle, balances, provisioning |
| Lithic.Accounts | Account management and spend limits |
| Lithic.AccountHolders | KYC/KYB verification |
| Lithic.AuthRules | V2 authorization rules engine |
| Lithic.AuthStreamAccess | Real-time ASA webhook |
| Lithic.Transactions | Card transactions and sandbox simulation |
| Lithic.Payments | ACH payments |
| Lithic.BookTransfers | Internal fund transfers |
| Lithic.ExternalBankAccounts | ACH counterparty accounts |
| Lithic.ExternalPayments | External payment lifecycle |
| Lithic.FinancialAccounts | Ledger, balances, credit config |
| Lithic.Balances | Balance queries |
| Lithic.Holds | Financial holds |
| Lithic.ManagementOperations | Manual ledger adjustments |
| Lithic.CardBulkOrders | Bulk physical card orders |
| Lithic.ThreeDS | 3DS authentication and decisioning |
| Lithic.Tokenization | Digital wallet tokenization |
| Lithic.Events | Webhooks and event subscriptions |
| Lithic.Chargebacks | Chargeback/dispute (legacy) |
| Lithic.Disputes | Disputes V2 |
| Lithic.FraudReports | Fraud report management |
| Lithic.Credit | Credit products, statements, loan tapes |
| Lithic.Settlement | Settlement summaries |
| Lithic.Network | Network programs and totals |
| Lithic.FundingEvents | Program-level funding |
| Lithic.TransactionMonitoring | Cases and queues |
Summary
Functions
Check API connectivity. Returns {:ok, %{"status" => "OK"}} on success.
Functions
@spec status(keyword()) :: {:ok, map()} | {:error, Lithic.Error.t()}
Check API connectivity. Returns {:ok, %{"status" => "OK"}} on success.