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

# Cancel Trade

> Cancels an open trade (one that has not yet been accepted or cancelled). Note that only the player who created the trade can cancel it via this API call, to prevent griefing of the trade system (cancelling trades in order to prevent other players from accepting them, for trades that can be claimed by more than one player).

## Error codes

This operation may return the following PlayFab errors:

| Error | Code |
| --- | --- |
| ProductDisabledForTitle | 1609 |
| TradeAlreadyFilled | 1163 |
| TradeCancelled | 1162 |
| TradeDoesNotExist | 1161 |
| TradeStatusNotValidForCancelling | 1159 |
| TradeWaitForStatusTimeout | 1164 |




## OpenAPI

````yaml /services/playfab/api-references/rest/client/client.openapi.json post /Client/CancelTrade
openapi: 3.0.0
info:
  version: '260922'
  title: PlayFab Client API
  description: >-
    APIs which provide the full range of PlayFab features available to the
    client - authentication, account and data management, inventory, friends,
    matchmaking, reporting, and platform-specific functionality
  termsOfService: https://playfab.com/terms/
  contact:
    url: https://community.playfab.com/index.html
  license:
    name: Apache 2.0
    url: https://github.com/PlayFab/API_Specs/blob/master/LICENSE
servers:
  - url: https://{titleId}.playfabapi.com
    description: PlayFab title endpoint
    variables:
      titleId:
        default: your_title_id
        description: Your PlayFab title ID (hex).
security: []
tags:
  - name: Account Management
    description: Account Management APIs
  - name: Advertising
    description: Advertising APIs
  - name: Analytics
    description: Analytics APIs
  - name: Authentication
    description: Authentication APIs
  - name: Character Data
    description: Character Data APIs
  - name: Characters
    description: Characters APIs
  - name: Content
    description: Content Service APIs
  - name: Friend List Management
    description: Friend List Management APIs
  - name: Matchmaking
    description: Matchmaking APIs
  - name: Platform Specific Methods
    description: Platform Specific Methods APIs
  - name: Player Data Management
    description: Player Data Management APIs
  - name: Player Item Management
    description: Player Item Management APIs
  - name: PlayStream
    description: PlayStream Management APIs
  - name: Server-Side Cloud Script
    description: Server-Side Cloud Script APIs
  - name: Shared Group Data
    description: Shared Group Data APIs
  - name: Title-Wide Data Management
    description: Title-Wide Data Management APIs
  - name: Trading
    description: Trading Management APIs
paths:
  /Client/CancelTrade:
    post:
      tags:
        - Trading
      summary: Cancel Trade
      description: >
        Cancels an open trade (one that has not yet been accepted or cancelled).
        Note that only the player who created the trade can cancel it via this
        API call, to prevent griefing of the trade system (cancelling trades in
        order to prevent other players from accepting them, for trades that can
        be claimed by more than one player).


        ## Error codes


        This operation may return the following PlayFab errors:


        | Error | Code |

        | --- | --- |

        | ProductDisabledForTitle | 1609 |

        | TradeAlreadyFilled | 1163 |

        | TradeCancelled | 1162 |

        | TradeDoesNotExist | 1161 |

        | TradeStatusNotValidForCancelling | 1159 |

        | TradeWaitForStatusTimeout | 1164 |
      operationId: CancelTrade
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelTradeRequest'
      responses:
        '200':
          $ref: '#/components/responses/CancelTradeResponse'
        '400':
          $ref: '#/components/responses/ApiErrorWrapper'
      security:
        - SessionTicket: []
