How to Invoice in a Foreign Currency: Which Exchange Rate to Use and What to Store

7 min read

How to Invoice in a Foreign Currency: Which Exchange Rate to Use and What to Store

If you need to invoice in a foreign currency, the short answer is this: pick one rate at a defined moment, apply it once, and store it with the invoice so the numbers can be reproduced years later. The exact moment (issue date, payment date or a contract-fixed rate) depends on your jurisdiction and your accountant. The engineering rule is the same in every case: never recompute an issued invoice from a rate you fetch today.

Most invoicing bugs in multi-currency systems are not math bugs. They are record-keeping bugs. A customer disputes a total, an auditor asks how a figure in your home currency was derived, and the rate that produced it is gone because the code fetched it on the fly and threw it away.

This guide covers the decisions you have to make, the fields worth persisting, and a small Python example that fetches a rate, snapshots it and rounds the result.

Decide which currency is the invoice currency

An invoice involves up to three currencies, and mixing them up is the root of most confusion:

  • Invoice currency: what the customer sees and pays, for example USD.
  • Functional (booking) currency: what your books are kept in, for example EUR.
  • Payment currency: what actually lands in your bank account, which may differ from both.

If the invoice currency and the booking currency differ, you need one conversion to record the invoice in your books. If the payment arrives in yet another currency, there is a second conversion, and the difference between the two is usually booked as a foreign-exchange gain or loss. That second step is accounting territory. Your software's job is to give accountants the inputs they need.

Which exchange rate should you use?

There are three common approaches. Which one is required or allowed depends on local rules, so confirm with an accountant rather than choosing by convenience.

ApproachWhen the rate is fixedTypical useTrade-off
Rate at issue dateThe moment the invoice is createdMost B2B invoicing and bookkeepingSimple, but the amount received can differ from the booked amount
Rate at payment dateWhen money is receivedCash-based bookkeepingBooked value is unknown until payment
Contractually fixed rateSet in the contract or quoteLong projects, retainersSomeone carries the currency risk for the period

Some tax authorities require an official published rate, such as a central-bank rate, for the booked amount. GetRatesAPI provides live market-derived rates, not bank or central-bank fixing rates, so if your jurisdiction mandates an official fixing, use that source for the booking amount. Live rates remain useful for quotes, previews, dashboards and estimates.

What to store with every foreign-currency invoice

A snapshot should be self-contained. Store at least:

  1. The invoice amount and currency, as a decimal, never a float.
  2. The rate as the exact string you received, for example "1.0842".
  3. The direction: base and quote codes, so nobody has to guess whether it is EUR per USD or USD per EUR.
  4. The rate's as_of timestamp, which is when the market observation was made.
  5. Your own fetched_at timestamp, which is when your system received it.
  6. The status (fresh or stale) and type (direct or derived).
  7. The converted amount in the booking currency, after rounding, and the rounding rule you used.

Why both as_of and fetched_at? They answer different questions. as_of tells you how old the market data was, and fetched_at tells you when you used it. A derived rate's as_of is the oldest of its inputs, so it is a conservative figure.

This also matters because GetRatesAPI serves current rates only. It does not offer historical or time-series lookups, so you cannot go back later and ask what the rate was at 10:00 last Tuesday. Your own database is the historical record. Write the snapshot at the moment you issue the invoice.

Fetch the rate and snapshot it in Python

The example below fetches one rate with the current rate endpoint, refuses to issue an invoice on a stale rate, and uses Decimal throughout. Rates arrive as JSON strings, so no precision is lost on the way in.

import os
from datetime import datetime, timezone
from decimal import Decimal, ROUND_HALF_UP

import requests

API = "https://api.getratesapi.com"
HEADERS = {"Authorization": f"ApiKey {os.environ['GETRATESAPI_KEY']}"}


def fetch_rate(base: str, quote: str) -> dict:
    resp = requests.get(f"{API}/v1/rates/{base}/{quote}", headers=HEADERS, timeout=10)
    if not resp.ok:
        err = resp.json()
        raise RuntimeError(f"rate lookup failed: {err['code']}")
    return resp.json()


