Official Exchange Rates in Salesforce: Dated Exchange Rates API

Load central bank and tax authority exchange rates (ECB, Fed, Bank of England, RBI, HMRC and 170+ more) into Salesforce multi-currency: DatedConversionRate or CurrencyType, scheduled Apex or an external job, plus a historical load.

By Madhushan, Founder & Lead Developer ·

Salesforce multi-currency converts amounts with the rates you maintain under Setup > Manage Currencies. Salesforce does not fill them for you. When finance asks for a named rate, such as the ECB reference rate, the Federal Reserve's H.10 rate, the RBI reference rate or the HMRC monthly rate, load that institution's own table from the Central Bank Exchange Rate API. It is dated with the bank's publication date, so quotes, opportunities and reports use the same rate as the books.

The code on this page is open source: salesforce-central-bank-rates on GitHub (MIT). It contains Apex classes with tests, a one-command setup script, and a Python script for running the job outside Salesforce. We tested it end to end in a Developer Edition org: ECB rates into dated exchange rates, RBI rates into static rates, and reruns that update rows instead of duplicating them.

1. Which Salesforce object holds the rate

2. What the API returns

One call returns a bank's whole table. Each row is value units of quote per 1 unit of base, and rate_date is the date the bank put on it. The /{YYYY-MM-DD} form returns the table in force on any past date. Weekends and holidays resolve to the previous publication, which is the rate a regulation expects.

GET https://allratestoday.com/api/v1/central-bank/ecb/latest
Authorization: Bearer art_live_your_key

{
  "bank": "ecb",
  "rate_date": "2026-11-25",
  "stale": false,
  "usually_at_utc": "14:07",
  "rates": [
    { "base": "EUR", "quote": "USD", "type": "reference", "value": 1.0935 },
    { "base": "EUR", "quote": "GBP", "type": "reference", "value": 0.8373 },
    { "base": "EUR", "quote": "JPY", "type": "reference", "value": 174.22 }
  ]
}

3. Convert to your corporate currency

Every row involves the publisher's home currency (EUR for the ECB, INR for the RBI, GBP for the Bank of England). Express each currency per 1 unit of that home currency, then divide by the corporate currency's figure:

ConversionRate(X) = (X per 1 home) / (corporate per 1 home)

This makes any table usable whatever your corporate currency is. A USD-corporate org reading the ECB table above writes EUR = 1 / 1.0935 = 0.914495 and GBP = 0.8373 / 1.0935 = 0.765706. Write only active, non-corporate currencies, and leave currencies the bank does not publish alone.

4. Write the rates (REST, not DML)

