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

# Ingest trade signal

> Primary endpoint for receiving automated trade signals from
TradingView webhooks, cURL scripts, or any HTTP client.

The gateway validates the API key (provided in the JSON body as
`apiKey`), checks the IP allowlist, enforces rate limits, and
verifies the kill switch before routing the trade to the execution
engine — either directly via service binding or asynchronously via
Cloudflare Queue (depending on queue mode).




## OpenAPI

````yaml /docs/openapi-minimal.yaml post /webhook
openapi: 3.0.3
info:
  title: Hoox API
  description: |
    REST API for the Hoox algorithmic trading platform.

    Ingest trade signals, check system health, and manage DeFi wallet
    operations on the Cloudflare edge. All requests are handled by the
    Hoox gateway worker (`workers/hoox`) running at the network edge.
  version: 1.0.0
  contact:
    name: Hoox Support
    email: support@hoox.sh
servers:
  - url: https://api.hoox.sh
    description: Production API
  - url: https://staging.hoox.sh
    description: Staging environment
security: []
paths:
  /webhook:
    post:
      tags:
        - Trades
      summary: Ingest trade signal
      description: |
        Primary endpoint for receiving automated trade signals from
        TradingView webhooks, cURL scripts, or any HTTP client.

        The gateway validates the API key (provided in the JSON body as
        `apiKey`), checks the IP allowlist, enforces rate limits, and
        verifies the kill switch before routing the trade to the execution
        engine — either directly via service binding or asynchronously via
        Cloudflare Queue (depending on queue mode).
      operationId: ingestTradeSignal
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - apiKey
                - exchange
                - action
                - symbol
                - quantity
              properties:
                apiKey:
                  type: string
                  description: |
                    Webhook authentication key. Provided inside the JSON
                    payload body — NOT as an HTTP header.
                  example: whk_live_a1b2c3d4e5f6
                exchange:
                  type: string
                  description: Target exchange
                  enum:
                    - binance
                    - bybit
                    - mexc
                  example: bybit
                action:
                  type: string
                  description: Trade action to execute
                  enum:
                    - LONG
                    - SHORT
                    - CLOSE_LONG
                    - CLOSE_SHORT
                  example: LONG
                symbol:
                  type: string
                  description: Trading pair symbol
                  maxLength: 20
                  example: BTCUSDT
                quantity:
                  type: number
                  description: Order size in contracts or base currency
                  minimum: 0
                  exclusiveMinimum: true
                  example: 0.002
                price:
                  type: number
                  description: Optional limit price (market order if omitted)
                  minimum: 0
                  exclusiveMinimum: true
                  example: 68500.5
                leverage:
                  type: integer
                  description: Optional leverage multiplier for margin trades
                  minimum: 1
                  example: 10
                idempotencyKey:
                  type: string
                  format: uuid
                  description: |
                    Optional client-supplied idempotency key. When the
                    gateway receives a duplicate request with the same
                    key inside the dedupe TTL window, the original
                    response is replayed (see 409 below).
                  example: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
                notify:
                  type: object
                  description: Optional Telegram notification configuration
                  properties:
                    chatId:
                      type: string
                      description: Target Telegram chat ID
                      example: '987654321'
                    message:
                      type: string
                      description: Custom notification message
                      example: BTC Long signal received
                    parseMode:
                      type: string
                      description: |
                        Optional Telegram Bot API parse mode applied to
                        `message`. Use `HTML` or `MarkdownV2` to enable
                        rich-text formatting. Omit (or use `Plain`) to
                        send literal text.
                      enum:
                        - Plain
                        - HTML
                        - Markdown
                        - MarkdownV2
                      default: Plain
                      example: HTML
      responses:
        '200':
          description: Trade processed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse'
        '202':
          description: Trade enqueued for asynchronous execution
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  requestId:
                    type: string
                    description: Unique request trace ID
                    example: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
                  status:
                    type: string
                    example: Enqueued
                  message:
                    type: string
                    example: Trade queued for execution
        '400':
          description: Invalid payload structure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Authentication failed or IP blocked
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Duplicate trade detected (idempotency check)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal processing error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Service disabled (kill switch active)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SuccessResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        requestId:
          type: string
          format: uuid
          description: Unique request trace identifier
          example: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
        tradeResult:
          type: object
          nullable: true
          properties:
            success:
              type: boolean
            orderId:
              type: string
              example: '18049284739'
            status:
              type: string
              example: Filled
            executedQty:
              type: number
              example: 0.005
            price:
              type: number
              example: 68425.5
            queued:
              type: boolean
              description: True if the trade was queued rather than executed immediately
        notificationResult:
          type: object
          nullable: true
          properties:
            success:
              type: boolean
            messageId:
              type: integer
              nullable: true
              example: 482904
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        requestId:
          type: string
          format: uuid
          description: Request trace identifier
          example: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
        error:
          type: string
          description: Human-readable error description
          example: Invalid JSON payload structure.

````