components:
  schemas:
    CancelTradeRequest:
      type: object
      properties:
        TradeId:
          description: Trade identifier.
          type: string
      required:
        - TradeId
      example:
        TradeId: D819CEC225EA9948C351
    CancelTradeResponse:
      type: object
      properties:
        Trade:
          allOf:
            - $ref: '#/components/schemas/TradeInfo'
          description: Details about trade which was just canceled.
      example:
        Trade:
          Status: Cancelled
          TradeId: D819CEC225EA9948C351
          OfferingPlayerId: CD803BF233CE76CC
          OfferedInventoryInstanceIds:
            - '1359447'
            - '635691'
          RequestedCatalogItemIds:
            - rare_hat_7
          OpenedAt: '2015-04-07T09:04:28+00:00'
          CancelledAt: '2015-04-07T09:18:24+00:00'
    ApiErrorWrapper:
      description: The basic wrapper around every failed API response
      type: object
      properties:
        code:
          description: Numerical HTTP code
          type: integer
        status:
          description: String HTTP code
          type: string
        error:
          description: Playfab error code
          type: string
        errorCode:
          description: Numerical PlayFab error code
          type: integer
        errorMessage:
          description: Description for the PlayFab errorCode
          type: string
        errorDetails:
          description: Detailed description of individual issues with the request object
          type: object
      required:
        - code
        - errorCode
    TradeInfo:
      type: object
      properties:
        AcceptedInventoryInstanceIds:
          description: >-
            Item instances from the accepting player that are used to fulfill
            the trade. If null, no one has accepted the trade.
          type: array
          items:
            type: string
        AcceptedPlayerId:
          description: >-
            The PlayFab ID of the player who accepted the trade. If null, no one
            has accepted the trade.
          type: string
        AllowedPlayerIds:
          description: >-
            An optional list of players allowed to complete this trade. If null,
            anybody can complete the trade.
          type: array
          items:
            type: string
        CancelledAt:
          description: If set, The UTC time when this trade was canceled.
          type: string
        FilledAt:
          description: If set, The UTC time when this trade was fulfilled.
          type: string
        InvalidatedAt:
          description: If set, The UTC time when this trade was made invalid.
          type: string
        OfferedCatalogItemIds:
          description: The catalogItem Ids of the item instances being offered.
          type: array
          items:
            type: string
        OfferedInventoryInstanceIds:
          description: The itemInstance Ids that are being offered.
          type: array
          items:
            type: string
        OfferingPlayerId:
          description: The PlayFabId for the offering player.
          type: string
        OpenedAt:
          description: The UTC time when this trade was created.
          type: string
        RequestedCatalogItemIds:
          description: The catalogItem Ids requested in exchange.
          type: array
          items:
            type: string
        Status:
          allOf:
            - $ref: '#/components/schemas/TradeStatus'
          description: Describes the current state of this trade.
        TradeId:
          description: The identifier for this trade.
          type: string
    TradeStatus:
      type: string
      enum:
        - Invalid
        - Opening
        - Open
        - Accepting
        - Accepted
        - Filled
        - Cancelled
  responses:
    CancelTradeResponse:
      description: ''
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: integer
                description: >-
                  The Http status code. If X-ReportErrorAsSuccess header is set
                  to true, this will report the actual http error code.
              status:
                type: string
                description: The Http status code as a string.
              data:
                $ref: '#/components/schemas/CancelTradeResponse'
            example:
              code: 200
              status: OK
              data:
                Trade:
                  Status: Cancelled
                  TradeId: D819CEC225EA9948C351
                  OfferingPlayerId: CD803BF233CE76CC
                  OfferedInventoryInstanceIds:
                    - '1359447'
                    - '635691'
                  RequestedCatalogItemIds:
                    - rare_hat_7
                  OpenedAt: '2015-04-07T09:04:28+00:00'
                  CancelledAt: '2015-04-07T09:18:24+00:00'
    ApiErrorWrapper:
      description: This is the outer wrapper for all responses with errors
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorWrapper'
  securitySchemes:
    SessionTicket:
      type: apiKey
      in: header
      name: X-Authorization
      description: >-
        This API requires a client session ticket, available from any Client
        Login function.

````

## Related topics

- [Cancel Trade](/services/playfab/api-references/rest/client/trading/cancel-trade.md)
- [Trading](/services/playfab/economy-monetization/economy/trading/index.md)
- [Using Player inventory](/services/playfab/player-progression/player-data/player-inventory.md)
- [Accept Trade](/services/playfab/api-references/rest/client/trading/accept-trade.md)
- [Open Trade](/services/playfab/api-references/rest/client/trading/open-trade.md)
