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.

7 min read

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"
}
FieldWhat it is
statusCodeThe HTTP status
errorThe HTTP reason phrase, such as Conflict
codeA stable, machine-readable code. Branch on this
messageWhat went wrong and what to do, for people. Always a string
request_idThe request's id, also sent as the X-Request-Id header
fieldThe request field at fault, when there is one
detailsEvery 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:

StatusCodeMeaning
400validation_failedA field failed validation, or the body has an unknown field. field names the first one, message the first problem and details every problem
400client_ip_invalidFianto could not tell which network the request came from, for example because a proxy sent a malformed X-Forwarded-For
401invalid_api_credentialsWrong 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_not_approved instead, on the routes that wait for approval. See Authentication
401api_key_wrong_networkA 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_api_credentials. See Authentication
403merchant_not_approvedDevnet 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
400idempotency_key_required, idempotency_key_invalidThe Idempotency-Key header is missing or malformed. See Idempotency
422idempotency_key_reusedThe key was used with a different request
409idempotency_request_in_progressThe first request with this key is still running
409idempotency_response_unreadableThe request already completed; fetch the resource
400amount_or_price_requiredSend price_id, or amount with description
400amount_out_of_rangeThe amount is outside 0.01 to 1,000,000 USDC
400url_insecuresuccess_url or cancel_url is not https
400expires_at_out_of_rangeexpires_at is not 5 minutes to 24 hours away
404price_not_foundNo price with that id belongs to you
422price_ended, product_endedThe price, or its product, has been ended; send an active price
422price_type_mismatchA payment session needs a one-time price; that price is recurring
409order_already_paidThis order_id is paid; use a new one
409order_id_in_useThis order_id already belongs to a completed checkout session, such as a completed subscription session; use a new one
409payment_in_progressA payment for this session is being processed, or the last transaction prepared for it could still land
409session_not_reissuableThe session is not open, or has under 120 seconds left
409session_not_cancelableThe session is no longer open
409checkout_unavailableFianto could not reach or check Solana in time. Retry after Retry-After (5 seconds)
422merchant_token_account_missingYour receiving wallet has no USDC token account
409checkout_wallet_requiredDevnet 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
400price_id_required, amount_not_allowedA subscription session needs price_id and no amount or description
422price_not_recurringA subscription session needs a recurring price
429plan_limit_reachedYour account reached its limit of new subscription plans in the last 24 hours: 50, or in Test mode before approval 5
409subscription_already_endedThe subscription has already ended
503subscription_busyAnother request was changing this subscription at the same moment. Nothing was changed; retry with the same Idempotency-Key
404invoice_not_foundNo document with that id belongs to this application: "This document does not exist."
400cursor_invalidOn GET /v1/invoices: the cursor names none of your documents. Start again from the first page
409webhook_endpoint_not_activeNo verified webhook URL to send a test event to
429rate_limitedToo many requests. Wait for Retry-After. See rate limits
500internal_errorSomething failed on Fianto's side. Quote the request_id
503checkout_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
503subscriptions_pausedNew subscription sessions are paused for now; existing subscriptions are unaffected. Try again later
422payment_method_unavailableNone 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:

StatusCodeMeaning
422payer_is_merchantThe payer connected your receiving wallet. Nothing was signed; another wallet can pay
422transaction_expiredThe payer approved the payment after it expired (about 60 to 90 seconds in the wallet), so Fianto did not send it
422transaction_would_failFianto simulated the signed payment before sending it, and it would have failed on Solana, so Fianto did not send it
409gateway_not_offered"This checkout session does not offer that way to pay. Choose another one."
409solana_pay_unavailableScan to pay cannot pay this session because it is a subscription: "Scan to pay isn't available for this checkout."
404solana_pay_key_invalidThe 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_would_fail, 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.

ClassWhen
APIErrorAny error response. Has status, code, message, field, details, requestId, headers
AuthenticationError401
PermissionDeniedError403
InvalidRequestError400 and 422
NotFoundError404
ConflictError409
RateLimitError429, with retryAfterSeconds
ServiceUnavailableError503
InternalServerErrorOther 5xx
ConnectionErrorNo response arrived
TimeoutErrorThe 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_request_in_progress or checkout_unavailable. It never retries any other 4xx, idempotency_key_reused included, and never retries plan_limit_reached (429) or subscriptions_paused (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_token_account_missing. The 503 answers checkout_busy, service_busy and subscriptions_paused 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

On this page