Agent Wranglers

API-8Required

Send money as an integer with its currency

Send amounts as an integer count of the currency's smallest unit, together with the ISO 4217 currency code. Never use floating-point numbers for money.

How to do it

Write 129.50 Swedish kronor as { "amount": 12950, "currency": "SEK" }. Look up each currency's number of decimals in ISO 4217, because it is not always two. Japanese yen has none and Kuwaiti dinar has three. Floats can't store 0.1 exactly, so sums drift. A decimal string such as "129.50" also works, if the whole API uses it. Store it with exact types. See also hold money as integer minor units everywhere.

Examples

JSON example

{ "total": { "amount": 12950, "currency": "SEK" } }

How to check

Search the OpenAPI file for money fields typed number. None remain, and each amount has a currency beside it.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/requests-and-responses/money">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.