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 eitherfromAmount 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 as400 — 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.
Check
failureReason before reaching for previewId: a refused preview has no id to execute
against.
Execute
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.