> ## Documentation Index
> Fetch the complete documentation index at: https://docs.route.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# Swap with builder attribution

> Quote, prepare, sign and verify.

Run API calls on your backend. Use an API key with `quote`, `swap` and `receipts` scopes.

## 1. Get a quote

```bash theme={null}
curl --get https://api.route.fun/api/v2/builders/quote \
  -H "x-api-key: $ROUTE_API_KEY" \
  --data-urlencode "chainId=4663" \
  --data-urlencode "tokenIn=0x0000000000000000000000000000000000000000" \
  --data-urlencode "tokenOut=0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168" \
  --data-urlencode "amountIn=1000000000000000" \
  --data-urlencode "payer=$WALLET_ADDRESS" \
  --data-urlencode "slippageBps=50"
```

This quotes 0.001 ETH to USDG, attributed to your workspace. Pass `builderCode` to select another registered code. Review the returned net output, minimum, fees and expiry.

## 2. Prepare the transaction

```bash theme={null}
curl https://api.route.fun/api/v2/builders/swap \
  -H "x-api-key: $ROUTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"quoteId\":\"$QUOTE_ID\"}"
```

For ERC-20 input, approve only the returned amount to the named spender. Refresh the quote if approval outlives it. The user reviews and signs the returned transaction; the API does not submit it.

## 3. Verify the result

```bash theme={null}
curl https://api.route.fun/api/v2/builders/receipts \
  -H "x-api-key: $ROUTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"quoteId\":\"$QUOTE_ID\",\"hash\":\"$TRANSACTION_HASH\"}"
```

`confirming` means finality is pending; `finalized` confirms the attributed settlement. Check status before retrying an uncertain submission. Never automatically resend it.
