---
title: "Start an advanced swap."
method: POST
path: "/swap"
tags: ["Swap"]
---

# Start an advanced swap.

`POST /swap`

## Request

- Base URL: `https://chainflip-broker.io`
- URL: `https://chainflip-broker.io/swap`
- Auth: one of:
  - API key in query parameter `apiKey`
  - API key in header `X-API-Key`

The same as `startSwap`, plus a JSON body for parameters that do not fit in a
query string, such as a Cross-Chain Messaging payload for the destination chain.

## Query parameters

- `apiKey` string
- `sourceAsset` string, required
- `destinationAsset` string, required
- `destinationAddress` string, required
- `commissionBps` integer
- `boostFee` integer
- `minimumPrice` number, double, required
- `refundAddress` string, required
- `retryDurationInBlocks` integer, required
- `livePriceSlippageTolerancePercent` number, double
- `numberOfChunks` integer
- `chunkIntervalBlocks` integer
- `affiliate1` string
- `affiliate1CommissionBps` integer
- `affiliate2` string
- `affiliate2CommissionBps` integer
- `affiliate3` string
- `affiliate3CommissionBps` integer
- `affiliate4` string
- `affiliate4CommissionBps` integer
- `platform` string

## Request body

- ChainflipBaasSwapAdvancedSwapRequest: The parameters of `startAdvancedSwap` that do not fit in a query string.
  - `ccmPayload` ChainflipBaasSwapCcmRequest: Cross-Chain Messaging payload. More details can be found at https://docs.chainflip.io/swapping/integrations/advanced/cross-chain-messaging/cross-chain-messaging
    - `gas_budget` string, required: Gas budget for the call on the destination chain. This amount is based on the source asset and will be subtracted from the input amount and swapped to pay for gas.
    - `message` string, required: Hex-encoded message that is passed to the destination address on the destination chain. The message should be shorter than 10k bytes.

## Response `200`

A deposit address for the given swap.

- ChainflipBaasSwapDepositAddress: The deposit channel opened for the swap. Send the source asset to `address` on `network` before the channel expires at `sourceExpiryBlock`, then follow the swap with `getStatusById` (using `id`) or `getStatusByDepositChannel`.
  - `id` integer, nullable: The BaaS swap id: pass it as `swapId` to `getStatusById`. Absent in the rare case the swap could not be recorded right away; follow it with `getStatusByDepositChannel` then.
  - `address` string, required: The deposit address to send source assets to.
  - `issuedBlock` integer, required: The block in which the deposit address was issued.
  - `network` string, required: The network to send the source assets over.
  - `channelId` integer, required: The channel id to monitor the deposit.
  - `sourceExpiryBlock` integer, required: The block (on the source network) in which the deposit address will expire.
  - `explorerUrl` string, required: The explorer url to monitor the deposit.
  - `channelOpeningFee` number, double, required: Fee in $FLIP to open the deposit channel.
  - `channelOpeningFeeNative` string, required: Fee in $FLIP flipperinos to open the deposit channel.
  - `destinationAddress` string, required: The destination address the swap was accepted for, exactly as you sent it (no change of case, prefix or encoding). Always present.

## Other responses

- `400`: The request has invalid information.
- `401`: The partner does not have access.
- `403`: Swaps between these assets are not enabled for the partner.
- `500`: An error occurred.
- `503`: A temporary upstream condition, such as maintenance, a disabled asset or the network channel cap. Retry with backoff.

---

[API](https://skmtc.dev/chainflip-broker/apis/chainflip-broker-as-a-service.md) · [All operations](https://skmtc.dev/chainflip-broker/apis/chainflip-broker-as-a-service/llms.txt) · [OpenAPI document](https://skmtc.dev/chainflip-broker/apis/chainflip-broker-as-a-service/revisions/3c819d79d6b9?raw)
