DEV Community

viraj geeth
viraj geeth

Posted on Originally published at allratestoday.com

Booking Xero Invoices at the Official Central Bank Rate (Xero Won't Let You Replace Its Feed, Here's the Workaround)

Every few weeks someone asks how to make Xero use the Bank of England, ECB or RBI rate instead of the rate it downloads. The short answer: you cannot replace Xero's organisation-level feed. It comes from XE.com once multicurrency is enabled and there is no endpoint to change it.

What Xero does allow, in the UI and in the Accounting API, is a rate on each transaction. Invoices, bills, credit notes, bank transactions and manual journals all carry a CurrencyRate. A compliant workflow sets that field at creation time from the official table for the document date. The full guide is on AllRatesToday: Xero integration.

The rate Xero expects

CurrencyRate is document-currency units per 1 unit of the organisation base currency. For a GBP organisation raising a EUR invoice you need EUR per GBP. Ask the API for exactly that pair and let it handle inversion or crossing:

GET https://allratestoday.com/api/v1/central-bank/boe/latest?source=GBP&target=EUR
Authorization: Bearer art_live_your_key

{
  "bank": "boe",
  "rate_date": "2026-10-08",
  "source": "GBP",
  "target": "EUR",
  "rate": 1.18,
  "derived": false,
  "method": "published"
}
Enter fullscreen mode Exit fullscreen mode

When the invoice is not dated today, use the dated endpoint /api/v1/central-bank/{bank}/{YYYY-MM-DD}. If the bank did not publish that day you get the prior table and published_on_requested_date: false, which is the rate in force and the one to apply.

Create the invoice with the official rate

Python with the xero-python SDK, after the usual OAuth 2.0 connection:

import requests
from xero_python.accounting import AccountingApi, Invoice, LineItem

BANK = "boe"                      # the publisher your rule names
BASE = "GBP"                      # Xero organisation base currency

def official_rate(target, on_date):
    url = f"https://allratestoday.com/api/v1/central-bank/{BANK}/{on_date}"
    r = requests.get(url, params={"source": BASE, "target": target},
                     headers={"Authorization": "Bearer art_live_your_key"}, timeout=10)
    r.raise_for_status()
    body = r.json()
    return body["rate"], body["rate_date"], body["derived"]

rate, rate_date, derived = official_rate("EUR", "2026-10-09")

invoice = Invoice(
    type="ACCREC",
    contact={"ContactID": contact_id},
    date="2026-10-09",
    due_date="2026-11-08",
    currency_code="EUR",
    currency_rate=rate,                          # EUR per 1 GBP, from the Bank of England table
    reference=f"BoE {rate_date}{' (derived)' if derived else ''}",
    line_items=[LineItem(description="Consulting", quantity=1, unit_amount=1000, account_code="200")],
)
AccountingApi(api_client).create_invoices(xero_tenant_id, invoices={"Invoices": [invoice]})
Enter fullscreen mode Exit fullscreen mode

Writing the bank and rate_date into the reference, or a tracking category, keeps the source of the rate on the document for the auditor. The same field exists on BankTransactions, CreditNotes and ManualJournals.

Month-end revaluation

Xero's unrealised gains report uses its own closing rate. If your statutory close must use the central bank's month-end table, pull it once with /api/v1/central-bank/{bank}/{last-business-day} and post the revaluation as a manual journal at those rates. ?format=xlsx on the same endpoint gives the table as a spreadsheet if the close is done in Excel.

Notes

  • One API call per pair per date. A monthly batch of 200 invoices across five currencies is at most 5 calls a day if you cache per date.
  • Xero rounds CurrencyRate to six decimal places; official tables are published to four or five, so nothing is lost.
  • UK VAT uses HMRC's monthly table, which is a separate source on the same API.

Links

Rates are redistributed from each institution's public publication. They are reference rates for accounting, tax and compliance, not dealing quotes.

Top comments (0)