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

Swap Permit2 Build

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

Swap Permit2 Build

post

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.

Body
quote_idstringRequired

Quote ID returned by delegated preparation.

Pattern: ^0x[0-9a-fA-F]{64}$
payer_signaturestringRequired

Payer signature over the returned Permit2 witness typed_data. 64-byte compact or 65-byte ECDSA. Send only in the JSON body.

Pattern: ^0x(?:[0-9a-fA-F]{128}|[0-9a-fA-F]{130})$
Responses
200

Application success (code=200) or application error (code!=200). Business errors may still have HTTP status 200; inspect the JSON code.

application/json
Responseone of
or
post/router/swap/permit2/build
cURL
# Use QUOTE_ID from the successful prepare response and PAYER_SIGNATURE
# from the payer signature over that response's Permit2 witness typed_data.
# These environment variables are placeholders for actual prepared values.
: "${QUOTE_ID:?Set QUOTE_ID from the prepare response}"
: "${PAYER_SIGNATURE:?Set PAYER_SIGNATURE to the payer witness signature}"
curl --fail-with-body --silent --show-error \
  --request POST 'https://api.peach.ag/router/swap/permit2/build' \
  --header 'Content-Type: application/json' \
  --data "{\"quote_id\":\"$QUOTE_ID\",\"payer_signature\":\"$PAYER_SIGNATURE\"}"
# Do not log the signature. Build does not broadcast the transaction.
{
  "code": 200,
  "msg": "Success",
  "data": {
    "quote_id": "text",
    "payer": "text",
    "executor": "text",
    "recipient": "text",
    "plan_hash": "text",
    "execution_mode": "PERMIT2_WITNESS",
    "execution_status": "TRANSACTION_READY",
    "gas": 1,
    "tx": {
      "to": "text",
      "data": "text",
      "value": "text",
      "entrypoint": "executePlan",
      "amount_out_min": "text"
    }
  }
}

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 for recovery guidance. Invalid query or body extraction may return plain text instead of the JSON envelope.

Last updated

Was this helpful?