Amounts & currency

Money objects represent a value using an integer amount, a scale, and a currency.

{
  "amount": 12550,
  "scale": 2,
  "currency": "USD"
}

This represents 125.50 USD.

Read an amount

For a computer, divide amount by 10 raised to the power of scale.

For a human, imagine a decimal point at the end of the integer, then move it scale places to the left. With an amount of 12550 and a scale of 2, 12550 becomes 125.50.

AmountScaleValue
12550012550
125502125.50
12550312.550

Always read the supplied scale. Do not assume every amount is expressed in cents.

Read the currency

The currency field identifies the denomination using an ISO 4217 currency code, such as USD.

Keep the currency with the amount when storing or processing it. Changing the currency code does not convert the value into another currency. Each endpoint’s schema defines which currencies it accepts.

Calculate with money

Preserve the integer amount and its scale in your application. Before adding or comparing values, make sure they use the same currency and scale.

Use integer or decimal arithmetic for calculations to avoid floating-point rounding errors. Apply display formatting separately from the stored value.

Other amount formats

Some fields may use a different amount representation, which will be highlighted in the field’s documentation.