Errors
Errors
Every error code the API answers with, what it means and what to do.
Every failed request answers with an RFC 9457 problem,
served as application/problem+json:
{
"type": "https://docs.xebra.exchange/errors/amount_below_minimum",
"title": "Amount below the minimum",
"status": 422,
"detail": "Fees would take more than a tenth of this transfer. Send at least 2.4 USDC to Base.",
"code": "amount_below_minimum",
"minimum": "2.4"
}codeis stable. Branch on it, not ontitleordetail.detailis a sentence written for a person. You can show it to your user as it is.typeis the page for that code, on this site.- Some codes add fields, such as
minimum,maximum,have,need,totalandlimit. Amounts are decimal strings of USDC, like everywhere else in the API.
The SDK throws these as XebraApiError, with the extra fields on err.extra:
import { , } from "@xebra/sdk";
const = ();
try {
await .({ : "stellar", : "base", : "0.5" });
} catch () {
if ( instanceof && . === "amount_below_minimum") {
.(`Send at least ${(..minimum)} USDC.`);
}
}The SDK adds three codes of its own, with status 0, for failures that never reached the API:
network_error, timeout and invalid_response.
All codes
| Code | Status | Title |
|---|---|---|
invalid_request | 400 | Invalid request |
unauthorized | 401 | Unauthorized |
not_found | 404 | Not found |
not_ready | 409 | Not ready |
already_delivered | 409 | Already delivered |
invalid_amount | 422 | Invalid amount |
invalid_recipient | 422 | Invalid recipient |
route_unavailable | 422 | Route unavailable |
amount_below_minimum | 422 | Amount below the minimum |
amount_above_maximum | 422 | Amount above the maximum |
insufficient_balance | 422 | Insufficient balance |
fee_above_limit | 422 | Fee above your limit |
transaction_rejected | 422 | Transaction would be rejected |
rate_limited | 429 | Rate limited |
internal_error | 500 | Internal error |
upstream_unavailable | 503 | Upstream unavailable |