Skip to main content
Converting between two currencies you hold is a two-call flow. You preview to get a rate and a previewId, then you execute against that id. The rate you were shown is the rate you get. This exists because a quote you cannot act on is not useful. Splitting the call lets you show a number to a customer, let them think about it, and settle on that number rather than on whatever the market has moved to by the time they answer.

Preview

Specify either fromAmount or toAmount, not both. fromAmount sells a fixed amount; toAmount buys a fixed amount and tells you what it will cost.
Previewing moves no money and has no side effects. Quote as often as you need.

When a preview is refused

A preview StableMint will not book comes back as 400 — including when the only thing wrong is that you cannot afford it. The body is not a problem document: it is the quote you asked for, plus a failureReason saying why it will not be booked, and no previewId.
A 400 here does not mean your request was malformed. NoBalance and InsufficientMasterLiquidity are both worth retrying — the first once the account is funded, the second after a wait — even though Errors treats 400 as “retrying unchanged will not help” everywhere else. Read failureReason before deciding.
Check failureReason before reaching for previewId: a refused preview has no id to execute against.

Execute

A previewId is single-use. It is consumed on the first successful execute. Replaying the same id does not book a second conversion — but it is not an idempotent read either, so treat a non-success response as an unknown outcome and check Transactions for a Conversion before retrying with a fresh preview.
The response restates the rate and amounts that were booked. It may also carry scaOperationId and maxAttemptCount, which indicate the conversion requires a strong customer authentication step before it settles; handle those fields if your flow can produce them rather than assuming every execute completes inline.

Handling expiry

1

Preview, and record expiryTime

Treat it as a hard deadline, not a guideline.
2

Show the rate for less time than you have

Leave yourself enough margin to make the execute call and handle a retry.
3

Re-preview rather than chase

If the quote lapses, get a new one and show the new number. There is no extension mechanism, and executing an expired id fails.
A conversion is two transactions, not one. It appears in Transactions as a pair sharing category: "Conversion" — an Outward leg debiting the sell currency and an Inward leg crediting the buy currency. Nothing leaves StableMint, but do not expect a single row, and do not filter on a transactionDirection of Internal: conversions never carry it.

Currencies

EUR and USD today, in either direction, between accounts you already hold. You cannot convert into a currency you have no account in.