For the complete documentation index, see llms.txt. This page is also available as Markdown.

Error Codes

Handle HTTP failures and application error codes returned by the BSC Aggregator.

Check the HTTP status first, then the JSON code when an application response is available. Only code: 200 indicates success. A business error can use HTTP status 200, with data omitted:

{
  "code": 4000,
  "msg": "Amount cannot be zero"
}

Application codes

Code
Meaning
Action

200

Success

Consume data after validating the response

4000

Invalid request

Check token pair, amount, version, roles, fee settings and expiry

4030

Request forbidden

Check the request and applicable service restrictions

4040

Target token identified as a honeypot

Stop the swap and show the service explanation

5000

Internal application error

Retry with backoff; retain diagnostic information

5010

No route or insufficient liquidity

Adjust the amount or token pair, or retry later

5030

Application unavailable

Retry with backoff; the builder or execution configuration may be unavailable

5040

Unsupported API version

Check the client v parameter

400

Generic application failure

Read msg; do not assume it is an HTTP status

Messages describe the particular failure and are not a stable enumeration. For example, find_routes rejects a missing or too-small v with 4000; it does not necessarily use 5040 for that check.

HTTP failures

HTTP status
Meaning
Action

400

Malformed query or request extraction failure

Fix the request; the response may be plain text

413

Build request exceeds the 4 KiB body limit

Send only quote_id and payer_signature in the JSON body

415

Unsupported request content type

Send /router/swap/permit2/build with Content-Type: application/json

422

Invalid JSON body or field types

Check the build request body; the response may be plain text

500

Unhandled service failure

Retry with backoff; the application envelope may contain code: 500

503

Service rate limit or circuit breaking

Retry with backoff; the application envelope contains code: 503

Gateways and network failures may return other statuses or non-JSON bodies. Check the content type before parsing JSON and preserve the HTTP status for diagnostics.

Delegated preparation and build

Preparation requires distinct payer and executor addresses, an explicit recipient, ERC20 input and a deadline within the service limit. Build requires a valid bytes32 quote_id and a 64-byte compact or 65-byte ECDSA payer_signature in the JSON body.

An expired or missing artifact, or an exceeded per-quote build-attempt limit, requires a new preparation and payer signature. Build accepts signature bytes for calldata construction; successful build does not establish on-chain authorization or successful execution.

Never put payer_signature in URLs, logs or support messages. For diagnosis, retain the endpoint, HTTP status, application code/msg and available request_id or response trace headers.

Last updated

Was this helpful?