# Orders Subscription & Events

## Subscribtion Method

#### `subscribe_orders_api`

Subscribe to real-time order updates using your API key.
It also returns all active orders at the time of subscription.

**Request:**


```javascript
{
  "apiKey": "your-api-key-here"
}
```

**Response example:**

It returns an array of all active orders


```javascript
{
   "orders": [
      {
         "order": {
            "autoSellSettings": {
               "enabled": true,
               "strategy": {
                  "profitTargets": [
                     {
                        "multiplier": 1.01,
                        "sellPercentage": 50,
                        "trailingStopLossAfter": 20
                     },
                     {
                        "multiplier": 1.02,
                        "sellPercentage": 30,
                        "trailingStopLossAfter": 30
                     },
                     {
                        "multiplier": 1.03,
                        "sellPercentage": 20,
                        "trailingStopLossAfter": 20
                     },
                     {
                        "multiplier": 1.04,
                        "sellPercentage": 0,
                        "trailingStopLossAfter": 0
                     }
                  ],
                  "stopLossPercentage": 25,
                  "stopLossType": "trailing",
                  "strategyName": "grid"
               }
            },
            "createdAt": "2025-07-25T22:00:47.064Z",
            "errorType": null,
            "executedAt": null,
            "expiresAt": "2025-07-26T02:00:47.062Z",
            "id": 75950,
            "inputAmount": "0.0001",
            "jitoTipInSolana": "0",
            "logicalOperator": "AND",
            "orderStatus": "pending",
            "prioritizationFeeInSolana": "0",
            "slippage": 0,
            "solPriceInUSDAtTimeOfBuying": null,
            "solPriceInUSDAtTimeOfPlacingOrder": "185.1539785",
            "timeoutRetryCount": 0,
            "tokenAddress": "5MWtJ6n3LmgGNTCo8sRpsJCcXgvD9TguWNAdqvkwbonk",
            "tokenPriceInUSDAtTimeOfBuying": null,
            "tokenPriceInUSDAtTimeOfPlacingOrder": "0.000009408065947372651",
            "transactionId": null,
            "userId": 1235,
            "walletAddresses": [
               "55qd4sXuD9sxNuB81zt774Yu1TmCXDRgJtcERtPkQWxt"
            ],
            "weirdErrorRetryCount": 0
         },
         "order_conditions": [
            {
               "conditionType": "price_change",
               "id": 75940,
               "maxValue": "0.000007056049460529488",
               "minValue": "0.0000061152428657922234",
               "orderId": 75950,
               "referenceValue": "0.000009408065947372651"
            }
         ],
         "tokenExtraInfo": {
            "tokenDecimals": 6,
            "tokenImage": "https://ipfs.launchblitz.ai/file/cce750e2-49be-47b2-8884-48c74edcef88.jpg",
            "tokenName": "Rug",
            "tokenSymbol": "RUG",
            "totalSupply": 999631926.011981
         }
      }
   ],
   "timestamp": 1753480850362
}
```

## Order Events

| Event | Description |
|  --- | --- |
| `order_created` | A new order was placed |
| `order_executed` | An order was filled/completed |
| `order_cancelled` | An order was cancelled |
| `order_failed` | An order failed to execute |
| `order_expire` | An order expired |


#### Event Data Structure

[Download Typescript Interfaces](/assets/interfaces.0041f78313d0b18b80c38f92ca1f886e06dafb3855649a1eea8ef3adc88293c0.b6def933.rar)


```javascript
{
  "order": SelectOrder,           // Basic order info
  "timestamp": 1642694400000,
  "type": "create" | "execute" | "cancel" | "fail" | "expire"
}
```