Convert Minor Units
finance.convert_minor_units
Overview
You pass an amount, ISO 4217 currency, and direction; we convert between major-unit decimals and integer minor units using the currency's official digit count. Extra precision is rejected by default or rounded only when you ask for it. We do not convert currencies or format for display. Do not use this for FX rates or locale-specific formatting.
Hard-coding two decimals quietly breaks JPY, KRW, BHD and KWD, and a stray third decimal turns into a rounding argument with your payment provider. We use the official digit count and refuse to drop precision unless you ask us to.
Reliability
Same input, same answer — exact decimal arithmetic, no floating point, and the digit count comes from the official ISO 4217 table rather than an assumption about cents. Nothing is rounded unless you set onExcessPrecision to round, and we tell you in precisionAdjusted when we did. CURRENCY_UNKNOWN — trigger: a blank code, or one outside the twenty currencies we support; retryable: no, the same code always fails; next: send a supported ISO 4217 code such as EUR or JPY. AMOUNT_INVALID — trigger: an amount we cannot read as a plain decimal, a to_major amount that is not a whole number of minor units, an onExcessPrecision other than reject or round, or a missing or unknown rounding mode while onExcessPrecision is round; retryable: no; next: strip separators and exponents from the amount, send whole minor units for to_major, and pair round with one of the seven rounding modes. AMOUNT_PRECISION_EXCEEDED — trigger: your to_minor amount carries more decimals than the currency has, and onExcessPrecision is left at reject; retryable: no; next: either round on your side first, or resend with onExcessPrecision set to round and a rounding mode you can defend to an auditor. AMOUNT_MAGNITUDE_EXCEEDED — trigger: the amount, or the minor-unit count it becomes, goes past 1E18 and would no longer survive a JSON round trip; retryable: no; next: split the figure, or keep totals of that size out of a single conversion.
Context footprint
Returns both major and minor representations so you can round-trip without a second call. A successful call costs 1 execution credit.
When to use it
When you move money between a decimal display value and the integer minor units your ledger or payment provider stores.
When you need an exchange rate, or a display string for a locale.
Scope
Non-goals
- Does not convert between currencies
- Does not format amounts for display
- Does not silently truncate excess precision unless you opt in to rounding
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
How we handle your data
What this means
This skill may receive sensitive content, but it does not target sensitive data and returns only a structured non-sensitive result.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response does not contain submitted content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| amount | object | Yes | Major-unit decimal for to_minor, or integer minor-unit count for to_major, as a plain string or JSON number under 1E18. |
| currency | string | Yes | ISO 4217 code whose official digit count drives the conversion. |
| direction | string | Yes | Whether to convert major units into integer minor units, or the reverse. |
| onExcessPrecision | string | No | What to do when to_minor carries extra decimals; omit it for reject. |
| rounding | string | No | Required unless onExcessPrecision is not round; ignored when no rounding happens. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| minorUnits | integer | Yes | Amount as a whole number of minor units, for example 1234 for 12.34 EUR. |
| majorAmount | string | Yes | Same amount as a decimal string carrying exactly minorUnitDigits fraction digits. |
| currency | string | Yes | ISO 4217 code whose official digit count produced this receipt, upper-cased. |
| minorUnitDigits | integer | Yes | Official fraction digits for this currency, from 0 through 3. |
| direction | string | Yes | Conversion direction actually applied, lower-cased, so a stored pair cannot be read backwards. |
| precisionAdjusted | boolean | Yes | True only when extra decimals were rounded away; false on every exact conversion. |
| _meta | object | No | Pinned ISO 4217 digit table that produced this answer so a stored conversion names its digit counts. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"finance.convert_minor_units","input":{"amount":"12.34","currency":"EUR","direction":"to_minor"}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("finance.convert_minor_units", {"direction":"to_minor","amount":"12.34","currency":"EUR","onExcessPrecision":"reject"});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
| CURRENCY_UNKNOWN | 400 | No | The request payload failed this skill's input validation. |
| AMOUNT_INVALID | 400 | No | The request payload failed this skill's input validation. |
| AMOUNT_PRECISION_EXCEEDED | 400 | No | The request payload failed this skill's input validation. |
| AMOUNT_MAGNITUDE_EXCEEDED | 429 | No | A size, quota, rate, or time limit was exceeded. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- Does not convert between currencies
- Does not format amounts for display
- Does not silently truncate excess precision unless you opt in to rounding
- Currency conversion or FX rates
- Locale display formatting
- VAT or invoice total validation
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "finance.convert_minor_units",
"input": {
"direction": "to_minor",
"amount": "12.34",
"currency": "EUR",
"onExcessPrecision": "reject"
}
}Examples
EUR major units to integer cents
{
"direction": "to_minor",
"amount": "12.34",
"currency": "EUR",
"onExcessPrecision": "reject"
}{
"_meta": {
"currencyProfile": "iso4217-2026-07"
},
"majorAmount": "12.34",
"direction": "to_minor",
"currency": "EUR",
"minorUnits": 1234,
"minorUnitDigits": 2,
"precisionAdjusted": false
}JPY has zero minor-unit digits
{
"currency": "JPY",
"direction": "to_minor",
"amount": "100"
}{
"_meta": {
"currencyProfile": "iso4217-2026-07"
},
"majorAmount": "100",
"direction": "to_minor",
"currency": "JPY",
"minorUnits": 100,
"minorUnitDigits": 0,
"precisionAdjusted": false
}Recommended use cases
- Store ledger amounts as integer minor units in your database
- Round-trip cents safely before payment capture
- Handle zero-decimal currencies like JPY correctly
Avoid for
- Currency conversion or FX rates
- Locale display formatting
- VAT or invoice total validation
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.