Currencies Configuration
  • 03 May 2023
  • 6 Minutes To Read
  • Dark
    Light
  • PDF

Currencies Configuration

  • Dark
    Light
  • PDF

Article Summary

Currencies are used to configure the currency type associated with monetary values in Mambu. For more information, see Currencies.

With Configuration as Code (CasC), you may batch configure your currencies configuration via the API using YAML. For general information on CasC, see Configuration as Code Overview.

Please be Aware

The CasC for currencies feature currently supports fiat currencies only. If you have access to cryptocurrencies or non-traditional currencies, they are not currently supported by CasC. For more information about crypotcurrencies and non-traditional currencies, see Currencies.

API Operations

CasC for currencies supports two operations.

ActionEndpointDescription
GET/configuration/currencies.yamlGet current currencies configuration.
PUT/configuration/currencies.yamlWrite a new currencies configuration to Mambu.
Please Note

If you PUT a configuration to Mambu, any current configuration settings not included in the new YAML configuration will be deleted. PATCH requests are not currently supported.

Requests

For general information on CasC requests such as authentication and required headers, see Configuration as Code Overview.

The following section shows sample requests using curl and basic authentication. For all examples, replace TENANT_NAME with your actual tenant name.

GET configuration

You can get your current currencies configuration either for all time periods, from a specified start date.

Retrieving all rates for all time periods

curl -X GET 'https://TENANT_NAME.mambu.com/api/configuration/currencies.yaml' \
-H 'Accept: application/vnd.mambu.v2+yaml' \
-H 'Authorization: Basic {auth}'

{auth} is the base-64-encoded value of username:password. For more information, see Authentication in our API reference.

Retrieving rates for specified time periods

To retrieve rates from a specific start date, use the startDate parameter in the YYY-MM-DD format. The midnight value of the configuration start date is determined by your organization's timezone.

curl -X GET 'https://TENANT_NAME.mambu.com/api/configuration/currencies.yaml?startDate=2019-01-02' \
-H 'Accept: application/vnd.mambu.v2+yaml' \
-H 'Authorization: Basic {auth}'

{auth} is the base-64-encoded value of username:password. For more information, see Authentication in our API reference.

Sample response

The following example shows a reply for a query with a start date value of the 2nd of January, 2019.

---
startDate: "2019-01-02"
baseCurrency:
  code: "USD"
  name : "US Dollars"
  symbol: "$"
  symbolPosition: "BEFORE_NUMBER"
  digitsAfterDecimal: 2
  type: "FIAT_CURRENCY"
foreignCurrencies:
  - currency:
      code: "EUR"
      name: "Euro"
      symbol: "€"
      symbolPosition: "AFTER_NUMBER"
      digitsAfterDecimal: 2
      type: "FIAT_CURRENCY"
    accountingRates:
      - startDate: "2018-01-02T00:00+11:00"
        rate: 100
      - startDate: "2020-01-02T00:00+11:00"
        rate: 100
    exchangeRates:
      - startDate: "2018-01-02T00:00+11:00"
        buyRate: 100
        sellRate: 110
      - startDate: "2020-01-02T00:00+11:00"
        buyRate: 200
        sellRate: 210     

Note that in this example the returned accounting and exchange rates have a start date of the 2nd of January, 2018, and that this date falls before our specified query start date of the 2nd of January, 2019, as shown in the first line.

This is because the returned values for accounting and exchange rates begin with the value that was in effect at the time of the query startDate. That value is reported along with its start date, which is the date the rate was added to Mambu. See the timeline below for an illustration.

Timeline showing start date is before start date specified in parameter.

If you specify a query startDate value that lies before the start date of a foreign currency exchange or accounting rate - that is, before the currency was added to Mambu - you will receive a reply that begins with the earliest exchange or accounting rate that was entered into Mambu along with its start date. That date will be after the specified query startDate. See the timeline below for an illustration:

Timeline showing start date is after start date specified in parameter.

PUT configuration

curl -X PUT 'https://tenanturl.mambu.com/api/configuration/currencies.yaml' \
-H 'Accept: application/vnd.mambu.v2+yaml' \
-H 'Content-Type: application/yaml' \
-H 'Authorization: Basic {auth}' \
--data-binary @currencies.yaml

“@currencies.yaml” represents the absolute path of the file on your device.

Use “--data-raw” if you want to specify the YAML body inline.

Configuration body example

