> For the complete documentation index, see [llms.txt](https://docs.peach.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peach.ag/api-reference/readme/build-swap-calldata.md).

# Swap Allowance

Return a quote, routes and executable transaction in one Allowance request.

## Swap Allowance

> Return a quote, selected paths and a signed executePlan transaction in one request. SDK method: \`swapAllowance()\`. The payer must equal the executor; payer and recipient default to executor. Use \`by\_amount\_in=true\` for the documented exact-input flow. No separate quote request is required. This endpoint builds the transaction without broadcasting it.\
> \
> Compatibility alias: \`/router/swap\`. Production deployment of the new endpoint has not been verified.

```json
{"openapi":"3.0.3","info":{"title":"BSC Aggregator HTTP API","version":"2026-10-20"},"tags":[{"name":"BSC Aggregator HTTP API","description":"Allowance: one request for a quote and executable transaction. Permit2: prepare, payer signing, then build. No prior find_routes request is required."}],"servers":[{"url":"https://api.peach.ag","description":"BSC production API (chain ID 56); operation availability follows deployment."}],"paths":{"/router/swap/allowance":{"get":{"operationId":"swapAllowance","tags":["BSC Aggregator HTTP API"],"summary":"Swap Allowance","description":"Return a quote, selected paths and a signed executePlan transaction in one request. SDK method: `swapAllowance()`. The payer must equal the executor; payer and recipient default to executor. Use `by_amount_in=true` for the documented exact-input flow. No separate quote request is required. This endpoint builds the transaction without broadcasting it.\n\nCompatibility alias: `/router/swap`. Production deployment of the new endpoint has not been verified.","parameters":[{"name":"from","in":"query","required":true,"description":"Input ERC20 token address. Use WBNB for native BNB routing.","schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"}},{"name":"target","in":"query","required":true,"description":"Output ERC20 token address; must differ from from. Use WBNB for native BNB routing.","schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"}},{"name":"amount","in":"query","required":true,"description":"Positive unsigned integer, at most 2^128 - 1, in input-token base units for the documented exact-input flow. Send decimal digits, never a human-readable fractional amount.","schema":{"type":"string","pattern":"^[0-9]+$"}},{"name":"by_amount_in","in":"query","required":false,"description":"Use true for the documented exact-input v7 workflow. Omission defaults to true. A legacy false flag can be parsed by the server but does not establish supported exact-output behavior.","schema":{"type":"boolean","enum":[true],"default":true}},{"name":"depth","in":"query","required":false,"description":"Maximum route hops. Omission or 0 uses the service routing configuration; values above its maximum are rejected.","schema":{"type":"integer","minimum":0}},{"name":"split_count","in":"query","required":false,"description":"Requested split count. Omission or 0 uses the configured maximum; the service can reduce it for trade size and metadata availability.","schema":{"type":"integer","minimum":0}},{"name":"providers","in":"query","required":false,"description":"Comma-separated provider identifiers from Get Status. Omit to use the enabled provider set; availability and version filters still apply.","schema":{"type":"string"}},{"name":"v","in":"query","required":false,"description":"Accepted for routing compatibility; swap endpoints do not apply the find_routes minimum-version gate.","schema":{"type":"integer","minimum":0}},{"name":"gas","in":"query","required":false,"description":"Optional gas limit override. Prefer the service estimate unless you have measured the complete execution path.","schema":{"type":"integer","minimum":0}},{"name":"cal_path_limit","in":"query","required":false,"description":"Optional advanced path-calculation limit; behavior follows the service routing configuration.","schema":{"type":"integer","minimum":0}},{"name":"executor","in":"query","required":false,"description":"Transaction sender signed into the plan. executor or its compatibility alias sender is required. Submit the returned transaction from this address. Must be nonzero and differ from the execution router.","schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"}},{"name":"sender","in":"query","required":false,"description":"Compatibility alias for executor. Prefer executor and send only one of the two fields. Must be nonzero and differ from the execution router.","schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"}},{"name":"payer","in":"query","required":false,"description":"Token owner. Omit to use executor; Direct Allowance requires payer=executor. Must be nonzero and differ from the execution router.","schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"}},{"name":"recipient","in":"query","required":false,"description":"Output recipient; defaults to executor. Must be nonzero and differ from the execution router.","schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"}},{"name":"custom_fee_bps","in":"query","required":false,"description":"Custom fee deducted from gross output, in basis points (100 bps=1%). Omission/0 means no fee. Must not exceed peach_router.max_custom_fee_bps from Get Status. Fees require by_amount_in=true.","schema":{"type":"integer","minimum":0,"maximum":65535}},{"name":"custom_fee_receiver","in":"query","required":false,"description":"Required when custom_fee_bps>0. Must be nonzero and differ from the execution router and recipient. For native BNB output use a recipient able to receive BNB; the service rejects contract fee receivers when its optional code check identifies one.","schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"}},{"name":"slippage_bps","in":"query","required":false,"description":"Slippage applied to expected net output after the custom fee: floor(expect_amount_out*(10000-slippage_bps)/10000). Omission uses service configuration (code fallback 50 bps=0.5%).","schema":{"type":"integer","minimum":0,"maximum":9999}},{"name":"deadline_secs","in":"query","required":false,"description":"Expiry offset in seconds. Omission uses service configuration (code fallback 120). Supply a positive value so the plan remains usable.","schema":{"type":"integer","minimum":0}},{"name":"native_in","in":"query","required":false,"description":"Set true only for native BNB input and pass WBNB as from. Returned tx.value is the BNB input amount in wei.","schema":{"type":"boolean","default":false}},{"name":"native_out","in":"query","required":false,"description":"Set true for native BNB output and pass WBNB as target. Cannot be combined with native_in=true.","schema":{"type":"boolean","default":false}},{"name":"apikey","in":"query","required":false,"schema":{"type":"string"},"description":"Optional pool-visibility key. Only a server-whitelisted key includes paths[].pool. Missing or invalid keys omit pool without blocking transaction construction. Not forwarded to the routing engine."}],"responses":{"200":{"description":"Application success (code=200) or application error (code!=200). Business errors may still have HTTP status 200; inspect the JSON code.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/SwapResponse"},{"$ref":"#/components/schemas/Error"}]}}},"headers":{"Cache-Control":{"description":"Do not cache execution responses.","schema":{"type":"string"}}}},"400":{"description":"Malformed query or request rejected by HTTP extraction. Body may be plain text rather than an application envelope.","content":{"text/plain":{"schema":{"type":"string"}}}},"500":{"description":"Unhandled service failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Service-wide rate limit / circuit breaking. Retry with backoff.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"SwapResponse":{"type":"object","properties":{"code":{"type":"integer","enum":[200]},"msg":{"type":"string"},"data":{"$ref":"#/components/schemas/SwapData"}},"required":["code","msg","data"]},"SwapData":{"type":"object","properties":{"request_id":{"type":"string"},"quote_id":{"type":"string","pattern":"^0x[0-9a-fA-F]{64}$"},"quote_ts":{"type":"integer","minimum":0,"description":"Unix milliseconds."},"amount_in":{"type":"string","pattern":"^[0-9]+$","description":"Gross input amount."},"amount_out":{"type":"string","pattern":"^[0-9]+$","description":"Gross output before custom fees."},"expect_amount_out":{"type":"string","pattern":"^[0-9]+$","description":"Expected net output after custom fees, before slippage."},"custom_fee_bps":{"type":"integer","minimum":0},"custom_fee_amount":{"type":"string","pattern":"^[0-9]+$","description":"Total custom fee in output-token base units."},"integrator_fee_amount":{"type":"string","pattern":"^[0-9]+$","description":"Integrator share of the custom fee."},"protocol_fee_amount":{"type":"string","pattern":"^[0-9]+$","description":"Protocol share of the custom fee."},"custom_fee_receiver":{"type":"string","description":"Encoded fee receiver; empty when no fee is charged."},"protocol_cut_bps":{"type":"integer","minimum":0},"deviation_ratio":{"type":"string"},"deviation_skip_reason":{"type":"string"},"contracts":{"$ref":"#/components/schemas/Contracts"},"gas":{"type":"integer","minimum":0},"execution_mode":{"type":"string","enum":["DIRECT_ALLOWANCE"]},"execution_status":{"type":"string","enum":["TRANSACTION_READY"]},"plan_hash":{"type":"string","pattern":"^0x[0-9a-fA-F]{64}$"},"aggregator_signature":{"type":"string","pattern":"^0x(?:[0-9a-fA-F]{2})*$"},"aggregator_signer":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"20-byte EVM address, prefixed with 0x."},"payer":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"20-byte EVM address, prefixed with 0x."},"executor":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"20-byte EVM address, prefixed with 0x."},"recipient":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"20-byte EVM address, prefixed with 0x."},"tx":{"$ref":"#/components/schemas/ExecutionTransaction"},"paths":{"type":"array","items":{"$ref":"#/components/schemas/SwapRoutePath"},"description":"Selected display paths. A missing pool does not affect the signed transaction."}},"required":["request_id","quote_id","quote_ts","amount_in","amount_out","expect_amount_out","custom_fee_bps","custom_fee_amount","integrator_fee_amount","protocol_fee_amount","custom_fee_receiver","protocol_cut_bps","deviation_ratio","paths","contracts","gas","execution_mode","execution_status","plan_hash","aggregator_signature","aggregator_signer","tx"],"description":"Direct transaction response with selected display paths. Roles are present on successful role-aware requests. Path pool identifiers are included only for a server-whitelisted apikey. Display paths are not used to rebuild the signed transaction."},"Contracts":{"type":"object","properties":{"router":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"Legacy PeachRouter proxy. Do not choose this as the transaction target for the new swap flow."},"execution_router":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"ExecutionPlan router; returned tx.to is the transaction target."}},"required":["router","execution_router"]},"ExecutionTransaction":{"type":"object","properties":{"to":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"PeachExecutionRouter target. Use this returned address with the returned calldata."},"data":{"type":"string","pattern":"^0x(?:[0-9a-fA-F]{2})*$","description":"Signed executePlan calldata. Preserve it unchanged."},"value":{"type":"string","pattern":"^[0-9]+$","description":"Native BNB value to attach, in wei. Zero for ERC20 input; nonzero only for native input."},"entrypoint":{"type":"string","enum":["executePlan"]},"amount_out_min":{"type":"string","pattern":"^[0-9]+$","description":"Minimum net output encoded in the signed plan, in output-token base units."}},"required":["to","data","value","entrypoint","amount_out_min"]},"SwapRoutePath":{"type":"object","properties":{"pool":{"type":"string","description":"Provider-native pool address or bytes32 pool ID for singleton venues. Only included for a server-whitelisted apikey; omitted otherwise."},"provider":{"type":"string","description":"Open provider identifier, such as PANCAKEV3."},"adapter":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"20-byte EVM address, prefixed with 0x."},"token_in":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"20-byte EVM address, prefixed with 0x."},"token_out":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"20-byte EVM address, prefixed with 0x."},"direction":{"type":"boolean","description":"true for token0 to token1."},"fee_rate":{"type":"string","description":"Decimal fee rate; 0.0005 means 0.05%."},"amount_in":{"type":"string","pattern":"^[0-9]+$","description":"Step input amount in input-token base units."},"amount_out":{"type":"string","pattern":"^[0-9]+$","description":"Step output amount in output-token base units."},"extra_data":{"type":"string","pattern":"^0x(?:[0-9a-fA-F]{2})*$"}},"required":["provider","adapter","token_in","token_out","direction","fee_rate","amount_in","amount_out"]},"Error":{"type":"object","properties":{"code":{"type":"integer","minimum":0,"maximum":65535,"not":{"enum":[200]},"description":"Application result code, distinct from HTTP status. See Error Codes."},"msg":{"type":"string","description":"Human-readable explanation."}},"required":["code","msg"],"description":"Application errors omit data. Business errors normally use HTTP 200; check code==200 before consuming data."}}}}
```

### Integration notes

`payer` must equal `executor`; payer and recipient default to executor. ERC20 input requires allowance to returned `tx.to`. Native BNB input uses WBNB in `from`, `native_in=true` and returned `tx.value`.

Review roles, chain, token addresses, `expect_amount_out` (net), `tx.amount_out_min`, fees and deadline, then submit the unchanged transaction as executor. This endpoint does not broadcast. Use `by_amount_in=true` for exact input.

Check both the HTTP status and JSON `code`; a business error may use HTTP 200. See [Error Codes](https://docs.peach.ag/api-reference/readme/error-codes) for recovery guidance. Invalid query or body extraction may return plain text instead of the JSON envelope.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.peach.ag/api-reference/readme/build-swap-calldata.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
