> 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/arc-aggregator/prepare.md).

# Prepare Delegated Swap

## Prepare a delegated swap

> Prepares a delegated swap and returns Permit2 authorization data for the payer to sign. The payer must differ from the executor.

```json
{"openapi":"3.0.3","info":{"title":"Arc Aggregator HTTP API","version":"1.0.0"},"tags":[{"name":"Swap"}],"servers":[{"url":"https://api.peach.ag/arc","description":"Arc Mainnet (chain ID 5042)"}],"paths":{"/router/swap/prepare":{"get":{"operationId":"arcSwapPrepare","tags":["Swap"],"summary":"Prepare a delegated swap","description":"Prepares a delegated swap and returns Permit2 authorization data for the payer to sign. The payer must differ from the executor.","parameters":[{"$ref":"#/components/parameters/From"},{"$ref":"#/components/parameters/Target"},{"$ref":"#/components/parameters/Amount"},{"$ref":"#/components/parameters/Executor"},{"name":"payer","in":"query","required":true,"description":"Input token owner; must differ from executor.","schema":{"$ref":"#/components/schemas/Address"}},{"name":"recipient","in":"query","required":true,"description":"Explicit output receiver; no default in delegated execution.","schema":{"$ref":"#/components/schemas/Address"}},{"$ref":"#/components/parameters/ByAmountIn"},{"$ref":"#/components/parameters/Version"},{"$ref":"#/components/parameters/Depth"},{"$ref":"#/components/parameters/SplitCount"},{"$ref":"#/components/parameters/Providers"},{"$ref":"#/components/parameters/Slippage"},{"$ref":"#/components/parameters/Deadline"},{"$ref":"#/components/parameters/CustomFeeBps"},{"$ref":"#/components/parameters/CustomFeeReceiver"},{"$ref":"#/components/parameters/Gas"},{"$ref":"#/components/parameters/CalPathLimit"},{"$ref":"#/components/parameters/NativeIn"},{"$ref":"#/components/parameters/NativeOut"}],"responses":{"200":{"description":"Prepared quote and payer authorization.","headers":{"Cache-Control":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ApiResponse"},{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PrepareData"}}}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/ServiceInternalError"},"503":{"$ref":"#/components/responses/ServiceCircuitBreaking"}}}}},"components":{"parameters":{"From":{"name":"from","in":"query","required":true,"description":"Input ERC-20 address. For USDC use its ERC-20 interface, 0x3600000000000000000000000000000000000000; native-token sentinels are unsupported.","schema":{"$ref":"#/components/schemas/Address"}},"Target":{"name":"target","in":"query","required":true,"description":"Output ERC-20 address; must differ from from.","schema":{"$ref":"#/components/schemas/Address"}},"Amount":{"name":"amount","in":"query","required":true,"description":"Positive base-unit integer string, at most 340282366920938463463374607431768211455 (u128).","schema":{"type":"string","pattern":"^[0-9]+$"}},"Executor":{"name":"executor","in":"query","required":true,"description":"Final transaction sender. HTTP also accepts sender as an alias; send one name only. Must be non-zero and different from the Execution Router.","schema":{"$ref":"#/components/schemas/Address"}},"ByAmountIn":{"name":"by_amount_in","in":"query","description":"If true, amount is the input; if false, amount is the desired quote output. Execution still uses a fixed input with a minimum output, not an exact-output guarantee. Custom fees require true.","schema":{"type":"boolean","default":true}},"Version":{"name":"v","in":"query","description":"Client version identifier; send 1001500, matching route-preview requests.","schema":{"type":"integer","minimum":0}},"Depth":{"name":"depth","in":"query","description":"Route depth, subject to deployment limits. Omitted or zero uses server configuration.","schema":{"type":"integer","minimum":0}},"SplitCount":{"name":"split_count","in":"query","description":"Requested split count, adjusted by server limits and trade size. Does not equal final execution-step count.","schema":{"type":"integer","minimum":0}},"Providers":{"name":"providers","in":"query","description":"Comma-separated provider IDs from /router/status. Omit for server selection; availability varies by network.","schema":{"type":"string"}},"Slippage":{"name":"slippage_bps","in":"query","description":"Basis points applied to net expect_amount_out after custom fees. Minimum output is floor(expect_amount_out * (10000 - slippage_bps) / 10000). Omitted uses the server default; send explicitly.","schema":{"type":"integer","minimum":0,"maximum":9999}},"Deadline":{"name":"deadline_secs","in":"query","description":"Validity in seconds from construction, not an absolute timestamp. Send a positive value; omitted uses the server default. Delegated plans also enforce the server lifetime cap.","schema":{"type":"integer","minimum":1}},"CustomFeeBps":{"name":"custom_fee_bps","in":"query","description":"Output-token custom fee in basis points, subject to /router/status arc_router.max_custom_fee_bps and on-chain policy. Positive values require by_amount_in=true and custom_fee_receiver.","schema":{"type":"integer","minimum":0,"maximum":10000,"default":0}},"CustomFeeReceiver":{"name":"custom_fee_receiver","in":"query","description":"Required for a positive custom fee; non-zero and different from recipient and the Execution Router.","schema":{"$ref":"#/components/schemas/Address"}},"Gas":{"name":"gas","in":"query","description":"Advanced gas-unit override. Omit for the server's buffered execution estimate; this is not a gas price or a transaction simulation.","schema":{"type":"integer","minimum":0}},"CalPathLimit":{"name":"cal_path_limit","in":"query","description":"Advanced route-search bound. Omit to use server configuration.","schema":{"type":"integer","minimum":0}},"NativeIn":{"name":"native_in","in":"query","description":"Arc supports ERC-20 input only. Omit or send false; true is rejected.","schema":{"type":"boolean","enum":[false],"default":false}},"NativeOut":{"name":"native_out","in":"query","description":"Arc supports ERC-20 output only. Omit or send false; true is rejected.","schema":{"type":"boolean","enum":[false],"default":false}}},"schemas":{"Address":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"ApiResponse":{"type":"object","required":["code","msg"],"description":"Check JSON `code` even on HTTP 200. `200` means success; errors omit `data`. See [Error Codes](https://docs.peach.ag/api-reference/arc-aggregator/error-codes).","properties":{"code":{"type":"integer"},"msg":{"type":"string"}}},"PrepareData":{"type":"object","required":["request_id","quote_id","quote_ts","amount_in","amount_out","expect_amount_out","amount_out_min","payer","executor","recipient","gas","execution_mode","execution_status","plan_hash","aggregator_signature","aggregator_signer","payer_authorization"],"properties":{"request_id":{"type":"string"},"quote_id":{"$ref":"#/components/schemas/Bytes32"},"quote_ts":{"type":"integer","description":"Final quote timestamp in Unix milliseconds."},"amount_in":{"$ref":"#/components/schemas/Amount"},"amount_out":{"$ref":"#/components/schemas/Amount"},"expect_amount_out":{"$ref":"#/components/schemas/Amount"},"amount_out_min":{"$ref":"#/components/schemas/Amount"},"payer":{"$ref":"#/components/schemas/Address"},"executor":{"$ref":"#/components/schemas/Address"},"recipient":{"$ref":"#/components/schemas/Address"},"gas":{"type":"integer","description":"Estimated execution gas units."},"execution_mode":{"type":"string","enum":["PERMIT2_WITNESS"]},"execution_status":{"type":"string","enum":["PAYER_SIGNATURE_REQUIRED"]},"plan_hash":{"$ref":"#/components/schemas/Bytes32"},"aggregator_signature":{"type":"string"},"aggregator_signer":{"$ref":"#/components/schemas/Address"},"payer_authorization":{"type":"object","required":["scheme","owner","permit2","spender","token","amount","nonce","deadline","witness_plan_hash","typed_data"],"properties":{"scheme":{"type":"string","enum":["PERMIT2_WITNESS_TRANSFER"]},"owner":{"$ref":"#/components/schemas/Address"},"permit2":{"type":"string","enum":["0x000000000022d473030f116ddee9f6b43ac78ba3"]},"spender":{"allOf":[{"$ref":"#/components/schemas/Address"}],"description":"Execution Router authorized by the Witness; ERC-20 allowance is granted to Permit2 instead."},"token":{"$ref":"#/components/schemas/Address"},"amount":{"$ref":"#/components/schemas/Amount"},"nonce":{"type":"string","pattern":"^[0-9]+$","description":"One-use uint256 nonce as a decimal string."},"deadline":{"type":"integer","description":"Absolute expiry in Unix seconds."},"witness_plan_hash":{"$ref":"#/components/schemas/Bytes32"},"typed_data":{"type":"object","description":"Complete EIP-712 PermitWitnessTransferFrom payload. Validate and sign this payload unchanged as payer; integer values in the message are decimal strings.","required":["domain","types","primaryType","message"],"properties":{"domain":{"type":"object","description":"Permit2 name, chainId and verifyingContract.","additionalProperties":true},"types":{"type":"object","description":"EIP712Domain, TokenPermissions, ArcExecutionWitness and PermitWitnessTransferFrom definitions.","additionalProperties":true},"primaryType":{"type":"string","enum":["PermitWitnessTransferFrom"]},"message":{"type":"object","description":"permitted token/amount, spender, nonce, deadline and witness.planHash.","additionalProperties":true}}}}}}},"Bytes32":{"type":"string","pattern":"^0x[0-9a-fA-F]{64}$"},"Amount":{"type":"string","pattern":"^[0-9]+$","description":"Decimal integer string in token base units."}},"responses":{"BadRequest":{"description":"Request parsing failed: malformed/missing query parameters or invalid JSON syntax. The body may be plain text; this is HTTP 400, not application code 400.","content":{"text/plain":{"schema":{"type":"string"}}}},"TooManyRequests":{"description":"Rate limit exceeded. Retry with backoff and honor Retry-After when present."},"ServiceInternalError":{"description":"Internal server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"ServiceCircuitBreaking":{"description":"Service rate limit exceeded. Retry with backoff.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}}}
```


---

# 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/arc-aggregator/prepare.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.
