amount_invalid_type
HTTP 422, type invalid_request_error.
You sent amount as a JSON number. It must be a JSON string.
Why it happened
This is the most likely first mistake anyone makes against this API, and it is our fault more than yours: every other API you have used takes a number here.
Amounts are strings because JSON numbers are IEEE-754 doubles in mainstream parsers. Above roughly nine quadrillion minor units they lose precision silently, on your machine, where nothing we deploy can catch it. A string cannot do that.
How to fix it
Send the amount in minor units, as a string, with no decimal point and no exponent.
{ "amount": "1250", "currency": "USD" }
That is 12.50 USD. 1250 without quotes is this error; "12.50" is amount_invalid_format.
One consequence worth knowing before it bites: amount * 2 in JavaScript concatenates
strings. Parse to an integer type before doing arithmetic. The loud failure is deliberate.
Retrying: retry only after fixing amount, to a JSON string. This request is refused before its Idempotency-Key is claimed, so send the corrected request with the same Idempotency-Key.
Related codes
amount_invalid_format-- a string, but not an integercurrency_unsupported-- the currency, not the amount