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

# Place a new order

> Places a market or pending order via `mt5.order_send()`. The NOVOSKY bot only places `BUY` and `SELL` market orders. Limit, stop, and stop-limit order types are available for manual use.



## OpenAPI

````yaml https://terminal-api.novosky.tech/roboforex/main/openapi.json post /orders
openapi: 3.0.3
info:
  description: >-
    Self-hosted HTTP REST API bridging the NOVOSKY trading bot to a MetaTrader 5
    terminal. All bot-to-broker communication goes through this service.
    Authentication is required on all endpoints except `GET /ping`.
  title: MT5 HEADLESS
  version: 1.0.0
servers:
  - url: /
security:
  - bearerAuth: []
tags:
  - description: Health, latency, and error diagnostics
    name: System
  - description: MT5 terminal lifecycle and server time
    name: Terminal
  - description: Broker server time and UTC offset detection
    name: Time
  - description: Live balance, equity, and margin
    name: Account
  - description: Symbol specs, ticks, and OHLCV rates
    name: Symbols
  - description: Open position management
    name: Positions
  - description: Pending order placement and management
    name: Orders
  - description: Closed deals and historical orders
    name: History
paths:
  /orders:
    post:
      tags:
        - Orders
      summary: Place a new order
      description: >-
        Places a market or pending order via `mt5.order_send()`. The NOVOSKY bot
        only places `BUY` and `SELL` market orders. Limit, stop, and stop-limit
        order types are available for manual use.
      operationId: place_order
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PositionResponse'
          description: Order filled — open position returned
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderResponse'
          description: Pending order placed
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: >-
            Invalid order parameters (check retcode — 10014 = bad SL/TP, 10019 =
            insufficient funds)
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or invalid Bearer token
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Order send failed
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: MT5 not initialized or market closed (retcode 10018)
components:
  schemas:
    OpenRequest:
      additionalProperties: true
      description: Request body for placing a new order.
      properties:
        comment:
          example: novosky
          type: string
        deviation:
          description: Max allowed price deviation in points.
          example: 20
          type: integer
        expiration:
          description: Expiry time as Unix epoch (for SPECIFIED type_time).
          type: integer
        magic:
          description: EA magic number for trade identification.
          example: 20250101
          type: integer
        price:
          description: Order price (required for limit/stop orders).
          example: 95000
          type: number
        sl:
          description: Stop loss price.
          example: 94800
          type: number
        stoplimit:
          description: Limit price for BUY_STOP_LIMIT / SELL_STOP_LIMIT orders.
          type: number
        symbol:
          example: BTCUSD
          type: string
        tp:
          description: Take profit price.
          example: 95300
          type: number
        type:
          description: >-
            Order type. The bot only uses BUY and SELL; the rest are available
            for manual use.
          enum:
            - BUY
            - SELL
            - BUY_LIMIT
            - SELL_LIMIT
            - BUY_STOP
            - SELL_STOP
            - BUY_STOP_LIMIT
            - SELL_STOP_LIMIT
          example: BUY
          type: string
        type_time:
          description: 'Order expiry type: GTC, TODAY, SPECIFIED, SPECIFIED_DAY.'
          example: GTC
          type: string
        volume:
          description: Lot size.
          example: 0.01
          type: number
      required:
        - symbol
        - type
        - volume
      type: object
    PositionResponse:
      additionalProperties: true
      description: An open position.
      properties:
        comment:
          example: novosky
          type: string
        magic:
          description: EA magic number.
          example: 20250101
          type: integer
        price_current:
          example: 95050
          type: number
        price_open:
          example: 95000
          type: number
        profit:
          description: Floating profit in account currency.
          example: 5
          type: number
        sl:
          example: 94800
          type: number
        swap:
          example: -0.12
          type: number
        symbol:
          example: BTCUSD
          type: string
        ticket:
          example: 123456789
          type: integer
        time:
          description: Position open time as Unix epoch.
          example: 1777879028
          type: integer
        tp:
          example: 95300
          type: number
        type:
          description: 0 = BUY, 1 = SELL.
          example: 0
          type: integer
        volume:
          example: 0.01
          type: number
      type: object
    OrderResponse:
      additionalProperties: true
      description: A pending order.
      properties:
        comment:
          example: novosky
          type: string
        magic:
          example: 20250101
          type: integer
        price_open:
          example: 94500
          type: number
        sl:
          example: 94300
          type: number
        symbol:
          example: BTCUSD
          type: string
        ticket:
          example: 987654321
          type: integer
        time_setup:
          description: Order creation time as Unix epoch.
          example: 1777879028
          type: integer
        tp:
          example: 94800
          type: number
        type:
          description: >-
            2=BUY_LIMIT, 3=SELL_LIMIT, 4=BUY_STOP, 5=SELL_STOP,
            6=BUY_STOP_LIMIT, 7=SELL_STOP_LIMIT.
          example: 2
          type: integer
        volume_current:
          example: 0.01
          type: number
      type: object
    ErrorResponse:
      additionalProperties: true
      description: MT5 error payload returned on non-2xx responses.
      properties:
        message:
          example: Invalid stops
          type: string
        retcode:
          description: MT5 error code (e.g. 10014 = invalid stops, 10018 = market closed).
          example: 10014
          type: integer
      type: object
  securitySchemes:
    bearerAuth:
      description: Set `API_TOKEN` in `.env` to match the token configured on the server.
      scheme: bearer
      type: http

````