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

# Create Trade

> Allows you to execute buy (BUY) or sell (SELL) operations for market assets. The trade can be of type MARKET (market order) or LIMIT (limit order). You can specify the amount in USD or the number of shares to buy/sell, but not both at the same time.



## OpenAPI

````yaml POST /api/public/v1/trades
openapi: 3.0.3
info:
  title: Wallbit Public API
  description: >-
    Wallbit Public API allows developers to integrate Wallbit functionality into
    their applications. Access account balances, view transaction history, and
    execute trades programmatically using API Keys.
  version: 1.0.0
  contact:
    name: Wallbit API Support
    email: dev@wallbit.io
servers:
  - url: https://api.wallbit.io
    description: Production server
  - url: http://localhost
    description: Local development server
security:
  - apiKey: []
tags:
  - name: Balance
    description: Endpoints to retrieve account balances
  - name: Transactions
    description: Endpoints to retrieve transaction history
  - name: Trades
    description: Endpoints to execute trading operations
  - name: Fees
    description: >-
      Endpoints to retrieve fee configuration for the authenticated user (e.g.
      stock trading fees by subscription tier)
  - name: Account Details
    description: Endpoints to obtain bank account details
  - name: Wallets
    description: Endpoints to obtain wallet addresses
  - name: Rates
    description: Endpoints to retrieve fiat exchange rates from Wallbit
  - name: Assets
    description: Endpoints to query information about assets (stocks) and categories
  - name: Operations
    description: Endpoints for deposit and withdrawal investment operations
  - name: Cards
    description: Endpoints to block and unblock cards
  - name: API Key
    description: Endpoints to revoke the API key used for authentication
paths:
  /api/public/v1/trades:
    post:
      tags:
        - Trades
      summary: Create a trade (buy/sell assets)
      description: >-
        Allows you to execute buy (BUY) or sell (SELL) operations for market
        assets. The trade can be of type MARKET (market order) or LIMIT (limit
        order). You can specify the amount in USD or the number of shares to
        buy/sell, but not both at the same time.
      operationId: createTrade
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TradeRequest'
            examples:
              market-buy-amount:
                summary: Market order BUY by amount
                value:
                  symbol: AAPL
                  direction: BUY
                  currency: USD
                  order_type: MARKET
                  amount: 100
              limit-sell-shares:
                summary: Limit order SELL by shares
                value:
                  symbol: TSLA
                  direction: SELL
                  currency: USD
                  order_type: LIMIT
                  shares: 2
                  limit_price: 250
                  time_in_force: GTC
      responses:
        '200':
          description: Trade created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Trade'
              example:
                data:
                  symbol: AAPL
                  direction: BUY
                  amount: 100
                  shares: 0.5847953
                  status: REQUESTED
                  order_type: MARKET
                  created_at: '2024-01-15T10:30:00.000000Z'
                  updated_at: '2024-01-15T10:30:00.000000Z'
        '400':
          description: Insufficient funds
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                message: Insufficient funds to complete the operation
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '412':
          description: KYC incomplete
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: >-
                  You must complete your investment account verification before
                  performing this operation.
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
        - apiKey: []
components:
  schemas:
    TradeRequest:
      type: object
      required:
        - symbol
        - direction
        - currency
        - order_type
      properties:
        symbol:
          type: string
          description: Asset symbol (e.g., AAPL, TSLA, MSFT)
          example: AAPL
        direction:
          type: string
          enum:
            - BUY
            - SELL
          description: Trade direction
          example: BUY
        currency:
          type: string
          description: Currency (only USD supported)
          example: USD
        order_type:
          type: string
          enum:
            - MARKET
            - LIMIT
            - STOP
            - STOP_LIMIT
          description: Order type
          example: MARKET
        amount:
          type: number
          format: float
          description: Amount in USD (required if shares not specified)
          example: 100
        shares:
          type: number
          format: float
          description: Number of shares (required if amount not specified)
          example: 5
        stop_price:
          type: number
          format: float
          description: Stop price (required for STOP and STOP_LIMIT)
          example: 150
        limit_price:
          type: number
          format: float
          description: Limit price (required for LIMIT and STOP_LIMIT)
          example: 145.5
        time_in_force:
          type: string
          enum:
            - DAY
            - GTC
          description: Time in force (required for LIMIT)
          example: DAY
    Trade:
      type: object
      properties:
        symbol:
          type: string
          description: Asset symbol
        direction:
          type: string
          enum:
            - BUY
            - SELL
          description: Trade direction
        amount:
          type: number
          format: float
          description: Amount in USD
        shares:
          type: number
          format: float
          description: Number of shares
        status:
          type: string
          description: Trade status
        order_type:
          type: string
          enum:
            - MARKET
            - LIMIT
            - STOP
            - STOP_LIMIT
          description: Order type
        limit_price:
          type: number
          format: float
          nullable: true
          description: Limit price (for LIMIT orders)
        stop_price:
          type: number
          format: float
          nullable: true
          description: Stop price (for STOP orders)
        time_in_force:
          type: string
          enum:
            - DAY
            - GTC
          nullable: true
          description: Time in force (for LIMIT orders)
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        message:
          type: string
          description: Error message
        error:
          type: string
          description: Error description
    ValidationError:
      type: object
      properties:
        message:
          type: string
          description: Error message
        errors:
          type: object
          description: Field-specific validation errors
          additionalProperties:
            type: array
            items:
              type: string
  responses:
    Unauthorized:
      description: Missing or invalid API Key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            missing:
              summary: Missing API Key
              value:
                message: API Key required. Please provide X-API-Key header.
            invalid:
              summary: Invalid API Key
              value:
                message: Invalid or expired API Key.
    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
              your_permissions:
                type: array
                items:
                  type: string
          example:
            message: 'Insufficient permissions. Required permission: read'
            your_permissions:
              - trade
    ValidationError:
      description: Validation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
          example:
            message: The given data was invalid.
            errors:
              symbol:
                - The symbol field is required.
    TooManyRequests:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
              retry_after:
                type: integer
                description: Seconds until rate limit resets
          example:
            message: Too many requests. Please try again later.
            retry_after: 42
      headers:
        X-RateLimit-Limit:
          description: Total requests allowed per minute
          schema:
            type: integer
        X-RateLimit-Remaining:
          description: Requests remaining in current window
          schema:
            type: integer
        X-RateLimit-Reset:
          description: Unix timestamp when rate limit resets
          schema:
            type: integer
        Retry-After:
          description: Seconds to wait before retry
          schema:
            type: integer
  securitySchemes:
    apiKey:
      type: apiKey
      name: X-API-Key
      in: header
      description: >-
        API Key authentication. Obtain your API key from the Wallbit dashboard
        under Settings → API Keys.

````

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