> 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-delegated-swap.md).

# Swap Permit2 Build

Build the final Permit2 transaction from a prepared plan and payer signature.

## Swap Permit2 Build

> Attach a payer signature to an unexpired prepared plan and return its executable transaction. This is the second Permit2 request; SDK method: \`swapPermit2Build()\`. The saved route and roles are preserved without requoting. Send the signature only in the JSON body. Building does not broadcast the transaction.\
> \
> Compatibility alias: \`/router/swap/build\`. 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/permit2/build":{"post":{"operationId":"swapPermit2Build","tags":["BSC Aggregator HTTP API"],"summary":"Swap Permit2 Build","description":"Attach a payer signature to an unexpired prepared plan and return its executable transaction. This is the second Permit2 request; SDK method: `swapPermit2Build()`. The saved route and roles are preserved without requoting. Send the signature only in the JSON body. Building does not broadcast the transaction.\n\nCompatibility alias: `/router/swap/build`. Production deployment of the new endpoint has not been verified.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BuildDelegatedRequest"}}},"description":"JSON body limited to 4 KiB by the service. Send quote_id and payer_signature only."},"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/BuildDelegatedResponse"},{"$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"}}}},"413":{"description":"Build request body exceeds the 4 KiB service limit."},"415":{"description":"Unsupported Content-Type. Send application/json."},"422":{"description":"Invalid JSON body or field types; extractor response may be plain text."},"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":{"BuildDelegatedRequest":{"type":"object","properties":{"quote_id":{"type":"string","pattern":"^0x[0-9a-fA-F]{64}$","description":"Quote ID returned by delegated preparation."},"payer_signature":{"type":"string","pattern":"^0x(?:[0-9a-fA-F]{128}|[0-9a-fA-F]{130})$","description":"Payer signature over the returned Permit2 witness typed_data. 64-byte compact or 65-byte ECDSA. Send only in the JSON body."}},"required":["quote_id","payer_signature"]},"BuildDelegatedResponse":{"type":"object","properties":{"code":{"type":"integer","enum":[200]},"msg":{"type":"string"},"data":{"$ref":"#/components/schemas/BuildDelegatedData"}},"required":["code","msg","data"]},"BuildDelegatedData":{"type":"object","properties":{"quote_id":{"type":"string","pattern":"^0x[0-9a-fA-F]{64}$"},"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."},"plan_hash":{"type":"string","pattern":"^0x[0-9a-fA-F]{64}$"},"execution_mode":{"type":"string","enum":["PERMIT2_WITNESS"]},"execution_status":{"type":"string","enum":["TRANSACTION_READY"]},"gas":{"type":"integer","minimum":0},"tx":{"$ref":"#/components/schemas/ExecutionTransaction"}},"required":["quote_id","payer","executor","recipient","plan_hash","execution_mode","execution_status","gas","tx"],"description":"Adds the payer signature to the stored signed plan without recomputing the route. Submit as executor before expiry; successful build does not broadcast or confirm a transaction."},"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"]},"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

Send a 64-byte compact or 65-byte ECDSA signature only in the JSON body. On-chain execution verifies authorization. Review the built terms and submit the returned transaction as executor before its deadline; build does not broadcast.

Expired artifacts or exceeded build-attempt limits require fresh preparation and a new signature.

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-delegated-swap.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.
