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

# Cancel a booked trade by booking an offsetting one.

> Books a trade whose position effects negate the original's. The original is left in place, so the book keeps both, and the response identifies the new offsetting trade rather than the one reversed. The caller needs edit access to every book the original touched; without it nothing is booked. This is a synchronous mutation and is not itself reversible except by reversing the offsetting trade.



## OpenAPI

````yaml /risk-and-pricing/atoti-risk-services/apis-endpoints/openapi/openapi.mintlify.json post /api/Position/ReverseTrade
openapi: 3.0.4
info:
  title: Derivitec Api 1.0
  version: '1.0'
servers:
  - url: https://api.riskportal.activeviam.com
security:
  - oauth2: []
  - apikey: []
tags:
  - name: AdminUser
  - name: AtotiReport
  - name: AtotiSession
  - name: BloombergOAuth
  - name: Bond
  - name: BondYieldCurvePage
  - name: BookAccess
  - name: Books
  - name: Commodity
  - name: Counterparties
  - name: Currencies
  - name: Equity
  - name: EquityDividend
  - name: EquityPage
  - name: FeatureFlag
  - name: Fx
  - name: FxPage
  - name: GroupAccess
  - name: Home
  - name: LegacyPosition
  - name: MarketData
  - name: MarketDataProvider
  - name: MarketDataProviderAccess
  - name: Meta
  - name: Notification
  - name: Organisation
  - name: PnLReport
  - name: PortfolioAccess
  - name: Portfolios
  - name: Position
  - name: PositionFilter
  - name: PricingEnvironment
  - name: PricingEnvironmentAccess
  - name: RateAsset
  - name: RateAssetPage
  - name: Report
  - name: ReportDefinition
  - name: ReportHistoryLauncherQuery
  - name: ReportLauncher
  - name: ReportQuery
  - name: ReportQueryViewUser
  - name: ReportRestriction
  - name: ReportView
  - name: RiskReport
  - name: Tradable
  - name: TradeBooking
  - name: User
  - name: VarReport
  - name: VarReportQuery
  - name: YieldCurvePage
paths:
  /api/Position/ReverseTrade:
    post:
      tags:
        - Position
      summary: Cancel a booked trade by booking an offsetting one.
      description: >-
        Books a trade whose position effects negate the original's. The original
        is left in place, so the book keeps both, and the response identifies
        the new offsetting trade rather than the one reversed. The caller needs
        edit access to every book the original touched; without it nothing is
        booked. This is a synchronous mutation and is not itself reversible
        except by reversing the offsetting trade.
      operationId: ReverseTrade
      requestBody:
        description: JSON request with `TradeId`, the identifier of the trade to reverse.
        content:
          application/json-patch+json:
            schema:
              $ref: '#/components/schemas/ApiReverseTradeRequest'
          application/json:
            schema:
              $ref: '#/components/schemas/ApiReverseTradeRequest'
          text/json:
            schema:
              $ref: '#/components/schemas/ApiReverseTradeRequest'
          application/*+json:
            schema:
              $ref: '#/components/schemas/ApiReverseTradeRequest'
      responses:
        '200':
          description: >-
            Returns the offsetting trade's identifier with `IsSuccess = true`,
            or `IsSuccess = false` and the reason when the trade was not found,
            has nothing to reverse, or the caller lacks edit access to one of
            its books.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiReverseTradeResponse'
        '400':
          description: BadRequest
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
      security:
        - oauth2: []
        - apikey: []
components:
  schemas:
    ApiReverseTradeRequest:
      required:
        - $type
      type: object
      properties:
        trade_id:
          type: integer
          description: >-
            Identifies the trade to reverse. The caller needs edit access to
            every book it touched.
          format: int32
        $type:
          type: string
          enum:
            - >-
              Derivitec.Web.Core.TradeBooking.ApiReverseTradeRequest,
              Derivitec.Web.Core
      additionalProperties: false
      description: >-
        Asks for a booked trade to be undone by booking an offsetting one. The
        original trade is left in

        place, so the book keeps a record of both.
    ApiReverseTradeResponse:
      required:
        - $type
      type: object
      properties:
        is_success:
          type: boolean
          description: >-
            Whether the operation completed successfully. The default is `true`;
            error outcomes set it to `false`.
          example: true
        error_messages:
          type: array
          items:
            type: string
          description: >-
            Messages explaining operation-level failures. The collection is
            empty by default.
          nullable: true
        trade_id:
          type: integer
          description: >-
            Identifies the offsetting trade that was booked, not the trade that
            was reversed. Null when

            no reversal was booked, in which case the request reports failure
            and says why.
          format: int32
          nullable: true
        $type:
          type: string
          enum:
            - >-
              Derivitec.Web.Core.TradeBooking.ApiReverseTradeResponse,
              Derivitec.Web.Core
      additionalProperties: false
      description: The outcome of reversing a booked trade.
  securitySchemes:
    oauth2:
      type: oauth2
      description: >-
        OAuth2 access-token requested from AWS Cognito and provided as a Auth
        Bearer header
      flows:
        implicit:
          authorizationUrl: https://auth.riskportal.derivitec.com/oauth2/authorize
          scopes: {}
    apikey:
      type: apiKey
      description: API-Key requested via the site and provided as a header
      name: x-api-key
      in: header

````