Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

Convert Minor Units

finance.convert_minor_units

ProductionBounded custom (Class B)Deterministicstrictfastv1.0.0
No network

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

Note
Exact major ↔ minor unit conversion for allowlisted ISO 4217 currencies.

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

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

data-transformationmath

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call1 credit

File handling

Accepts file_refProduces file_refMax input4 KB

How we handle your data

Sensitive input, safe output
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.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
amountobjectYesMajor-unit decimal for to_minor, or integer minor-unit count for to_major, as a plain string or JSON number under 1E18.
currencystringYesISO 4217 code whose official digit count drives the conversion.
directionstringYesWhether to convert major units into integer minor units, or the reverse.
onExcessPrecisionstringNoWhat to do when to_minor carries extra decimals; omit it for reject.
roundingstringNoRequired unless onExcessPrecision is not round; ignored when no rounding happens.

Output schema

FieldTypeRequiredDescription
minorUnitsintegerYesAmount as a whole number of minor units, for example 1234 for 12.34 EUR.
majorAmountstringYesSame amount as a decimal string carrying exactly minorUnitDigits fraction digits.
currencystringYesISO 4217 code whose official digit count produced this receipt, upper-cased.
minorUnitDigitsintegerYesOfficial fraction digits for this currency, from 0 through 3.
directionstringYesConversion direction actually applied, lower-cased, so a stored pair cannot be read backwards.
precisionAdjustedbooleanYesTrue only when extra decimals were rounded away; false on every exact conversion.
_metaobjectNoPinned ISO 4217 digit table that produced this answer so a stored conversion names its digit counts.

API contract

POST /v1/execute
curl
curl -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"}}'
Integrations
TypeScript SDK
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

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.
CURRENCY_UNKNOWN400NoThe request payload failed this skill's input validation.
AMOUNT_INVALID400NoThe request payload failed this skill's input validation.
AMOUNT_PRECISION_EXCEEDED400NoThe request payload failed this skill's input validation.
AMOUNT_MAGNITUDE_EXCEEDED429NoA size, quota, rate, or time limit was exceeded.

Other limits

LimitValue
Recommended inline bytes32 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)

Request bodyjson
{
  "skillKey": "finance.convert_minor_units",
  "input": {
    "direction": "to_minor",
    "amount": "12.34",
    "currency": "EUR",
    "onExcessPrecision": "reject"
  }
}

Examples

EUR major units to integer cents

Inputjson
{
  "direction": "to_minor",
  "amount": "12.34",
  "currency": "EUR",
  "onExcessPrecision": "reject"
}
Expected outputjson
{
  "_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

Inputjson
{
  "currency": "JPY",
  "direction": "to_minor",
  "amount": "100"
}
Expected outputjson
{
  "_meta": {
    "currencyProfile": "iso4217-2026-07"
  },
  "majorAmount": "100",
  "direction": "to_minor",
  "currency": "JPY",
  "minorUnits": 100,
  "minorUnitDigits": 0,
  "precisionAdjusted": false
}
  • 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

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.

Tags

mathcurrencytransformationfinance