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

# Create a trading stream token

> Returns a short-lived token for the real-time trading stream of **all** your organization's trading accounts: every order, execution, position change, balance/equity update and rule violation, as it happens. New accounts are included automatically.

The stream is read-only. It accepts no trading commands.

**Connect** to the returned `url` with the token in the `Authorization` header:

```bash
TOKEN=$(curl -s -X POST "https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token" \
  -H "X-API-Key: hp_live_your_key_here" | jq -r .data.token)
websocat -H "Authorization: Bearer $TOKEN" wss://api.hyperprop.com/trade/org/stream
```

The first message is `{"type": "Welcome", "organization_id": ..., "expires_at": ...}`. Then each event arrives as one JSON message with a `type`: `OrderSubmitted`, `OrderFilled` (one per execution, with the `trade`), `OrderCancelled`, `PositionUpdate`, `AccountUpdate` (balance, equity, P&L, drawdown, status), `RuleViolation` and account `Notification`. Every event carries `account_id`. A `Heartbeat` arrives every 15 seconds.

**Token lifetime:** 15 minutes. Before it expires, request a new token and send `{"action": "refresh", "token": "<new token>"}` on the open connection (reply `TokenRefreshed`). Otherwise the connection closes with code `4001` and you reconnect with a new token. A revoked API key can't get new tokens, so its connections end within one token lifetime.

**Missed events:** the stream does not replay. If your connection falls behind, you get `{"type": "StreamGap", "dropped_events": n}`; after a `StreamGap` or a reconnect, read current state from the trading account endpoints. A client that stops reading is disconnected (code `4008`).

**Limits:** 5 open connections per organization per server; more are refused with HTTP `429`. One connection carries all your accounts, so one or two are enough. Send `{"action": "ping"}` for a `Pong`.

Requires **view** permission on traders.



## OpenAPI

````yaml https://api.hyperprop.com/platform/openapi.json post /v1/organization/trading-accounts/stream-token
openapi: 3.0.0
info:
  title: Hyperprop Platform API
  version: 1.0.0
  description: >-
    REST API for the Hyperprop Trading Platform — provision evaluation and
    funded trading accounts, manage traders and plans, react to account
    lifecycle events via signed webhooks, and reconcile billing. Built for prop
    firms integrating from their own backend.


    Authentication, quick start, error handling, idempotency, pagination, custom
    metadata, webhooks, and the MCP connector are documented at
    https://docs.hyperprop.com.
  x-logo:
    url: https://app.hyperprop.com/logo-icon.svg
    altText: Hyperprop
    href: https://hyperprop.com
servers:
  - url: https://api.hyperprop.com/platform
    description: Production
security: []
tags:
  - name: Trading accounts
    description: Create, update, and inspect trading accounts.
  - name: Traders
    description: Look up and update the traders in your organization.
  - name: Trading plans
    description: Define the plans you sell.
  - name: Trading rules
    description: Define how accounts are evaluated.
  - name: Lockouts
    description: Pause and resume trading on an account.
  - name: Payouts
    description: Check payout eligibility and record payouts.
  - name: Purchases
    description: Purchases recorded for your organization.
  - name: Time Machine
    description: Restore accounts to an earlier trading day or instant.
  - name: Mass credit
    description: >-
      Credit back losses across many accounts after an incident, as background
      jobs you can follow, pause, export and reverse.
  - name: Webhooks
    description: Register webhook endpoints and inspect deliveries.
  - name: Events
    description: Your organization's event history and real-time event stream.
  - name: Reconciliation
    description: Balances, end-of-day snapshots, and fills for reconciliation.
  - name: Analytics
    description: Organization performance and plan economics.
  - name: Billing
    description: 'Your Hyperprop bill: activity, billing cycles, and forecasts.'
  - name: Team and roles
    description: Manage dashboard access for your staff.
  - name: API keys
    description: Manage your organization's API key.
  - name: Logs and health
    description: >-
      API request logs, the audit log, integration health, and idempotency key
      recovery.
  - name: Organization profile
    description: Your organization's profile and logo.
  - name: Support
    description: Open and follow up on support tickets.
  - name: Partner access
    description: >-
      Read a trader's journal as an approved partner app, with the trader's own
      key.
