Errors

When a request fails, the Merchant API returns a non-2xx HTTP status and a consistent JSON error envelope. The code is a stable, machine-readable string you can branch on; the message is a human-readable explanation meant for logs and developers, not end users.

The error envelope

Every error has the same shape:

Error envelope

{
  "error": {
    "code": "invalid_amount",
    "message": "amount must be a decimal string"
  }
}

HTTP status codes

  • Name
    400
    Type
    Bad Request
    Description

    The request is malformed — invalid JSON body, a bad amount, or a missing required field.

  • Name
    401
    Type
    Unauthorized
    Description

    Authentication failed. See Authentication for the specific codes (missing_auth, stale_request, bad_signature, …).

  • Name
    403
    Type
    Forbidden
    Description

    Authenticated, but not allowed to perform this action.

  • Name
    404
    Type
    Not Found
    Description

    The resource does not exist, or is not owned by your account.

  • Name
    409
    Type
    Conflict
    Description

    The request conflicts with the resource's current state — e.g. refunding an order that is not refundable.

  • Name
    429
    Type
    Too Many Requests
    Description

    You are being rate limited. Back off and retry later.

  • Name
    500
    Type
    Internal Server Error
    Description

    Something went wrong on our side. Safe to retry idempotent requests.

  • Name
    503
    Type
    Service Unavailable
    Description

    A dependency is temporarily unavailable — e.g. an on-chain channel whose deposit-address pool is momentarily exhausted. Retry shortly.

Common error codes

