Skip to content

Request access

Tell us about your processing, and we'll reply by email.

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" } } }
StatuscodeMeaningWhat to do
400invalid_jsonThe body is not JSON, has unknown fields, or is over 64 KiB (256 KiB for a sweep list).Fix the request.
400invalid_queryA query parameter of a list is not valid; message says which.Fix the parameter.
401unauthorizedNo API key, an unknown one or a revoked one.Check the key and the environment: a test key works only on the testnet API.
403partner_disabledYour account is disabled.Contact support.
404not_foundNo 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.
409hot_wallet_not_activeThe hot wallet’s delegate is still being deployed, or its deployment failed.Wait for hot_wallet.active; after failed, repeat POST /v1/hot-wallets.
409external_id_conflictSome 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, 422invalid_itemsItems 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.
409too_many_tokensYou have 100 tokens of your own on this chain.Remove one with DELETE /v1/tokens/{chain_id}/{address}.
409, 422token_needs_supportThe 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.
422unknown_chainThe chain is not supported in this environment.Use a chain of the environment.
422unknown_hot_walletThe hot wallet is not registered on this chain.Register it with POST /v1/hot-wallets.
422unknown_tokenThe 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.
422token_disabledYou turned the base token off.POST /v1/tokens turns it on again.
422token_refusedPortuna refuses the token.See its reason in GET /v1/tokens and Tokens.
422token_blockedPortuna blocked the token: nobody can sweep it. details.category and details.public_note say why.Do not accept the token.
422confirmation_requiredA token of your own is added only with confirm: true.Check the token, compare its card with the issuer’s, then send confirm: true.
422not_a_contract, delegated_account, own_contract, invalid_decimals, balance_not_stored, no_transfer_event, sweep_incompatibleThe 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.
422transfer_failsThe token refuses transfers now; details.cause is its reason.Check it again later.
422invalid_addressAn address is not a non-zero 0x-address.Fix the address.
422invalid_amountAn amount is not a positive integer in the smallest units.Send a string of digits, or leave amount out to sweep everything.
422invalid_external_idexternal_id is longer than 128 characters.Use a shorter id.
422invalid_authorizationThe authorization is for another chain or delegate, is not signed by the deposit address, or its signature is invalid.See below.
422invalid_urlThe webhook URL is not a public https URL.Use a public https URL.
422invalid_items_countA sweep list has no items, or more than the chain’s batch size, details.max.Send up to details.max items in a list.
422invalid_waitwait of a sweep list is not a whole number from 0 to 55.Send seconds from 0 to 55, or leave it out.
422gas_limit_exceededA 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.
429rate_limitedToo many checks of tokens, or requests for sweep lists, on your account.Ask again after the seconds of Retry-After.
429too_many_lists10 of your sweep lists are open on the chain, queued or on their way.Ask again after the seconds of Retry-After.
500internalSomething failed on our side.Retry later with the same external_id.
503chain_unavailableThe chain’s node did not respond to the check of a token you check or add.Retry later.
503token_check_unavailableTokens 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.

message starts withCause
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 elseA malformed field: address, y_parity, r or s.

More in Signing authorizations.

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.

  • Retry network errors, timeouts and 5xx, with a growing pause, and with the same external_id so that a sweep is never queued twice: see Idempotency.
  • Do not retry 4xx as they are: the same request gets the same response. The exceptions pass later: 409 hot_wallet_not_active once the delegate is deployed, 422 transfer_fails once the token allows transfers again, and 429 after the seconds of Retry-After.

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 again
case "hot_wallet_not_active":
// wait for hot_wallet.active
default:
// fix the request
}