def build_invoice_snapshot(amount: str, invoice_ccy: str, booking_ccy: str) -> dict:
    data = fetch_rate(invoice_ccy, booking_ccy)

    if data["status"] != "fresh":
        raise RuntimeError("rate is stale; retry before issuing the invoice")

    amount_dec = Decimal(amount)
    rate = Decimal(data["rate"])
    booked = (amount_dec * rate).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)

    return {
        "invoice_amount": str(amount_dec),
        "invoice_currency": invoice_ccy,
        "booking_currency": booking_ccy,
        "rate": data["rate"],            # exact string, as received
        "rate_as_of": data["as_of"],
        "rate_type": data["type"],
        "fetched_at": datetime.now(timezone.utc).isoformat(),
        "booked_amount": str(booked),
        "rounding": "half_up_2dp",
    }


print(build_invoice_snapshot("1250.00", "USD", "EUR"))

Whether to block on a stale rate is a business decision. For a final invoice, failing and retrying is usually safer than booking on old data. For a draft or a preview, showing the stale rate with a visible note may be fine. GetRatesAPI flags stale rates rather than withholding them, so the choice stays with you.

If you only need the converted figure, the convert endpoint returns an exact converted_amount for a request like GET /v1/convert?from=USD&to=EUR&amount=125.50. The result is not rounded, so you still apply your own rounding rule. For invoices, fetching the rate and calculating yourself usually makes it easier to store the exact rate alongside the result.

Round once, at a defined point

Rounding differences are the most common reason a customer's total is a cent away from yours. Two rules help:

  • Convert at one level only. Either convert each line item and sum the rounded lines, or sum the lines in the invoice currency and convert the total once. Pick one, document it and keep it consistent. Converting the total once is generally simpler to explain.
  • Never convert already-converted amounts. Keep the original invoice-currency amounts as the source of truth. Derive booking-currency figures from them, not from each other.

Currencies also differ in minor units. JPY has none, USD and EUR have two, and some currencies have three. Quantize to the right exponent for the currency you are producing. For the full treatment of decimals and rounding modes, see our guide on currency conversion rounding without floating-point errors.

Handle credit notes, refunds and partial payments

Corrections are where snapshots earn their keep. A credit note that reverses an invoice should normally reuse the original invoice's stored rate, so the reversal nets to zero in the books. Fetching a new rate for the refund would create a small mismatch that someone has to explain.

Partial payments work the same way: each payment can carry its own rate snapshot if you track gains and losses, while the invoice keeps its original one. Keep these as separate records instead of overwriting.

Quotes versus invoices: use live rates for the former

Before an invoice exists, a customer often wants a quote. Here a live rate is the right input, as long as you tell the customer how long it is valid. A common pattern is to quote with a rate, hold it for a fixed window, then re-fetch when the window ends. If you call the API often for quotes, a short cache helps, and our article on caching exchange rates without showing stale prices explains how to size the TTL against the freshness windows. Invoices themselves should not depend on a cache; they should depend on the stored snapshot.

Handle errors by their code only. unsupported_pair and invalid_asset_symbol mean the request needs fixing, while rate_limit_exceeded includes retry_after_seconds and temporarily_unavailable is worth a retry with backoff. The full list is in the error reference.

A checklist before you ship

  • Invoice amounts are stored as decimals or integer minor units, never floats.
  • The rate is stored as the exact string with direction, as_of, fetched_at, status and type.
  • Issued invoices are never recalculated from a fresh rate.
  • Credit notes reuse the original snapshot.
  • Rounding rule and level are written down and tested.
  • Your accountant has confirmed which rate source and timing your jurisdiction expects.

Try it on your own invoices

GetRatesAPI covers about 170 fiat currencies plus metals and crypto, and any pair works even if no market quotes it directly. Each rate states whether it is direct or derived. You can try every endpoint in the dashboard playground on the free plan, which needs no credit card: create a free account. When your invoice volume grows, see the pricing page for plan limits.

All articles →
Invoice in Foreign Currency: Which Exchange Rate to Use — GetRatesAPI