Apex DML is not allowed on DatedConversionRate or CurrencyType, so every integration writes them through the REST API (Apex calls the org's own API through a Named Credential). StartDate is the bank's rate_date, not the day the job ran. Query DatedConversionRate for that StartDate first and update the existing row, so a re-run does not fail on a duplicate. Salesforce closes the previous range for you. After a 2026-11-25 rate is added, the earlier EUR row's NextStartDate becomes 2026-11-25.

# New dated rate (the range starts on the bank's rate_date)
POST /services/data/v62.0/sobjects/DatedConversionRate
{ "IsoCode": "EUR", "ConversionRate": 0.914495, "StartDate": "2026-11-25" }

# A rate already exists for that StartDate: update it
PATCH /services/data/v62.0/sobjects/DatedConversionRate/04w...
{ "ConversionRate": 0.914495 }

# Without Advanced Currency Management: the static rate
PATCH /services/data/v62.0/sobjects/CurrencyType/02k...
{ "ConversionRate": 0.914495 }

5. In Salesforce: scheduled Apex

Run ./scripts/setup-org.sh myorg from the repository after sf org login web. It needs no custom objects. The script deploys the classes and two Named Credentials. AllRatesToday keeps your API key encrypted in an External Credential and sends it as an Authorization header. ART_Salesforce_API reaches your org's own REST API through an External Client App with the client credentials flow; leave its scope empty, because the token endpoint rejects one. The script also assigns two permission sets and asks for the key and the app's consumer secret. A batch class makes one rates call per table, and a scheduled class runs it. If a write fails, the job fails and shows the error in Setup > Apex Jobs.

// Execute Anonymous, after deploying the repository and setting up its two Named Credentials
ARTRateOptions o = new ARTRateOptions('ecb');          // bank or tax-authority code
o.mode = ARTRateOptions.SyncMode.DATED;                 // or ARTRateOptions.SyncMode.STATIC_RATES
Database.executeBatch(new ARTRateSyncBatch(o), 1);     // latest table, now

// Weekdays at 17:00 (scheduling user's time zone), after the ECB's ~16:00 CET publication
System.schedule('AllRatesToday ECB rates', '0 0 17 ? * MON-FRI', new ARTRateSyncSchedulable(o));

The core of it, without the error handling and buy/sell filtering the repository adds:

HttpRequest req = new HttpRequest();
req.setEndpoint('callout:AllRatesToday/api/v1/central-bank/ecb/latest');   // Named Credential adds the key
req.setMethod('GET');
Map<String, Object> table = (Map<String, Object>) JSON.deserializeUntyped(new Http().send(req).getBody());

// value = quote per 1 base. Express every currency per 1 unit of the publisher's home currency (EUR here),
// then divide by the corporate currency's figure: ConversionRate(X) = (X per EUR) / (USD per EUR).
Map<String, Decimal> perHome = new Map<String, Decimal>{ 'EUR' => 1 };
for (Object o : (List<Object>) table.get('rates')) {
    Map<String, Object> r = (Map<String, Object>) o;
    perHome.put((String) r.get('quote'), Decimal.valueOf(String.valueOf(r.get('value'))));
}
Decimal gbp = perHome.get('GBP').divide(perHome.get('USD'), 6, System.RoundingMode.HALF_UP);   // 0.765706

Schedule after the bank publishes. Each /latest response carries usually_at_utc (14:07 UTC for the ECB), and the publication times of all banks are on the institutions list. If the bank has not published yet, the job rewrites the previous table and picks up the new one on the next run.

6. Outside Salesforce: a scheduled script

If you already run jobs in cron, a CI schedule or a serverless timer, skip the Apex and the second Named Credential. sync_rates.py gets an OAuth token with the client credentials flow, reads the active currencies, and writes DatedConversionRate or CurrencyType over REST.

pip install requests
export ALLRATES_API_KEY=art_live_your_key
export SF_DOMAIN=https://yourcompany.my.salesforce.com
export SF_CLIENT_ID=...  SF_CLIENT_SECRET=...      # External Client App, client credentials flow

python sync_rates.py --bank ecb --dry-run          # print the rates it would write
python sync_rates.py --bank ecb                    # latest table -> DatedConversionRate
python sync_rates.py --bank rbi --mode static      # latest table -> CurrencyType
python sync_rates.py --bank ecb --from 2026-01-01  # historical load, one table per weekday

7. Historical load and corrections

For back-dated opportunities, load one table per weekday over the range: ARTRateSyncBatch.historical(o, from, to) in Apex or --from in the script. Holidays return the previous table, and each rate_date is written once. Historical dates are on paid plans. History goes back to 1999 for the ECB and to the start of each bank's series for the others (see coverage).

Which table to load

Questions

Does this need an AppExchange package?

No. The repository is plain Apex you deploy and own. You can review every line, and it does not depend on a vendor package's release cycle.

Can I use it without Advanced Currency Management?

Yes. Use SyncMode.STATIC_RATES (or --mode static) to update CurrencyType.ConversionRate. Static rates have no history, so each run replaces the last.

How many API calls does it use?

One call per table: about 22 a month for a weekday schedule, and one per weekday in a historical range. All currencies of the table come in that one call.

Can I keep buying and selling rates apart?

Tables that publish several rate types (commercial bank boards, some central banks) carry type on each row. Set rateType (Apex) or --rate-type (script) to the one you want. Salesforce keeps one rate per currency and date, so it stores one type.

Need official rates in Salesforce and your ERP?

One API key covers Salesforce, Business Central, SAP, NetSuite and the rest, with the same bank and date everywhere.

Get a free API key Code on GitHub