DevelopersBuild safely
Errors
The v1 error body, request ids, the codes you will meet most, and how the SDK turns errors into classes and retries.
Every v1 error has the same JSON body. Branch on code, show or log message, and quote
request_id when you write to support@fianto.xyz.
The error body
{
"statusCode": 409,
"error": "Conflict",
"code": "order_already_paid",
"message": "That order_id is already paid. Use a new order_id to charge again.",
"request_id": "req_…",
"field": "order_id"
}| Field | What it is |
|---|---|
statusCode | The HTTP status |
error | The HTTP reason phrase, such as Conflict |
code | A stable, machine-readable code. Branch on this |
message | What went wrong and what to do, for people. Always a string |
request_id | The request's id, also sent as the X-Request-Id header |
field | The request field at fault, when there is one |
details | Every problem, when one request had several |
An unexpected server error always reads internal_error with the message "Something went wrong on
our side. Quote the request_id when you contact support."
Request ids
Every response carries an X-Request-Id header: req_ followed by 24 characters. If you send your
own X-Request-Id of 8 to 64 letters, digits, _ or -, Fianto keeps it, so your logs and
Fianto's share one id.
Codes
The list of codes is open-ended: Fianto can add codes, so treat any code you do not know by its HTTP
status. When a response has no specific code, Fianto uses a general one for its status, such as
bad_request, unauthorized, forbidden, conflict, unprocessable or rate_limited.
The codes you are most likely to meet:
| Status | Code | Meaning |
|---|---|---|
| 400 | validation_failed | A field failed validation, or the body has an unknown field. field names the first one, message the first problem and details every problem |
| 400 | client_ip_invalid | Fianto could not tell which network the request came from, for example because a proxy sent a malformed X-Forwarded-For |
| 401 | invalid_ | Wrong or disabled credentials, or an account that is not approved and active. On devnet, a test key of an account still being set up or reviewed answers 403 merchant_ instead, on the routes that wait for approval. See Authentication |
| 401 | api_ | A real, valid key sent to the other network's API: a live key (fian_sk_live_…) to devnet, or a test key (fian_sk_test_…) to mainnet. The message says which kind of key it is, and the WWW-Authenticate header is sent as with invalid_. See Authentication |
| 403 | merchant_ | Devnet only. A test key of an account still being set up or reviewed reached a route that waits for approval, such as GET /v1/application or GET /v1/events. See Before approval for the routes that work before approval |
| 400 | idempotency_, idempotency_ | The Idempotency-Key header is missing or malformed. See Idempotency |
| 422 | idempotency_ | The key was used with a different request |
| 409 | idempotency_ | The first request with this key is still running |
| 409 | idempotency_ | The request already completed; fetch the resource |
| 400 | amount_ | Send price_id, or amount with description |
| 400 | amount_out_of_range | The amount is outside 0.01 to 1,000,000 USDC |
| 400 | url_insecure | success_url or cancel_url is not https |
| 400 | expires_ | expires_at is not 5 minutes to 24 hours away |
| 404 | price_not_found | No price with that id belongs to you |
| 422 | price_ended, product_ended | The price, or its product, has been ended; send an active price |
| 422 | price_type_mismatch | A payment session needs a one-time price; that price is recurring |
| 409 | order_already_paid | This order_id is paid; use a new one |
| 409 | order_id_in_use | This order_id already belongs to a completed checkout session, such as a completed subscription session; use a new one |
| 409 | payment_in_progress | A payment for this session is being processed, or the last transaction prepared for it could still land |
| 409 | session_ | The session is not open, or has under 120 seconds left |
| 409 | session_ | The session is no longer open |
| 409 | checkout_ | Fianto could not reach or check Solana in time. Retry after Retry-After (5 seconds) |
| 422 | merchant_ | Your receiving wallet has no USDC token account |
| 409 | checkout_ | Devnet only. Your account is not approved yet and has no test wallet, so the checkout session has nowhere to pay and nothing was opened. Add a test wallet in the dashboard in Test mode. See Checkout sessions before approval |
| 400 | price_id_required, amount_not_allowed | A subscription session needs price_id and no amount or description |
| 422 | price_not_recurring | A subscription session needs a recurring price |
| 429 | plan_limit_reached | Your account reached its limit of new subscription plans in the last 24 hours: 50, or in Test mode before approval 5 |
| 409 | subscription_ | The subscription has already ended |
| 503 | subscription_busy | Another request was changing this subscription at the same moment. Nothing was changed; retry with the same Idempotency-Key |
| 404 | invoice_not_found | No document with that id belongs to this application: "This document does not exist." |
| 400 | cursor_invalid | On GET /v1/invoices: the cursor names none of your documents. Start again from the first page |
| 409 | webhook_ | No verified webhook URL to send a test event to |
| 429 | rate_limited | Too many requests. Wait for Retry-After. See rate limits |
| 500 | internal_error | Something failed on Fianto's side. Quote the request_id |
| 503 | checkout_busy (checkout-session routes), service_busy (other routes) | Fianto's database, or the Solana RPC it reads, was too busy to answer, and nothing was started. Retry after Retry-After (3 seconds), with the same Idempotency-Key on a POST; the SDK retries it for you. A devnet call can answer service_busy with Retry-After too; retry after the delay |
| 503 | subscriptions_ | New subscription sessions are paused for now; existing subscriptions are unaffected. Try again later |
| 422 | payment_ | None of the payment_methods you asked for can be offered: ["card"] when no card can serve this checkout. field is payment_methods, and the body adds method: "card". See Card payments |
Codes the checkout page handles
A few codes answer the hosted checkout page while a payer pays, never a call from your server. They
are in the API's code list, so the SDK's ErrorCode includes them, and the checkout page shows the
payer its own message for each:
| Status | Code | Meaning |
|---|---|---|
| 422 | payer_is_merchant | The payer connected your receiving wallet. Nothing was signed; another wallet can pay |
| 422 | transaction_expired | The payer approved the payment after it expired (about 60 to 90 seconds in the wallet), so Fianto did not send it |
| 422 | transaction_ | Fianto simulated the signed payment before sending it, and it would have failed on Solana, so Fianto did not send it |
| 409 | gateway_not_offered | "This checkout session does not offer that way to pay. Choose another one." |
| 409 | solana_ | Scan to pay cannot pay this session because it is a subscription: "Scan to pay isn't available for this checkout." |
| 404 | solana_ | The payer's wallet asked for a Scan to pay code that is malformed, unknown, or belongs to a checkout link that was reissued. The wallet shows "This payment link is no longer valid." |
After transaction_expired or transaction_, the session stays open and the payer can press Pay again.
The two Scan to pay codes are in the SDK's ErrorCode from version 0.8.0.
insufficient_sol is still in the code list and the SDK's ErrorCode, but it is deprecated: it has
never been returned since October 2026, because Fianto pays every Solana network fee.
In the SDK
The SDK throws one class per status. Every class extends FiantoError.
| Class | When |
|---|---|
APIError | Any error response. Has status, code, message, field, details, requestId, headers |
AuthenticationError | 401 |
PermissionDeniedError | 403 |
InvalidRequestError | 400 and 422 |
NotFoundError | 404 |
ConflictError | 409 |
RateLimitError | 429, with retryAfterSeconds |
ServiceUnavailableError | 503 |
InternalServerError | Other 5xx |
ConnectionError | No response arrived |
TimeoutError | The request took longer than timeoutMs |
The status classes extend APIError. Check a code with isFiantoError(err, ErrorCode.X):
import { APIError, ErrorCode, Fianto, isFiantoError } from '@fianto/sdk';
const fianto = new Fianto();
export async function createCheckout(orderId: string) {
try {
return await fianto.checkoutSessions.create({
mode: 'payment',
order_id: orderId,
amount: '12.50',
description: 'Coffee beans, 1 kg',
success_url: 'https://shop.example/thank-you',
cancel_url: 'https://shop.example/cart',
});
} catch (err) {
if (isFiantoError(err, ErrorCode.OrderAlreadyPaid)) {
return null; // this order is paid; do not charge it again
}
if (err instanceof APIError) {
console.error(err.status, err.code, err.requestId); // quote requestId to support
}
throw err;
}
}What the SDK retries
By default the SDK retries a call up to 2 times (maxRetries, 0 to 10). It retries network errors,
timeouts, 408, 429, every 5xx, and a 409 only when the code is idempotency_ or
checkout_. It never retries any other 4xx, idempotency_ included, and never
retries plan_limit_reached (429) or subscriptions_ (503): it throws them at once.
Between attempts it waits for Retry-After when the response sends one, and otherwise backs off from
500 ms, doubling each time up to 8 s, with ±25 % jitter. If Retry-After asks for more than
10 seconds, the SDK does not wait: it throws the error at once. Every retry of a POST reuses the
same idempotency key.
Route helpers pass only some codes to the browser
The SDK's checkout route helpers (Checkout(), checkout(), createCheckoutHandler) relay only an
allowlist of codes to the browser, such as payment_in_progress, url_insecure,
price_id_required, plan_limit_reached and merchant_. The 503 answers
checkout_busy, service_busy and subscriptions_ reach it as 503 with their Retry-After.
Every other error, including 401, 403 and any other 5xx, reaches the browser as 500
internal_error. Your onError
always receives the original error, so log it there.
instanceof can fail when one app loads the SDK twice, once as ESM and once as CommonJS.
isFiantoError works either way.
See also
Was this page helpful? Tell us
fianto.xyz