Xero.BankFeeds (Xero v1.0.0)

Copy Markdown View Source

Xero Bank Feeds API – Push bank statement data into Xero for auto-reconciliation. Base URL: https://api.xero.com/bankfeeds.xro/1.0/ Scope: bankfeeds

⚠️ Requires Xero Bank Feeds partner programme approval before use. Contact Xero to apply: https://developer.xero.com/documentation/bank-feeds-api/overview/

Workflow

  1. Create a feed connection for each bank account
  2. Push statement lines to the connection periodically
  3. Xero auto-matches and reconciles transactions

Statement Line Fields

FieldRequiredDescription
postedDateTransaction date (YYYY-MM-DD)
descriptionTransaction description
amountDecimal amount (always positive)
creditDebitIndicator"CREDIT" or "DEBIT"
transactionIdYour unique ID (strongly recommended for idempotency)
payeeNameMerchant or payee name
referenceYour reference
chequeNumberCheque number
subTypeTransaction sub-type (for categorisation)

Examples

{:ok, conn} = Xero.BankFeeds.create_feed_connection(token, tenant_id, %{
  "accountToken"  => "my-unique-token",
  "accountType"   => "BANK",
  "accountName"   => "Business Cheque",
  "accountNumber" => "123456789",
  "currency"      => "AUD"
})

{:ok, _} = Xero.BankFeeds.create_statements(token, tenant_id, %{
  "feedConnectionId" => conn_id,
  "startDate"        => "2024-01-01",
  "endDate"          => "2024-01-31",
  "startBalance"     => %{"amount" => "1000.00", "creditDebitIndicator" => "CREDIT"},
  "endBalance"       => %{"amount" => "1500.00", "creditDebitIndicator" => "CREDIT"},
  "statementLines"   => [
    %{
      "postedDate"           => "2024-01-15",
      "description"          => "Client Payment",
      "amount"               => "5000.00",
      "creditDebitIndicator" => "CREDIT",
      "transactionId"        => "TXN-2024-001"
    }
  ]
})

Summary

Functions

Creates one or more feed connections (pass a single map or a list).

Pushes one or more bank statements into Xero (pass a single map or a list).

Deletes feed connections by their IDs. Uses the DeleteRequests endpoint (POST, not DELETE).

Deletes a statement by ID. Note: Only statements that have not yet been reconciled can be deleted.

Retrieves a single feed connection by ID.

Retrieves a single statement by ID.

Lists all feed connections. Options: :page, :page_size

Lists statements. Options: :feed_connection_id, :page, :page_size

Functions

create_feed_connection(t, tid, conn_or_conns)

@spec create_feed_connection(Xero.Auth.Token.t(), String.t(), map() | [map()]) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Creates one or more feed connections (pass a single map or a list).

Required fields per connection

  • "accountToken" — Your unique identifier for this bank account (max 50 chars)
  • "accountType""BANK" or "CREDITCARD"
  • "accountName" — Display name in Xero (max 30 chars)
  • "accountNumber" — Bank account number (max 12 chars)
  • "currency" — ISO 4217 currency code (e.g. "AUD", "GBP")

Region-specific required fields

  • UK: "sortCode" (format "12-34-56")
  • AU: "bsb" (format "123456")

create_statements(t, tid, stmt_or_stmts)

@spec create_statements(Xero.Auth.Token.t(), String.t(), map() | [map()]) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Pushes one or more bank statements into Xero (pass a single map or a list).

Each statement represents one bank account period and must include:

  • "feedConnectionId" — UUID of the feed connection
  • "startDate" / "endDate" — Statement period (YYYY-MM-DD)
  • "startBalance" / "endBalance" — Balance maps with amount and creditDebitIndicator
  • "statementLines" — List of transaction maps

Use transactionId in each statement line for idempotency — Xero will reject duplicate transactionId values for the same feed connection.

delete_feed_connections(t, tid, ids)

@spec delete_feed_connections(Xero.Auth.Token.t(), String.t(), [String.t()]) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Deletes feed connections by their IDs. Uses the DeleteRequests endpoint (POST, not DELETE).

delete_statement(t, tid, id)

@spec delete_statement(Xero.Auth.Token.t(), String.t(), String.t()) ::
  :ok | {:error, Xero.Error.t()}

Deletes a statement by ID. Note: Only statements that have not yet been reconciled can be deleted.

get_feed_connection(t, tid, id)

@spec get_feed_connection(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Retrieves a single feed connection by ID.

get_statement(t, tid, id)

@spec get_statement(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Retrieves a single statement by ID.

list_feed_connections(t, tid, opts \\ [])

@spec list_feed_connections(Xero.Auth.Token.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Lists all feed connections. Options: :page, :page_size

list_statements(t, tid, opts \\ [])

@spec list_statements(Xero.Auth.Token.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Lists statements. Options: :feed_connection_id, :page, :page_size