Skip to main content
POST
/
trade
/
swap
Create swap transaction
curl --request POST \
  --url https://public-api-v2.bags.fm/api/v1/trade/swap \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "quoteResponse": {
    "requestId": "<string>",
    "contextSlot": 123,
    "inAmount": "<string>",
    "inputMint": "<string>",
    "outAmount": "<string>",
    "outputMint": "<string>",
    "minOutAmount": "<string>",
    "otherAmountThreshold": "<string>",
    "priceImpactPct": "<string>",
    "slippageBps": 123,
    "routePlan": [
      {
        "venue": "<string>",
        "inAmount": "<string>",
        "outAmount": "<string>",
        "inputMint": "<string>",
        "outputMint": "<string>",
        "inputMintDecimals": 123,
        "outputMintDecimals": 123,
        "marketKey": "<string>",
        "data": "<string>"
      }
    ],
    "platformFee": {
      "amount": "<string>",
      "feeBps": 123,
      "feeAccount": "<string>",
      "segmenterFeeAmount": "<string>",
      "segmenterFeePct": 123
    },
    "outTransferFee": "<string>",
    "simulatedComputeUnits": 123
  },
  "userPublicKey": "<string>"
}
'
{
  "success": true,
  "response": {
    "swapTransaction": "<string>",
    "computeUnitLimit": 123,
    "lastValidBlockHeight": 123,
    "prioritizationFeeLamports": 123
  }
}

Authorizations

x-api-key
string
header
required

API key authentication. Provide your API key as the header value.

Body

application/json
quoteResponse
object
required

The quote response from the getQuote endpoint

userPublicKey
string
required

Public key of the user's wallet

Response

Successfully created swap transaction

success
boolean
required
Example:

true

response
object