These are the codes you are most likely to encounter across the Merchant API. Endpoint pages list the codes specific to each operation.

  • Name
    invalid_body
    Type
    400
    Description

    The request body is not valid JSON.

  • Name
    invalid_amount
    Type
    400
    Description

    An amount field is not a valid decimal string.

  • Name
    invalid_filter
    Type
    400
    Description

    A list filter is invalid: a time bound (paid_from / paid_to on GET /api/v1/orders, from / to on GET /api/v1/ledger) is not an RFC 3339 timestamp, or the end of the window is before its start. A filter is never silently ignored.

  • Name
    order_not_found
    Type
    404
    Description

    No order with that id belongs to your account.

  • Name
    idempotency_mismatch
    Type
    409
    Description

    merchant_order_id was already used with a different amount, currency or channel, or with a stored settle_on_received / min_received_amount that differs from the one you sent. Reuse an id only to retry the same request.

  • Name
    order_closed_during_charge
    Type
    409
    Description

    The order expired or was canceled while the payment channel was creating its payment (usually only when expires_in_seconds is shorter than the channel's response time). Any channel and presentation. The order stays closed and you receive its order.expired or order.canceled exactly once, with no order.created. No checkout link, client secret or deposit address is handed out: retrying with the same merchant_order_id returns the closed order with an instruction of type none. Its payment.channel_ref is kept for reconciliation; for an on-chain order that is the address the order was assigned, which a deposit no longer pays, so never show it to the payer. Create a new charge with a new merchant_order_id.

  • Name
    amount_not_above_fee
    Type
    400
    Description

    The platform fee for this channel would consume the whole amount; a direct-settlement charge must leave a positive net for you.

  • Name
    invalid_min_received_amount
    Type
    400
    Description

    min_received_amount is not a positive decimal string with at most 18 decimal places, exceeds amount, was sent without settle_on_received: true, or (live charges) is below the channel's minimum charge amount, or pays a higher platform fee rate than amount does (a fixed fee component or a costlier small-amount fee tier). Only an explicit min_received_amount fails this way: an omitted one is defaulted to the lowest value that passes.

  • Name
    settle_on_received_unsupported
    Type
    400
    Description

    settle_on_received was requested on a channel that is not direct-settlement (on-chain), including a network route that resolved to a custodial gateway.

  • Name
    min_received_amount_not_above_fee
    Type
    400
    Description

    The platform fee on amount would consume the whole amount, so a test-mode settle_on_received charge would leave nothing to settle. A live charge fails earlier with amount_not_above_fee.

  • Name
    not_refundable
    Type
    409
    Description

    Only a paid (or partially refunded) order can be refunded.

  • Name
    order_not_cancelable
    Type
    409
    Description

    Only an unpaid (created or pending) order can be canceled; this one is already paid, refunded, expired or failed. Cancelling an order that is already canceled is not an error: it returns the order.

  • Name
    refund_unsupported
    Type
    409
    Description

    The order cannot be refunded through fluxa. On-chain and Stripe Connect orders settle directly to your own account: refund on-chain orders off-platform and Connect orders from your own Stripe Dashboard. An order paid on your own Stripe key gets this only when the key is no longer saved for that environment (or cannot be used): save it again in the portal or refund in your Stripe Dashboard.

  • Name
    refund_charge_mismatch
    Type
    409
    Description

    For a Stripe order: Stripe charged the customer in a different currency or amount than the order (for example with Adaptive Pricing on the account that was charged), so an amount in the order's currency cannot be refunded on that payment. fluxa did not ask Stripe to refund; refund the order in the Stripe Dashboard of the account that was charged (yours for an order paid on your own Stripe key; the platform operator handles an order on the platform's Stripe account).

  • Name
    refund_disputed
    Type
    409
    Description

    Only for an order paid on your own Stripe key: Stripe withdrew funds of the order for a dispute (you received payment.refunded with reason: "dispute"). Those funds count toward the order's refunded amount but not toward Stripe's refund total, so fluxa can no longer reconcile a refund with Stripe and does not refund the order. fluxa did not call Stripe; handle the order in your Stripe Dashboard, and do not retry.

  • Name
    refund_method_unsupported
    Type
    409
    Description

    For a Stripe order: Stripe settled the order with Konbini (or another method without native refunds, such as PromptPay, Boleto or a bank transfer). Stripe refunds those only after emailing the customer for their bank account details; the refund waits in requires_action and fails if the customer does not answer within 45 days, so it is not money fluxa can record as returned. fluxa did not call Stripe; refund the order in the Stripe Dashboard of the account that was charged (yours for an order paid on your own Stripe key; the platform operator handles an order on the platform's Stripe account), where Stripe collects the details and shows the refund's progress, and do not retry. fluxa records that refund, and sends payment.refunded, once the customer has submitted their details and Stripe starts paying it out. PayPay and card payments are refunded through fluxa as usual.

  • Name
    provider_refund_failed
    Type
    502
    Description

    The payment provider did not accept the refund — for an order paid on your own Stripe key, Stripe refused it (for example more than is left on the charge, a disputed charge, or a restricted key without write access to Refunds). No refund exists on Stripe and nothing changed on the order. Fix the cause and retry with a new idempotency key: Stripe answers a reused key with its first answer, failures included, for 24 hours, and refuses a reused key with other parameters (a smaller amount, say). For other orders this 502 does not prove the provider did nothing: check the order or wait for payment.refunded before retrying, and retry with the same key and parameters.

  • Name
    provider_refund_unconfirmed
    Type
    502
    Description

    For a Stripe order: the refund may have been made on Stripe, but fluxa could not confirm its result (the connection dropped, Stripe answered 5xx, an earlier request under the same key exists, the result could not be read, it does not match the order, or Stripe answered that the refund waits for the customer's bank details). fluxa has not recorded it; if Stripe did refund, Stripe's refund events update the order and send payment.refunded once the refund is paying out. Do not retry with a new idempotency key, which can refund again: check the order or your Stripe Dashboard first, and retry only with the same key and the same parameters, which replays Stripe's first answer.

  • Name
    no_deposit_address
    Type
    503
    Description

    No deposit address is available for an on-chain charge right now — the channel's receiving-address pool is empty or exhausted. Retry shortly.

  • Name
    unknown_channel
    Type
    400
    Description

    The channel code is not enabled for your account.

  • Name
    channel_or_network_required
    Type
    400
    Description

    A charge needs either an explicit channel or a network (with currency) for routing.

  • Name
    no_route
    Type
    400
    Description

    No enabled channel collects the requested (network, currency) pair.

  • Name
    pay_currency_mismatch
    Type
    400
    Description

    On a routed charge, metadata.pay_currency contradicts the requested network — drop one of the two.

  • Name
    settlement_address_required
    Type
    400
    Description

    A live direct-settlement charge needs your settlement address for the order's chain kind configured first. See Account.

  • Name
    payment_mode_disabled
    Type
    403
    Description

    The channel's settlement mode is disabled for your account. Contact the platform operator.

  • Name
    channel_not_supported
    Type
    400
    Description

    The channel cannot be used this way. Naming the platform's Stripe Connect channel or your own-key Stripe channel directly returns this code: pass stripe instead, and a linked Stripe account or your saved Stripe key is used automatically.

  • Name
    stripe_account_not_ready
    Type
    409
    Description

    Your linked Stripe account cannot accept charges yet (Stripe has not enabled charges on it). Finish the account setup in your Stripe Dashboard.

  • Name
    stripe_connect_inactive
    Type
    409
    Description

    Your Stripe charges are linked to your own Stripe account, but that link is currently disabled or disconnected. The charge is refused rather than falling back to the platform's custodial Stripe. Contact the platform operator.

  • Name
    stripe_connect_unavailable
    Type
    503
    Description

    Your Stripe account is linked, but the platform's Stripe Connect channel is unavailable right now. Retry later or contact the platform operator.

  • Name
    stripe_account_changed_during_charge
    Type
    409
    Description

    The charge was routed to your own Stripe key, and you removed that key or switched it to another Stripe account while the charge was being created. The order is failed before anything is created on Stripe, so nothing payable is handed out and you receive no order.created; retrying with the same merchant_order_id returns the failed order with an instruction of type none. Create a new charge with a new merchant_order_id.

  • Name
    stripe_account_unavailable
    Type
    503
    Description

    Your own Stripe key is saved for this environment, but the account cannot be used right now. The charge is refused rather than falling back to the platform's custodial Stripe. Check the keys in the portal or contact the platform operator. It is also returned for up to about 30 seconds right after you switch to another Stripe account, while some servers still hold the previous account's keys (retry shortly).

  • Name
    invalid_secret_key
    Type
    400
    Description

    Saving your own Stripe key in the portal: the key is not a secret key (sk_) or restricted key (rk_) for this environment, or Stripe rejected it. A restricted key needs write access to Checkout Sessions and PaymentIntents and read access to Charges, Refunds and Account (plus write access to Refunds to refund through fluxa).

  • Name
    invalid_webhook_secret
    Type
    400
    Description

    Saving your own Stripe key in the portal: the webhook secret is not the endpoint's signing secret (whsec_...).

  • Name
    stripe_connect_linked
    Type
    409
    Description

    Saving your own Stripe key in the portal: your Stripe account is already linked by the platform through Stripe Connect in this environment, and that link takes precedence. Ask the platform operator to unlink it first.

  • Name
    stripe_unavailable
    Type
    502
    Description

    Saving your own Stripe key in the portal: fluxa could not reach Stripe to check the key. Try again.

  • Name
    exceeds_custodial_balance
    Type
    409
    Description

    The payout amount exceeds the custodial (withdrawable) part of the balance; proceeds of direct-settled orders are never withdrawable.

Handling errors

Check the HTTP status first, then read error.code to decide what to do. Retry 5xx and 429 with backoff; treat 4xx (other than 429) as a request you must fix before retrying.

Node.js

const res = await pgFetch('POST', '/api/v1/orders/ord_2Zx9/refund', {
  amount: '10.00',
})

if (!res.ok) {
  const { error } = await res.json()
  switch (error.code) {
    case 'not_refundable':
      // order is not in a refundable state
      break
    case 'refund_unsupported':
      // on-chain or Stripe Connect order, or a removed own Stripe key — refund elsewhere
      break
    default:
      throw new Error(`${res.status} ${error.code}: ${error.message}`)
  }
}