Skip to main content

Errors

Error format​

All errors use one format:

{
"type": "validation_error",
"errors": [
{ "code": "min_amount", "detail": "مقدار سفارش کمتر از حداقل مجاز خرید است", "attr": "base_amount" }
]
}
FieldDescription
typevalidation_error (400), client_error (401/403/404/409/429) or server_error (5xx)
errors[].codeStable, English, machine-readable. Base your logic on this only.
errors[].detailHuman message, in Persian. It may change at any time; do not parse it.
errors[].attrThe request field (or query parameter) the error is about; "non_field_errors" for errors about a combination of fields (e.g. amount_conflict); null for errors not tied to a field (auth, insufficient_balance, …)
  • errors can have more than one item (for example several invalid fields).
  • 401 responses carry WWW-Authenticate: X-API-Key, and 429 responses carry Retry-After.

Error code catalog​

HTTPcodeWhen
401not_authenticatedNo X-API-Key header (a JWT alone counts as no key)
401invalid_api_keyUnknown or malformed key
401api_key_revokedKey revoked (by user, admin, or password change/reset)
401api_key_expiredKey past its expiry
401user_inactiveThe key owner's account is deactivated
403ip_not_allowedKey has an IP allow-list and the request IP is not in it
403api_disabledPublic API turned off globally (maintenance)
403api_blockedAPI access blocked for this user by an admin
403kyc_requiredThe user's KYC is no longer valid
403insufficient_scoperead key on a trade endpoint
403trade_blockedTrading blocked for this user
404not_foundUnknown resource, or not visible to this user
409client_id_conflictclient_id reused with a different request
429throttledRate limit exceeded (Rate limits)
400required, null, invalid, invalid_choice, min_value, max_digits, max_whole_digits, max_decimal_placesField input validation, standard codes (attr names the field or parameter)
400amount_required, amount_conflictNeither or both of base_amount / quote_amount sent (attr: "non_field_errors")
400market_inactive, side_disabled, limit_disabledMarket, side or limit trading switched off
400min_amount, max_amountAmount outside market limits
400insufficient_balanceNot enough available balance
400quote_not_foundQuote does not exist, is not yours, or was not created by POST /quotes/
400quote_expiredMore than 30 s since the quote
400quote_usedQuote already used for another order
400quote_kind_mismatchLimit quote sent to /orders/, or spot quote to /limit-orders/
400invalid_target_priceTarget price on the wrong side of the current price (re-checked when the limit order is placed)
400invalid_expires_atLimit-order expiry in the past or beyond the maximum
400order_not_cancellableCancel on a non-active limit order
500order_failedSettlement failed and the whole order was rolled back; nothing was created and no funds moved
503price_unavailableNo reliable price right now, retry shortly
500errorUnexpected server error

Handling tips​

  • Branch on code, not on detail and not only on the HTTP status. New codes may be added; have a default branch for unknown ones.
  • quote_expired / quote_used: get a new quote and try once more, with a new client_id. If quote_expired keeps happening, shorten the time between quote and order.
  • insufficient_balance: no order was created. Do not retry until the wallet is topped up. Read GET /balances/; part of the balance may be locked (locked) in active limit orders.
  • min_amount / max_amount: read limits from GET /markets/ and adjust the amount.
  • market_inactive / side_disabled / limit_disabled / api_disabled: temporary. Check again every few minutes; do not hammer.
  • 401s, ip_not_allowed, insufficient_scope, api_blocked, kyc_required: retrying will not fix these. Stop the bot and alert.
  • order_failed: nothing was created and no funds moved. You can resend the same request while the quote is still valid.
  • Field errors (required, invalid, min_value, …): check attr; retrying without fixing the input will not help.
  • Connection drop or timeout on POST /orders/: you do not know whether the order was created. See safe retries.
try:
order = place_order(...)
except TalanoError as e:
if e.code == "quote_expired":
... # new quote, retry once
elif e.code == "insufficient_balance":
... # stop, alert
elif e.status == 429:
... # sleep Retry-After seconds
else:
raise