Skip to main content
POST
https://api.pmx.trade
/
v2
/
markets
/
{slug}
/
trade
/
sell
curl -X POST "https://api.pmx.trade/v2/markets/btc-100k-march/trade/sell" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "wallet": "YourWalletPubkey...",
    "tokenAmount": 20000,
    "side": "YES"
  }'
{
  "success": false,
  "error": {
    "code": "PAYMENT_REQUIRED",
    "message": "Token transfer required to execute sell"
  },
  "payment": {
    "x402Version": 1,
    "tokenMint": "YesTokenMintAddress...",
    "sendTo": "YesOptionWallet...",
    "tokenAmount": 20000,
    "tokenAmountAtomic": 20000000000
  },
  "quote": {
    "side": "YES",
    "tokenAmount": 20000,
    "usdcPayout": 10,
    "targetPrice": 0.0005,
    "issuedAt": "2026-01-15T10:00:00Z",
    "expiresAt": "2026-01-15T10:02:00Z",
    "ttlMs": 120000
  },
  "marketSlug": "btc-100k-march"
}
Selling shares uses a two-step X.402 payment flow where you transfer tokens to the platform:
  1. Step 1: Submit sell request to get token transfer requirements (returns 402)
  2. Step 2: Transfer tokens and submit again with X-PAYMENT header to receive USDC (returns 200)
slug
string
required
The market slug (e.g., btc-100k-march)

Request Body

wallet
string
required
Your Solana wallet address
tokenAmount
number
required
Number of tokens to sell (human-readable, e.g., 20000 for 20,000 tokens)
side
string
required
Side to sell: YES or NO

Step 1: Get Quote

curl -X POST "https://api.pmx.trade/v2/markets/btc-100k-march/trade/sell" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "wallet": "YourWalletPubkey...",
    "tokenAmount": 20000,
    "side": "YES"
  }'
{
  "success": false,
  "error": {
    "code": "PAYMENT_REQUIRED",
    "message": "Token transfer required to execute sell"
  },
  "payment": {
    "x402Version": 1,
    "tokenMint": "YesTokenMintAddress...",
    "sendTo": "YesOptionWallet...",
    "tokenAmount": 20000,
    "tokenAmountAtomic": 20000000000
  },
  "quote": {
    "side": "YES",
    "tokenAmount": 20000,
    "usdcPayout": 10,
    "targetPrice": 0.0005,
    "issuedAt": "2026-01-15T10:00:00Z",
    "expiresAt": "2026-01-15T10:02:00Z",
    "ttlMs": 120000
  },
  "marketSlug": "btc-100k-march"
}

Step 2: Execute Trade

After transferring tokens to the sendTo address:
# Create payment payload
PAYMENT_PAYLOAD=$(echo -n '{
  "x402Version": 1,
  "network": "solana-mainnet",
  "txHash": "YOUR_TOKEN_TX_SIGNATURE",
  "tokenAmount": 20000,
  "sender": "YourWalletPubkey...",
  "recipient": "YesOptionWallet...",
  "tokenMint": "YesTokenMintAddress...",
  "quoteIssuedAt": "2026-01-15T10:00:00Z"
}' | base64)

curl -X POST "https://api.pmx.trade/v2/markets/btc-100k-march/trade/sell" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: $PAYMENT_PAYLOAD" \
  -d '{
    "wallet": "YourWalletPubkey...",
    "tokenAmount": 20000,
    "side": "YES"
  }'
{
  "success": true,
  "data": {
    "slug": "btc-100k-march",
    "action": "sell",
    "side": "YES",
    "tokenAmount": 20000,
    "usdcPayout": 10,
    "tokenTransferTxHash": "YOUR_TOKEN_TX_SIGNATURE",
    "usdcPayoutTxHash": "PLATFORM_USDC_TX_SIGNATURE"
  }
}

Payment Payload Fields (X-PAYMENT header)

The X-PAYMENT header must contain a base64-encoded JSON object:
FieldTypeDescription
x402VersionnumberProtocol version (use 1)
networkstringNetwork identifier (e.g., solana-mainnet)
txHashstringYour token transfer transaction signature
tokenAmountnumberToken amount transferred (human-readable)
senderstringYour wallet address (must match wallet in body)
recipientstringPlatform wallet from quote response
tokenMintstringToken mint address from quote response
quoteIssuedAtstringISO 8601 timestamp from quote response

Payout Calculation

USDC payout is calculated as:
usdcPayout = tokenAmount × targetPrice
For example, with targetPrice = 0.0005:
  • 20,000 tokens → 10 USDC payout
  • 100,000 tokens → 50 USDC payout
Quotes expire after 2 minutes (ttlMs). If your quote expires, request a new one before executing the trade.
The platform automatically sends USDC to your wallet after verifying your token transfer.