startDate: "2019-01-02" 
baseCurrency:
  code: "USD"
  name : "US Dollars"
  symbol: "$"
  symbolPosition: "BEFORE_NUMBER"
  digitsAfterDecimal: 2
  type: "FIAT_CURRENCY"
foreignCurrencies:
  - currency:
      code: "EUR"
      name: "Euro"
      symbol: "€"
      symbolPosition: "AFTER_NUMBER"
      digitsAfterDecimal: 2
      type: "FIAT_CURRENCY"
    accountingRates:
      - startDate: "2019-01-02T00:00+11:00"
        rate: 100
      - startDate: "2019-01-05T00:00+11:00"
        rate: 100
    exchangeRates:
      - startDate: "2019-01-02T00:00+11:00"
        buyRate: 100
        sellRate: 110
      - startDate: "2020-06-29T00:00+10:00"
        buyRate: 200
        sellRate: 210  

Attributes

NameTypeDescriptionRequired
startDateStringDate starting from which the configuration is applied and/or retrieved, based on the organization timezone. Can be null if all the data is retrieved or updated.
baseCurrencyCurrency configurationModel representing the currency configuration.
foreignCurrenciesForeign Currency ConfigurationList of all foreign currencies. Can be empty. Ordered by currency code, ascending.

Base currency attributes

NameTypeDescriptionRequired
codeStringThe unique currency code.
nameStringThe currency name.
symbolStringThe currency symbol.
symbolPositionStringThe position of the currency symbol. The options are BEFORE_NUMBER and AFTER_NUMBER.
digitsAfterDecimalStringNumber of digits that are supported for given currency.
typeStringThe type of currencies. Only FIAT_CURRENCY is currenlty supported.

Foreign currency attributes

NameTypeDescriptionRequired
currencyCurrency configurationModel representing the currency configuration.
currency.codeStringThe unique currency code.
currency.nameStringThe currency name.
currency.symbolStringThe currency symbol.
currency.symbolPositionStringThe position of the currency symbol.
currency.digitsAfterDecimalStringNumber of digits that are supported for given currency.
currency.typeStringThe type of currencies. Only FIAT_CURRENCY is currenlty supported.
accountingRatesAccounting Rate ConfigurationThe accounting rate for the current currency and base currency. Ordered by start date, ascending.Required only if Accounting in Multicurrency is enabled, not required otherwise.
accountingRates.startDateStringThe accounting rate will apply starting with this date.
accountingRates.rateNumberThe accounting rate.
exchangeRatesExchange rate configurationThe exchange rate for the current currency and base currency. Ordered by start date, ascending.
exchangeRates.startDateStringThe exchange rate applies starting with this date.
exchangeRates.buyRateNumberThe buy exchange rate.
exchangeRates.sellRateNumberThe sell exchange rate.

Replies

If you do not receive a 200 OK status code then fix any validation errors and make another PUT request until you receive a 200 OK status code.

Please Note

If you PUT a valid YAML configuration to the API and you do not receive a 200 OK status code within 60 seconds, you may receive a 504 Gateway Timeout status code. We expect all responses to be below 60 seconds.

If you encounter this issue, please contact us through Mambu Support so we can investigate it.

Validations

NameValidation
nameMust have a maximum length of 256 characters.
symbolMust have a maximum length of 10 characters.
codeThe code can not be changed at update. It has the initial value set when the tenant was first created or provisioned.
accountingRatesList cannot be empty if Accounting in Multicurrency is enabled. Existing accounting rates can not be edited or removed, they must be left as they were retrieved. Only new rates can be added.
accountingRates.startDateIt must be greater than the previous rate start date. If it’s the first rate, it’s start date is compared with the configuration start date.
accountingRates.rateMust be between 0 and 2000000000000000
exchangeRatesList cannot be empty. Existing accounting rates can not be edited or removed, they must be left as they were retrieved. Only new rates can be added.
exchangeRates.startDateIt must be greater than the previous rate start date. If it’s the first rate, it’s start date is compared with the configuration start date.
exchangeRates.buyRateIt must be between 0 and 2000000000000000
exchangeRates.sellRateIt must be between 0 and 2000000000000000. It must be greater than the buy rate.

Warnings

You will receive a list of warnings if you try to delete a foreign currency which is in use because those cannot be deleted.

You will also receive warnings if a foreign currency does not have an accounting rate specified or an exchange rate specified.

Please Note

Unlike the Mambu UI, you cannot omit the exchange rate or accounting rate when adding or editing a currency when making API requests.


Was this article helpful?