> ## Documentation Index
> Fetch the complete documentation index at: https://sure-917046f5-docs-cloudflare-tunnel-self-hosting.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create trade



## OpenAPI

````yaml /openapi.yaml post /api/v1/trades
openapi: 3.0.3
info:
  title: Sure API
  version: v1
  description: OpenAPI documentation for the Sure API.
servers:
  - url: https://app.sure.am
    description: Production
  - url: http://localhost:3000
    description: Local development
security: []
paths:
  /api/v1/trades:
    post:
      tags:
        - Trades
      summary: Create trade
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                trade:
                  type: object
                  properties:
                    account_id:
                      type: string
                      format: uuid
                      description: Account ID (must be an investment or crypto account)
                    type:
                      type: string
                      enum:
                        - buy
                        - sell
                      description: Trade type
                    date:
                      type: string
                      format: date
                      description: Trade date
                    qty:
                      type: number
                      description: Quantity (must be positive)
                    price:
                      type: number
                      description: Price per unit (must be positive)
                    currency:
                      type: string
                      description: Currency code (defaults to account currency)
                    security_id:
                      type: string
                      format: uuid
                      description: >-
                        Security ID (provide one of security_id, ticker, or
                        manual_ticker)
                    ticker:
                      type: string
                      description: Security ticker symbol
                    manual_ticker:
                      type: string
                      description: Manual ticker for unlisted securities
                    investment_activity_label:
                      type: string
                      description: Activity label (e.g. Buy, Sell, Dividend)
                    category_id:
                      type: string
                      format: uuid
                      description: Category ID
                  required:
                    - account_id
                    - type
                    - date
                    - qty
                    - price
              required:
                - trade
        required: true
      responses:
        '201':
          description: trade created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Trade'
        '404':
          description: account or security not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - apiKeyAuth: []
components:
  schemas:
    Trade:
      type: object
      required:
        - id
        - date
        - amount
        - currency
        - name
        - qty
        - price
        - account
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
        date:
          type: string
          format: date
        amount:
          type: string
          description: Formatted monetary amount (e.g. "$1,234.56")
        currency:
          type: string
        name:
          type: string
        notes:
          type: string
          nullable: true
        qty:
          type: number
          description: Quantity of shares or units traded. Negative for sells.
        price:
          type: string
          description: Formatted price per unit
        investment_activity_label:
          type: string
          nullable: true
          description: Activity label such as Buy, Sell, Dividend, etc.
        account:
          $ref: '#/components/schemas/Account'
        security:
          $ref: '#/components/schemas/Security'
          nullable: true
        category:
          type: object
          nullable: true
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        message:
          type: string
          nullable: true
        details:
          oneOf:
            - type: array
              items:
                type: string
            - type: object
          nullable: true
    Account:
      type: object
      required:
        - id
        - name
        - account_type
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        account_type:
          type: string
    Security:
      type: object
      required:
        - id
        - ticker
        - name
      properties:
        id:
          type: string
          format: uuid
        ticker:
          type: string
        name:
          type: string
          nullable: true
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      name: X-Api-Key
      in: header
      description: API key for authentication. Generate one from your account settings.

````