Skip to main content
POST
/
close
curl -X POST "https://api.strike.markets/close" \
  -H "X-API-Key: stk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "positionId": 12345
  }'
{
  "success": true,
  "message": "Position closed successfully",
  "txHash": "0x1234567890abcdef1234567890abcdef12345680",
  "gasUsed": 165000,
  "positionId": 12345,
  "symbol": "BTC-USD",
  "szi": "0.002217",
  "margin": "100.0",
  "entryPrice": "45123.50",
  "exitPrice": "46123.50",
  "realizedPnl": "114.50",
  "pnlFee": "8.75",
  "status": "closed",
  "createdAt": "2024-01-15T14:30:00Z",
  "closedAt": "2024-01-15T15:45:00Z",
  "settledAt": null,
  "spread": "5.25"
}
curl -X POST "https://api.strike.markets/close" \
  -H "X-API-Key: stk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "positionId": 12345
  }'
{
  "success": true,
  "message": "Position closed successfully",
  "txHash": "0x1234567890abcdef1234567890abcdef12345680",
  "gasUsed": 165000,
  "positionId": 12345,
  "symbol": "BTC-USD",
  "szi": "0.002217",
  "margin": "100.0",
  "entryPrice": "45123.50",
  "exitPrice": "46123.50",
  "realizedPnl": "114.50",
  "pnlFee": "8.75",
  "status": "closed",
  "createdAt": "2024-01-15T14:30:00Z",
  "closedAt": "2024-01-15T15:45:00Z",
  "settledAt": null,
  "spread": "5.25"
}

Overview

Manually close an existing position at the current market price. This endpoint allows you to realize profits or cut losses by closing your position immediately.
This endpoint requires authentication with a valid API key. You can only close positions that belong to your wallet.

Authentication

Include your API key in the X-API-Key header:
X-API-Key: stk_your_api_key_here

Request Body

positionId
integer
required
The unique identifier of the position to close.How to get: Use Get Positions to find your position IDs
Example: 12345

Response Fields

success
boolean
Indicates if the position was closed successfully
message
string
Success message describing the operation
txHash
string
Blockchain transaction hash for the position closure
positionId
integer
ID of the closed position
exitPrice
string
Price at which the position was closed
pricePnl
string
PnL from price movement only (excludes funding)
accumulatedFunding
string
Total funding payments received/paid during position lifetime
grossPnl
string
Total PnL including funding (pricePnl + accumulatedFunding)
pnl
string
Net PnL after fees (grossPnl - fee)
fee
string
Total fees charged for closing the position
gasUsed
integer
Gas consumed for the transaction
position
object
Updated position object with closure details

Error Responses

400 Bad Request
object
Invalid position ID or position cannot be closed
{
  "error": 400,
  "message": "Position not found or already closed"
}
401 Unauthorized
object
Missing or invalid authentication token
{
  "error": 401,
  "message": "Authorization header missing"
}
403 Forbidden
object
Attempting to close position that doesn’t belong to your wallet
{
  "error": 403,
  "message": "Position does not belong to authenticated wallet"
}
429 Too Many Requests
object
Rate limit exceeded (10 requests per minute for trading endpoints)
{
  "error": "RATE_LIMIT_EXCEEDED",
  "message": "Rate limit exceeded. Please wait 45 seconds.",
  "retry_after": 45
}

Next Steps

After closing a position:
  1. Check Balance - View updated balance in Account
  2. Review Performance - Analyze trade in Dashboard
  3. Monitor Queue - If queued, check status with Queue Positions
  4. Plan Next Trade - Use Market Data for analysis
Consider market conditions and your overall strategy before closing positions. Sometimes holding through temporary volatility can be more profitable than frequent trading.
Position closure is irreversible. Make sure you want to close the position before submitting the request.

Authorizations

X-API-Key
string
header
required

Strike Protocol API key authentication

Body

application/json
positionId
integer
required

Position ID to close

Response

Position closed successfully

success
boolean
txHash
string
pnl
string
fees
string
netPayout
string