Guides
Errors and retries
Errors come with an HTTP status and a JSON body:
{ "error": { "code": "invalid_authorization", "message": "invalid authorization: chain 1, expected 11155111" } }code is stable: branch on it. message is for people and may change. Some codes carry details, what you may act
on besides the code: the cause of a token’s refusal, the category and public_note of a blocked token.
{ "error": { "code": "sweep_incompatible", "message": "our sweep cannot move this token: …", "details": { "cause": "tx_origin" } } }| Status | code | Meaning | What to do |
|---|---|---|---|
| 400 | invalid_json | The body is not JSON, has unknown fields, or is over 64 KiB (256 KiB for a sweep list). | Fix the request. |
| 400 | invalid_query | A query parameter of a list is not valid; message says which. | Fix the parameter. |
| 401 | unauthorized | No API key, an unknown one or a revoked one. | Check the key and the environment: a test key works only on the testnet API. |
| 403 | partner_disabled | Your account is disabled. | Contact support. |
| 404 | not_found | No such sweep, sweep list, revocation or token of yours, or no webhook set; for a new sweep list, lists are not available on the chain. | Check the id or the address. |
| 409 | hot_wallet_not_active | The hot wallet’s delegate is still being deployed, or its deployment failed. | Wait for hot_wallet.active; after failed, repeat POST /v1/hot-wallets. |
| 409 | external_id_conflict | Some external_id of a sweep list belong to other sweeps, or come on another chain or with other items; details.items names them. Nothing is created. | Leave out your earlier sweeps of the same deposits; to try an item again, give it a new external_id. See Sweep lists. |
| 409, 422 | invalid_items | Items of a sweep list are invalid: details.items has each one’s index, code and message, duplicate_external_id for an id that comes twice. 409 when every one is hot_wallet_not_active. Nothing is created. | Fix the items and send the list again. |
| 409 | too_many_tokens | You have 100 tokens of your own on this chain. | Remove one with DELETE /v1/tokens/{chain_id}/{address}. |
| 409, 422 | token_needs_support | The token was turned off after 5 sweeps in a row failed because of it: 409 when you add it, 422 for a sweep. | Contact support: only support turns it on again. |
| 422 | unknown_chain | The chain is not supported in this environment. | Use a chain of the environment. |
| 422 | unknown_hot_wallet | The hot wallet is not registered on this chain. | Register it with POST /v1/hot-wallets. |
| 422 | unknown_token | The token is neither a base token of this chain nor one you added, or you named a token of your own by its symbol. | Use native, a listed ticker or address, or the address of a token you added; or add the token with POST /v1/tokens. |
| 422 | token_disabled | You turned the base token off. | POST /v1/tokens turns it on again. |
| 422 | token_refused | Portuna refuses the token. | See its reason in GET /v1/tokens and Tokens. |
| 422 | token_blocked | Portuna blocked the token: nobody can sweep it. details.category and details.public_note say why. | Do not accept the token. |
| 422 | confirmation_required | A token of your own is added only with confirm: true. | Check the token, compare its card with the issuer’s, then send confirm: true. |
| 422 | not_a_contract, delegated_account, own_contract, invalid_decimals, balance_not_stored, no_transfer_event, sweep_incompatible | The token you check or add failed a check: no code at the address, an account delegated with EIP-7702, a contract of Portuna Sweep, decimals() failing or above 36, a fake balance, no Transfer event, or a token your sweep cannot move (details.cause). All but the first three block the token for every account. | Check the address: see the checks. |
| 422 | transfer_fails | The token refuses transfers now; details.cause is its reason. | Check it again later. |
| 422 | invalid_address | An address is not a non-zero 0x-address. | Fix the address. |
| 422 | invalid_amount | An amount is not a positive integer in the smallest units. | Send a string of digits, or leave amount out to sweep everything. |
| 422 | invalid_external_id | external_id is longer than 128 characters. | Use a shorter id. |
| 422 | invalid_authorization | The authorization is for another chain or delegate, is not signed by the deposit address, or its signature is invalid. | See below. |
| 422 | invalid_url | The webhook URL is not a public https URL. | Use a public https URL. |
| 422 | invalid_items_count | A sweep list has no items, or more than the chain’s batch size, details.max. | Send up to details.max items in a list. |
| 422 | invalid_wait | wait of a sweep list is not a whole number from 0 to 55. | Send seconds from 0 to 55, or leave it out. |
| 422 | gas_limit_exceeded | A sweep list needs more gas than one transaction may use; details.max_items of its first items fit. | Send those, and the rest as another list. |
| 429 | rate_limited | Too many checks of tokens, or requests for sweep lists, on your account. | Ask again after the seconds of Retry-After. |
| 429 | too_many_lists | 10 of your sweep lists are open on the chain, queued or on their way. | Ask again after the seconds of Retry-After. |
| 500 | internal | Something failed on our side. | Retry later with the same external_id. |
| 503 | chain_unavailable | The chain’s node did not respond to the check of a token you check or add. | Retry later. |
| 503 | token_check_unavailable | Tokens cannot be added on this chain for now. | Retry later, or contact support. |
A disabled account keeps what it already sent on chain: those transactions are seen through. Queued sweeps, revocations and deployments wait, and continue once the account is enabled again. Webhooks keep coming.
invalid_authorization
Section titled “invalid_authorization”message starts with | Cause |
|---|---|
invalid authorization: chain … | Signed for another chain, or for chain 0. |
invalid authorization: delegates to … | Signed for something other than this hot wallet’s delegate (for a revocation: other than the zero address). |
invalid authorization: signature … | A high s, or r or s out of range. |
signed by … | Another key signed: a wrong key, a wrong y_parity or a wrong digest. |
authorization is required … | A revocation came without its authorization. |
| anything else | A malformed field: address, y_parity, r or s. |
More in Signing authorizations.
Outcomes are not errors
Section titled “Outcomes are not errors”A request that is accepted can still end badly: a sweep rejected before sending or failed on chain, with a
reason, or a hot wallet whose delegate was not deployed, with an error. Those come in webhooks and in
GET /v1/sweeps/{id}. Like code, they are stable codes, such as not_upgraded or insufficient_gas_balance, and
never the node’s own messages: every one is in Statuses, confirmations and reorgs.
Retries
Section titled “Retries”- Retry network errors, timeouts and
5xx, with a growing pause, and with the sameexternal_idso that a sweep is never queued twice: see Idempotency. - Do not retry
4xxas they are: the same request gets the same response. The exceptions pass later:409 hot_wallet_not_activeonce the delegate is deployed,422 transfer_failsonce the token allows transfers again, and429after the seconds ofRetry-After.
In the SDKs
Section titled “In the SDKs”API errors are *portuna.Error with StatusCode, Code, Message and Details, and Cause() gives
details.cause; with a 429 or a 503, RetryAfter is how long Retry-After asks to wait. portuna.ErrorCode(err)
gives the code, or "" for other errors such as a network failure. The token codes are constants:
portuna.CodeTokenBlocked and the like.
_, _, err := client.CreateSweep(ctx, req)switch portuna.ErrorCode(err) {case "": if err != nil { // network error or timeout: retry with the same ExternalID }case "invalid_authorization": // sign againcase "hot_wallet_not_active": // wait for hot_wallet.activedefault: // fix the request}API errors are ApiError with status, code, message and details, and with a 429 or a 503, retryAfter,
the seconds of Retry-After. Other errors, such as a network failure, are not.
import { ApiError } from '@portuna/sdk'
try { await client.createSweep(request)} catch (err) { if (err instanceof ApiError && err.code === 'invalid_authorization') { // sign again } else if (!(err instanceof ApiError) || err.status >= 500) { // retry with the same external_id } else { throw err }}