paths:
  /v1/organization/trading-accounts/stream-token:
    post:
      tags:
        - Trading accounts
      summary: Create a trading stream token
      description: >-
        Returns a short-lived token for the real-time trading stream of **all**
        your organization's trading accounts: every order, execution, position
        change, balance/equity update and rule violation, as it happens. New
        accounts are included automatically.


        The stream is read-only. It accepts no trading commands.


        **Connect** to the returned `url` with the token in the `Authorization`
        header:


        ```bash

        TOKEN=$(curl -s -X POST
        "https://api.hyperprop.com/platform/v1/organization/trading-accounts/stream-token"
        \
          -H "X-API-Key: hp_live_your_key_here" | jq -r .data.token)
        websocat -H "Authorization: Bearer $TOKEN"
        wss://api.hyperprop.com/trade/org/stream

        ```


        The first message is `{"type": "Welcome", "organization_id": ...,
        "expires_at": ...}`. Then each event arrives as one JSON message with a
        `type`: `OrderSubmitted`, `OrderFilled` (one per execution, with the
        `trade`), `OrderCancelled`, `PositionUpdate`, `AccountUpdate` (balance,
        equity, P&L, drawdown, status), `RuleViolation` and account
        `Notification`. Every event carries `account_id`. A `Heartbeat` arrives
        every 15 seconds.


        **Token lifetime:** 15 minutes. Before it expires, request a new token
        and send `{"action": "refresh", "token": "<new token>"}` on the open
        connection (reply `TokenRefreshed`). Otherwise the connection closes
        with code `4001` and you reconnect with a new token. A revoked API key
        can't get new tokens, so its connections end within one token lifetime.


        **Missed events:** the stream does not replay. If your connection falls
        behind, you get `{"type": "StreamGap", "dropped_events": n}`; after a
        `StreamGap` or a reconnect, read current state from the trading account
        endpoints. A client that stops reading is disconnected (code `4008`).


        **Limits:** 5 open connections per organization per server; more are
        refused with HTTP `429`. One connection carries all your accounts, so
        one or two are enough. Send `{"action": "ping"}` for a `Pong`.


        Requires **view** permission on traders.
      operationId: postV1OrganizationTradingaccountsStreamtoken
      responses:
        '200':
          description: Stream token
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model1060'
        '401':
          description: Authentication required
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model11'
        '403':
          description: This API key does not have admin permissions
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model1061'
        '503':
          description: The trading stream is not available right now
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model1062'
      security:
        - X-API-Key: []
components:
  schemas:
    Model1060:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/Model1059'
    Model11:
      type: object
      properties:
        success:
          type: boolean
          description: Always false on errors
          example: false
        statusCode:
          type: number
          example: 401
        error:
          type: string
          example: Unauthorized
        message:
          type: string
          example: Authentication required
        code:
          type: string
          description: Machine-readable error code — switch on this, not on message text
          example: UNAUTHORIZED
    Model1061:
      type: object
      properties:
        success:
          type: boolean
          description: Always false on errors
          example: false
        statusCode:
          type: number
          example: 403
        error:
          type: string
          example: Forbidden
        message:
          type: string
          example: This API key does not have admin permissions
        code:
          type: string
          description: Machine-readable error code — switch on this, not on message text
          example: INSUFFICIENT_PERMISSIONS
    Model1062:
      type: object
      properties:
        success:
          type: boolean
          description: Always false on errors
          example: false
        statusCode:
          type: number
          example: 503
        error:
          type: string
          example: Error
        message:
          type: string
          example: The trading stream is not available right now
        code:
          type: string
          description: Machine-readable error code — switch on this, not on message text
          example: STREAM_UNAVAILABLE
    Model1059:
      type: object
      properties:
        token:
          type: string
          description: 'Send as `Authorization: Bearer <token>` when connecting'
          example: >-
            eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6Im9yZ19zdHJlYW0ifQ.c2lnbmF0dXJl
        expiresIn:
          type: integer
          description: Seconds until the token expires
          example: 900
        expiresAt:
          type: string
          example: '2026-10-25T16:15:00.000Z'
        url:
          type: string
          description: WebSocket URL to connect to
          example: wss://api.hyperprop.com/trade/org/stream
  securitySchemes:
    X-API-Key:
      type: apiKey
      name: X-API-Key
      in: header
      description: >-
        Organization API key. Format: "hp_live_{key}". Organization admins
        manage the key in the dashboard.

````

## Related topics

- [Real-time trading stream](https://docs.hyperprop.com/guides/realtime-trading-stream.md)
- [Create a partner session](https://docs.hyperprop.com/trade-api/account/create-a-partner-session.md)
- [Introduction](https://docs.hyperprop.com/introduction.md)
- [Create or update a copy trading config](https://docs.hyperprop.com/trade-api/copy-trading/create-or-update-a-copy-trading-config.md)
- [Create a trading account](https://docs.hyperprop.com/platform-api/trading-accounts/create-a-trading-account.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.