> ## 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.

# Update a trade



## OpenAPI

````yaml /openapi.yaml patch /api/v1/trades/{id}
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/{id}:
    parameters:
      - name: id
        in: path
        required: true
        description: Trade ID
        schema:
          type: string
    patch:
      tags:
        - Trades
      summary: Update a trade
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                trade:
                  type: object
                  properties:
                    name:
                      type: string
                    date:
                      type: string
                      format: date
                    amount:
                      type: number
                    currency:
                      type: string
                    notes:
                      type: string
                    nature:
                      type: string
                      enum:
                        - buy
                        - sell
                        - inflow
                        - outflow
                      description: Trade direction (sell/inflow vs buy/outflow)
                    qty:
                      type: number
                      description: Quantity of shares or units
                    price:
                      type: number
                      description: Price per unit
                    investment_activity_label:
                      type: string
                    category_id:
                      type: string
                      format: uuid
        required: true
      responses:
        '200':
          description: trade updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Trade'
        '404':
          description: trade 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.

````