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

# Emergency Exit Position

> Emergency exit from a position, refunding the margin

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.strike.markets/emergency-exit" \
    -H "X-API-Key: stk_your_api_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "positionId": 12345
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.strike.markets/emergency-exit', {
    method: 'POST',
    headers: {
      'X-API-Key': 'stk_your_api_key_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      positionId: 12345
    })
  });

  const data = await response.json();
  console.log('Emergency exit completed:', data);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.strike.markets/emergency-exit',
      headers={
          'X-API-Key': 'stk_your_api_key_here',
          'Content-Type': 'application/json'
      },
      json={
          'positionId': 12345
      }
  )

  data = response.json()
  print('Emergency exit completed:', data)
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "refundedAmount": "100.0"
  }
  ```
</ResponseExample>

## Overview

Perform an emergency exit from a position, immediately returning your original margin without realizing profit or loss. This is a last-resort option that should only be used in exceptional circumstances.

<Warning>
  Emergency exit forfeits any potential profit or loss and should only be used when normal position closure is not possible or during system emergencies.
</Warning>

<Note>
  This endpoint requires authentication with a valid API key. You can only emergency exit positions that belong to your wallet.
</Note>

## Authentication

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

```
X-API-Key: stk_your_api_key_here
```

## Request Body

<ParamField body="positionId" type="integer" required>
  The unique identifier of the position to emergency exit.

  **How to get**: Use [Get Positions](/api-reference/positions/get-positions) to find your position IDs\
  **Example**: 12345
</ParamField>

## Response Fields

<ResponseField name="success" type="boolean">
  Indicates if the emergency exit was completed successfully
</ResponseField>

<ResponseField name="refundedAmount" type="string">
  The original margin amount returned to your account in USD
</ResponseField>

## Error Responses

<ResponseField name="400 Bad Request" type="object">
  Invalid position ID or position cannot be emergency exited

  ```json theme={null}
  {
    "error": 400,
    "message": "Position not found or already closed"
  }
  ```
</ResponseField>

<ResponseField name="401 Unauthorized" type="object">
  Missing or invalid authentication token

  ```json theme={null}
  {
    "error": 401,
    "message": "Authorization header missing"
  }
  ```
</ResponseField>

<ResponseField name="403 Forbidden" type="object">
  Attempting to emergency exit position that doesn't belong to your wallet

  ```json theme={null}
  {
    "error": 403,
    "message": "Position does not belong to authenticated wallet"
  }
  ```
</ResponseField>

<ResponseField name="429 Too Many Requests" type="object">
  Rate limit exceeded (10 requests per minute for trading endpoints)

  ```json theme={null}
  {
    "error": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded. Please wait 45 seconds.",
    "retry_after": 45
  }
  ```
</ResponseField>

## Recovery and Next Steps

After an emergency exit:

1. **Confirm Refund** - Check [Account](/api-reference/account/account-info) for margin refund
2. **Review Dashboard** - Update portfolio view in [Dashboard](/api-reference/account/dashboard)
3. **Assess Markets** - Use [Market Data](/api-reference/market-data/markets) to evaluate conditions
4. **Consider Reentry** - If conditions improve, consider new positions

<Warning>
  Emergency exit is irreversible and forfeits all potential profit. Only use when absolutely necessary.
</Warning>

<Tip>
  Keep emergency exit as a true last resort. In most cases, normal position closure or even waiting out temporary issues is preferable to forfeiting potential gains.
</Tip>


## OpenAPI

````yaml POST /emergency-exit
openapi: 3.1.0
info:
  title: Strike Protocol API
  description: >-
    Strike Protocol is a perpetual futures trading platform that allows users to
    trade with leverage (1-1000x) on various crypto assets. This API provides
    access to trading operations, account management, market data, analytics,
    and user systems.
  version: 1.0.0
  contact:
    name: Strike Protocol
    url: https://strike.markets
  license:
    name: MIT
servers:
  - url: https://api.strike.markets
    description: Production server
security:
  - apiKeyAuth: []
paths:
  /emergency-exit:
    post:
      summary: Emergency Exit Position
      description: Emergency exit from a position, refunding the margin
      operationId: emergencyExitPosition
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmergencyExitRequest'
      responses:
        '200':
          description: Emergency exit completed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  refundedAmount:
                    type: string
                    description: Amount refunded in USD
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized - Invalid or missing authentication token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    EmergencyExitRequest:
      type: object
      required:
        - positionId
      properties:
        positionId:
          type: integer
          description: Position ID for emergency exit
    Error:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Strike Protocol API key authentication

````