Skip to main content

amount_invalid_format

HTTP 422, type invalid_request_error.

amount is a string, but not a plain integer.

Why it happened​

An amount is an integer in the currency's minor unit, sent as a string. A decimal point, an exponent, a leading sign or surrounding whitespace all fail this check.

The rule is strict on purpose. "12.50" is ambiguous the moment a currency has a different number of decimal places, and a parser that guesses is a parser that eventually guesses wrong about money.

How to fix it​

Send minor units with nothing else in the string.

{ "amount": "1250", "currency": "USD" }

That is 12.50 USD. "12.50", "1250.00", "1.25e3", "+1250" and " 1250" are all this error. A number rather than a string is amount_invalid_type.

Retrying: retry only after fixing amount, to a string of digits in minor units. This request is refused before its Idempotency-Key is claimed, so send the corrected request with the same Idempotency-Key.