ClearBank.EmbeddedBanking.Accounts (ClearBank v1.0.0)

Copy Markdown View Source

Embedded Banking account management — hub, payment, and savings accounts for your embedded customers.

Account types

  • Hub accounts — internal pooled accounts you use to aggregate and manage funds
  • Payment accounts — FSCS-protected current/payment accounts for end customers
  • Savings accounts — interest-bearing accounts for end customers

Examples

# Create a payment account for a retail customer
{:ok, acct} = ClearBank.EmbeddedBanking.Accounts.create_payment_account(client, %{
  customer_id: "cust-uuid",
  account_name: "Alice's Current Account"
})

# Create a savings account
{:ok, savings} = ClearBank.EmbeddedBanking.Accounts.create_savings_account(client, %{
  customer_id: "cust-uuid",
  account_name: "Alice's Savings"
})

Summary

Functions

Closes an embedded account.

Creates a hub account (internal pooled operational account).

Creates a payment account for an embedded customer.

Creates a savings account for an embedded customer.

Returns an embedded account by ID.

Returns all embedded accounts for a customer.

Returns all transactions for an embedded account.

Sends a Faster Payment from an embedded customer's payment account.

Updates an embedded account (e.g. rename, change status).

Functions

close(client, account_id)

Closes an embedded account.

Sets account status to "Closed". Ensure the balance is zero before closing.

Examples

{:ok, _} = ClearBank.EmbeddedBanking.Accounts.close(client, "acct-uuid")

create_hub_account(client, params)

@spec create_hub_account(ClearBank.Client.t(), map()) :: ClearBank.HTTP.result()

Creates a hub account (internal pooled operational account).

Required params

  • :account_name - display name for the hub account

Optional params

  • :owner - your internal owner reference
  • :currency - ISO 4217 (default: "GBP")

create_payment_account(client, params)

@spec create_payment_account(ClearBank.Client.t(), map()) :: ClearBank.HTTP.result()

Creates a payment account for an embedded customer.

Required params

  • :customer_id - UUID of the customer (retail, sole trader, or legal entity)
  • :account_name - display name

Optional params

  • :currency - ISO 4217 (default: "GBP")
  • :external_account_id - your internal account reference

create_savings_account(client, params)

@spec create_savings_account(ClearBank.Client.t(), map()) :: ClearBank.HTTP.result()

Creates a savings account for an embedded customer.

Required params

  • :customer_id - UUID of the customer
  • :account_name - display name

Optional params

get(client, account_id)

Returns an embedded account by ID.

list(client, customer_id, opts \\ [])

Returns all embedded accounts for a customer.

Options

  • :page_number, :page_size
  • :account_type - filter by type: "Payment" | "Savings" | "CashIsa"

Examples

{:ok, accounts} = ClearBank.EmbeddedBanking.Accounts.list(client, "cust-uuid")

list_transactions(client, account_id, opts \\ [])

@spec list_transactions(ClearBank.Client.t(), String.t(), keyword()) ::
  ClearBank.HTTP.result()

Returns all transactions for an embedded account.

Options

  • :page_number, :page_size, :start_date, :end_date

Examples

{:ok, txns} = ClearBank.EmbeddedBanking.Accounts.list_transactions(client, "acct-uuid")

send_payment(client, params)

@spec send_payment(ClearBank.Client.t(), map()) :: ClearBank.HTTP.result()

Sends a Faster Payment from an embedded customer's payment account.

This routes the payment through FPS on behalf of the embedded customer. CoP and APP scam rules apply.

Required params

  • :account_id - embedded payment account UUID (source)
  • :amount - decimal string
  • :currency - "GBP"
  • :destination_sort_code - 6-digit sort code
  • :destination_account_number - 8-digit account number
  • :destination_account_name - payee name

Optional params

  • :reference - payment reference (max 35 chars)
  • :end_to_end_id - your end-to-end reference

Examples

{:ok, _} = ClearBank.EmbeddedBanking.Accounts.send_payment(client, %{
  account_id: "embedded-acct-uuid",
  amount: "50.00",
  currency: "GBP",
  destination_sort_code: "040004",
  destination_account_number: "12345678",
  destination_account_name: "Bob",
  reference: "Rent"
})

update(client, account_id, params)

Updates an embedded account (e.g. rename, change status).

Optional params

  • :account_name - new display name
  • :status - "Active" | "Suspended" | "Closed"

Examples

{:ok, _} = ClearBank.EmbeddedBanking.Accounts.update(client, "acct-uuid",
  account_name: "Alice's Renamed Account"
)