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

# Cancel portfolio transaction

> Cancel a pending portfolio asset transaction and all its associated orders



## OpenAPI

````yaml POST /investments/transactions/{id}/cancel
openapi: 3.0.3
info:
  title: Wealthyhood Investments API
  version: 1.0.0
  description: >
    Portfolio and asset investment preview, execution, and order management
    endpoints for Wealthyhood portfolios.


    All requests use machine-to-machine (M2M) authentication. Each request
    requires:

    - A bearer access token (M2M token with required scopes)

    - An `x-user-id` header to specify which user's data to access
servers:
  - url: https://{host}
    variables:
      host:
        default: api.wealthyhood.com
        description: Wealthyhood API host name.
security:
  - bearerAuth: []
tags:
  - name: Investments
    description: >-
      Preview and execute portfolio and asset investment operations, and manage
      orders.
paths:
  /investments/transactions/{id}/cancel:
    post:
      tags:
        - Investments
      summary: Cancel a portfolio asset transaction
      description: >
        Cancel a pending portfolio asset transaction and all its associated
        orders.

        Only transactions in `Pending` status with cancellable orders can be
        cancelled.


        A transaction cannot be cancelled if:

        - It is not in `Pending` status

        - Its orders have already been submitted to the broker

        - Its orders have real-time execution and the market is currently open
      parameters:
        - $ref: '#/components/parameters/XUserId'
        - $ref: '#/components/parameters/TransactionId'
      responses:
        '200':
          description: Transaction cancelled successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AssetTransaction'
              example:
                id: 64f5b3137fb3fc001234abce
                category: AssetTransaction
                status: Cancelled
                portfolioTransactionCategory: buy
                owner: 64f0c51e7fb3fc001234abcd
                portfolio: 64f0c51e7fb3fc001234abcd
                consideration:
                  currency: EUR
                  amount: 250.5
                orders:
                  - id: 64f5b3137fb3fc001234abcf
                    isin: US0378331005
                    side: Buy
                    status: Cancelled
                    consideration:
                      currency: EUR
                      amount: 250.5
        '400':
          description: Transaction is not cancellable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                status: 400
                error:
                  description: Transaction 64f5b3137fb3fc001234abce is not cancellable
                responseId: 3f0fd3bf-a2ff-4c0e-9b1d-5d7055dbf6cd
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
components:
  parameters:
    XUserId:
      name: x-user-id
      in: header
      required: true
      description: >-
        User identifier for the M2M client to specify which user's data to
        access.
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
    TransactionId:
      name: id
      in: path
      required: true
      description: Transaction identifier (MongoDB ObjectId)
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
  schemas:
    AssetTransaction:
      type: object
      description: Asset transaction enriched with display-ready fields.
      required:
        - id
        - category
        - status
        - orders
      properties:
        id:
          type: string
        category:
          type: string
          enum:
            - AssetTransaction
        status:
          type: string
          description: >-
            Current transaction status (`Pending`, `PendingGift`, `Settled`,
            etc.).
        portfolioTransactionCategory:
          type: string
          enum:
            - update
            - buy
            - sell
        owner:
          type: string
          description: User identifier owning the transaction.
        portfolio:
          type: string
          description: Portfolio identifier associated with the transaction.
        consideration:
          type: object
          properties:
            currency:
              type: string
              description: Portfolio currency (EUR, GBP, USD, etc.).
            amount:
              type: number
              format: double
              description: Raw consideration amount in whole currency.
        executionWindow:
          allOf:
            - $ref: '#/components/schemas/ExecutionWindowsType'
          nullable: true
        orders:
          type: array
          items:
            $ref: '#/components/schemas/Order'
        fees:
          allOf:
            - $ref: '#/components/schemas/TransactionFees'
          nullable: true
        partnerFees:
          allOf:
            - $ref: '#/components/schemas/PartnerFees'
          nullable: true
          description: Present for partner users when countervalue fees apply.
    ApiErrorResponse:
      type: object
      properties:
        status:
          type: integer
        error:
          type: object
          properties:
            message:
              type: string
            description:
              type: string
              nullable: true
        responseId:
          type: string
          format: uuid
    ExecutionWindowsType:
      type: object
      description: >-
        Execution windows separated by asset category (matches domain
        ExecutionWindowsType)
      properties:
        stocks:
          $ref: '#/components/schemas/ExecutionWindowType'
        etfs:
          $ref: '#/components/schemas/ExecutionWindowType'
      additionalProperties: false
    Order:
      type: object
      description: Order information including execution details and fees
      required:
        - id
        - displayId
        - isin
        - side
        - status
        - orderType
        - displayDate
        - isCancellable
      properties:
        id:
          type: string
        displayId:
          type: string
          description: User-friendly display identifier for the order (e.g., ORD-XXXXX)
          example: ORD-ABC12
        isin:
          type: string
        side:
          type: string
          enum:
            - Buy
            - Sell
        status:
          type: string
          enum:
            - Pending
            - Matched
            - Settled
            - Rejected
            - Cancelled
        orderType:
          type: string
          enum:
            - market
            - limit
          description: Order type (`market` or `limit`).
        quantity:
          type: number
          format: double
          description: Asset units (may be null for pending buy orders)
        executionWindow:
          allOf:
            - $ref: '#/components/schemas/ExecutionWindow'
          nullable: true
        consideration:
          type: object
          properties:
            currency:
              type: string
            amount:
              type: number
              format: double
        limitPrice:
          allOf:
            - $ref: '#/components/schemas/UnitPriceType'
          nullable: true
          description: Limit price per unit for limit orders
        expiresAt:
          type: string
          format: date-time
          nullable: true
          description: ISO datetime when a limit order expires
        fees:
          allOf:
            - $ref: '#/components/schemas/TransactionFees'
          nullable: true
        partnerFees:
          allOf:
            - $ref: '#/components/schemas/PartnerFees'
          nullable: true
        createdAt:
          type: string
          format: date-time
          description: Timestamp when the order was created (optional)
        settledAt:
          type: string
          format: date-time
          nullable: true
          description: ISO datetime when the order settled or is expected to settle
        filledAt:
          type: string
          format: date-time
          nullable: true
          description: ISO datetime when order was matched
        displayDate:
          type: string
          format: date-time
          description: Display date (`filledAt` when matched, otherwise `createdAt`)
        isCancellable:
          type: boolean
          description: Whether the order can be cancelled by the user
        unitPrice:
          allOf:
            - $ref: '#/components/schemas/UnitPriceType'
          nullable: true
        fxRate:
          allOf:
            - $ref: '#/components/schemas/ExchangeRate'
          nullable: true
          description: Exchange rate used
    TransactionFees:
      type: object
      description: >-
        Wealthyhood fees on orders and settled transactions (commission, FX, and
        real-time execution when applicable).
      properties:
        commission:
          $ref: '#/components/schemas/FeeBreakdown'
        fx:
          $ref: '#/components/schemas/FeeBreakdown'
      additionalProperties: false
    PartnerFees:
      type: object
      description: >-
        ETE/NBG countervalue fees charged to partner users (sibling of
        Wealthyhood `fees`)
      properties:
        commission:
          $ref: '#/components/schemas/FeeBreakdown'
        fx:
          $ref: '#/components/schemas/FeeBreakdown'
      additionalProperties: false
    ExecutionWindowType:
      type: object
      description: Base execution window type matching domain structure
      properties:
        executionType:
          type: string
          enum:
            - REALTIME
            - MARKET_HOURS
          description: Internal execution type
        start:
          type: string
          format: date-time
          nullable: true
          description: Execution window start (ISO datetime)
        end:
          type: string
          format: date-time
          nullable: true
          description: Execution window end (ISO datetime)
      additionalProperties: false
    ExecutionWindow:
      type: object
      description: Execution timing communicated to the client.
      properties:
        executionType:
          type: string
          description: Internal execution type such as `REALTIME` or `MARKET_HOURS`.
        start:
          type: string
          format: date-time
          nullable: true
        end:
          type: string
          format: date-time
          nullable: true
      additionalProperties: true
    UnitPriceType:
      type: object
      description: Price per unit in major units (e.g. 200.00 for €200.00).
      properties:
        amount:
          type: number
          format: double
          description: Price per unit in major units (e.g. 200.00 for €200.00).
        currency:
          type: string
          description: ISO 4217 currency code
          enum:
            - GBP
            - EUR
            - USD
      additionalProperties: false
    ExchangeRate:
      type: object
      description: Exchange rate with currency information
      properties:
        rate:
          type: number
          format: double
          description: Exchange rate value
        currency:
          type: string
          description: ISO 4217 currency code
          enum:
            - GBP
            - EUR
            - USD
      additionalProperties: false
    FeeBreakdown:
      type: object
      properties:
        currency:
          type: string
        amount:
          type: number
          format: double
      additionalProperties: false
  responses:
    UnauthorizedError:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            status: 401
            error:
              message: User not found
            responseId: 145f2b0d-1d5b-4e91-8d0d-7af0ae9ad13a
    ForbiddenError:
      description: >-
        Authenticated user cannot act on the requested portfolio or lacks
        scopes.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            status: 403
            error:
              message: Portfolio does not belong to user
            responseId: 5e467f79-c62c-4d83-9810-7a0f8529fd76
    NotFoundError:
      description: Portfolio or related resource was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            status: 404
            error:
              message: Portfolio not found
            responseId: 65c0b1f6-2a48-4c4f-a5aa-9b9c8c6f9b58
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Auth0-issued access token that includes the scopes listed for the
        endpoint.

````