The Mercury Accounts API — bank accounts, cards, statements, and sending money from an account.
Summary
Functions
Downloads a statement PDF, returning the raw bytes. GET /statements/{id}/pdf
Returns a single account by ID. GET /account/{id}
Same as get/2 but raises on error.
Returns one page of accounts. GET /accounts
Same as list/2 but raises on error.
Returns every card issued on an account. GET /account/{id}/cards
Returns one page of statements for an account. GET /account/{id}/statements
Returns one page of transactions for an account. GET /account/{id}/transactions
Sends money from an account to a recipient. attrs accepts snake_case
keys, e.g.
A lazy, auto-paginating stream of every account.
A lazy, auto-paginating stream of every statement for an account.
A lazy, auto-paginating stream of every transaction for an account.
Functions
@spec download_statement(client :: Mercury.Client.t(), statement_id :: String.t()) :: {:ok, binary()} | {:error, Exception.t()}
Downloads a statement PDF, returning the raw bytes. GET /statements/{id}/pdf
@spec download_statement!(client :: Mercury.Client.t(), statement_id :: String.t()) :: binary()
@spec get(client :: Mercury.Client.t(), account_id :: String.t()) :: {:ok, Mercury.Account.t()} | {:error, Exception.t()}
Returns a single account by ID. GET /account/{id}
@spec get!(client :: Mercury.Client.t(), account_id :: String.t()) :: Mercury.Account.t()
Same as get/2 but raises on error.
@spec list(client :: Mercury.Client.t(), opts :: keyword()) :: {:ok, Mercury.Page.t(Mercury.Account.t())} | {:error, Exception.t()}
Returns one page of accounts. GET /accounts
Accepts the common list options: :limit, :order (:asc | :desc),
:start_after, :end_before.
@spec list!(client :: Mercury.Client.t(), opts :: keyword()) :: Mercury.Page.t(Mercury.Account.t())
Same as list/2 but raises on error.
@spec list_cards(client :: Mercury.Client.t(), account_id :: String.t()) :: {:ok, [Mercury.Card.t()]} | {:error, Exception.t()}
Returns every card issued on an account. GET /account/{id}/cards
@spec list_cards!(client :: Mercury.Client.t(), account_id :: String.t()) :: [ Mercury.Card.t() ]
@spec list_statements( client :: Mercury.Client.t(), account_id :: String.t(), opts :: keyword() ) :: {:ok, Mercury.Page.t(Mercury.AccountStatement.t())} | {:error, Exception.t()}
Returns one page of statements for an account. GET /account/{id}/statements
@spec list_statements!( client :: Mercury.Client.t(), account_id :: String.t(), opts :: keyword() ) :: Mercury.Page.t(Mercury.AccountStatement.t())
@spec list_transactions( client :: Mercury.Client.t(), account_id :: String.t(), opts :: keyword() ) :: {:ok, Mercury.Page.t(Mercury.Transaction.t())} | {:error, Exception.t()}
Returns one page of transactions for an account. GET /account/{id}/transactions
@spec list_transactions!( client :: Mercury.Client.t(), account_id :: String.t(), opts :: keyword() ) :: Mercury.Page.t(Mercury.Transaction.t())
@spec send_money( client :: Mercury.Client.t(), account_id :: String.t(), attrs :: map() | keyword() ) :: {:ok, Mercury.Transaction.t()} | {:error, Exception.t()}
Sends money from an account to a recipient. attrs accepts snake_case
keys, e.g.:
Mercury.Accounts.send_money(client, account_id, %{
recipient_id: recipient_id,
amount: 100.00,
payment_method: :ach,
idempotency_key: idempotency_key
})POST /account/{id}/transactions
@spec send_money!( client :: Mercury.Client.t(), account_id :: String.t(), attrs :: map() | keyword() ) :: Mercury.Transaction.t()
@spec stream(client :: Mercury.Client.t(), opts :: keyword()) :: Enumerable.t()
A lazy, auto-paginating stream of every account.
@spec stream_statements( client :: Mercury.Client.t(), account_id :: String.t(), opts :: keyword() ) :: Enumerable.t()
A lazy, auto-paginating stream of every statement for an account.
@spec stream_transactions( client :: Mercury.Client.t(), account_id :: String.t(), opts :: keyword() ) :: Enumerable.t()
A lazy, auto-paginating stream of every transaction for an account.