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

# Generate a reverse quote

> Creates a time-limited quote previewing the amounts and differential for reversing an existing trade.

<Warning>
  **v1 sunsets December 31, 2026.** Migrate to v2 — see the [migration guide](/v1/migration-v1-to-v2).
</Warning>

Generates a time-limited quote that previews the amounts and differential for reversing an existing trade. Pass the returned quote's `id` to [Reverse a trade](/v1/api-reference/trade/reverse-trade).

Use this endpoint to:

* Preview the reversal amount and differential before committing
* Get a guaranteed rate for the reversal
* Decide whether a reversal is worth executing

<Note>
  Idempotency is supported on v2 and v3 for this endpoint. v1 does not support idempotency keys — see [Migration guide](/v1/migration-v1-to-v2).
</Note>

## Errors

| Status | Message                                                                         | Notes                                                                       |
| ------ | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| 400    | `Query validation failed`                                                       | Request didn't match schema (bad trade ID, invalid `quoteForSeconds`, etc.) |
| 401    | `The authorization key provided is either invalid or expired, please try again` | Mint a fresh JWT — see [Authentication](/v1/authentication)                 |
| 404    | `Trade not found`                                                               | `tradeId` doesn't resolve to a record on this org                           |
| 500    | `Something went wrong, please try again later`                                  | Quote-engine failure; request a fresh reverse quote                         |

See the full [v1 error reference](/v1/errors).


## OpenAPI

````yaml POST /v1/brokerage/{orgId}/trade/reverse-quote
openapi: 3.1.0
info:
  title: Overview of OpenFX APIs
  description: >-
    OpenFX provides a robust and secure API suite engineered for high
    performance and reliability, enabling programmatic access to real-time
    market data, trade execution, and money movement functionalities. This guide
    will walk through the step-by-step process of deposits, quoting, trading,
    settlements and monitoring using OpenFX APIs.
  version: v1.0.0
  termsOfService: https://www.openfx.com/terms
  contact:
    name: OpenFX Support
    email: support@openfx.com
    url: https://www.openfx.com
servers:
  - url: https://api.openfx.com
    description: OpenFX API Server
security:
  - bearerAuth: []
tags:
  - name: MarketData
    description: >-
      This endpoint retrieves a complete list of all tradable fiat and
      stablecoin currency pairs on the OpenFX platform.
  - name: Balances
    description: >-
      The Balance endpoints enable real-time tracking and management of currency
      holdings within an account.
  - name: Trade
    description: >-
      The Trade APIs facilitate programmatic currency exchange through a
      quote-then-trade workflow, ensuring price transparency and guaranteed
      execution at quoted rates.
  - name: Deposits
    description: >-
      Deposit endpoints enable secure funding of trading accounts across
      multiple supported currencies and methods.
  - name: Withdrawals
    description: >-
      The Withdrawal API facilitates secure fund withdrawals for both fiat and
      stablecoins.
paths:
  /v1/brokerage/{orgId}/trade/reverse-quote:
    post:
      tags:
        - Trade
      summary: Generate a reverse quote
      description: >-
        Generates a time-limited quote that previews the amounts and
        differential for reversing an existing trade.


        **Idempotency (V2 only):** This endpoint requires an `Idempotency-Key`
        header. Keys are cached for 30 minutes. Reusing a key with the same
        parameters returns the cached response; different parameters return a
        422 error.
      operationId: reverseQuote
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            format: uuid
            example: 323e4567-e89b-42d3-a456-426614174000
          description: >-
            V2 only. Unique key for an idempotent reverse quote request. Valid
            for 30 minutes.
        - schema:
            type: string
          in: path
          name: orgId
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                tradeId:
                  type: string
                  format: uuid
                  example: 123e4567-e89b-42d3-a456-426614174000
                  description: Unique identifier of the trade to reverse
                quoteForSeconds:
                  type: number
                  enum:
                    - 3
                    - 15
                    - 30
                    - 45
                    - 60
                  default: 3
                  example: 30
                  description: Requested reverse quote expiry validity in seconds.
              required:
                - tradeId
      responses:
        '200':
          description: Reverse quote generated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - success
                      - error
                    example: success
                  data:
                    type: object
                    properties:
                      quote:
                        type: object
                        properties:
                          id:
                            type: string
                            format: uuid
                            example: 223e4567-e89b-42d3-a456-426614174000
                            description: Unique identifier for the reverse quote
                          buy:
                            type: string
                            example: USD
                            description: Currency the user would buy
                          sell:
                            type: string
                            example: USDC
                            description: Currency the user would sell
                          buyAmount:
                            type: number
                            example: 999.5
                            description: Amount of the buy currency
                          sellAmount:
                            type: number
                            example: 1000
                            description: Amount of the sell currency
                          quoteAmount:
                            type: number
                            example: 999.5
                            description: Quoted reversal amount
                          createdAt:
                            type: string
                            example: '2026-07-13T10:00:00.000Z'
                            description: UTC timestamp when the reverse quote was created
                          expiresAt:
                            type: string
                            example: '2026-07-13T10:00:30.000Z'
                            description: UTC timestamp when the reverse quote expires
                          reversalDetails:
                            type: object
                            properties:
                              direction:
                                type: string
                                enum:
                                  - DEBIT
                                  - CREDIT
                                example: DEBIT
                              differentialAmount:
                                type: number
                                example: 0.75
                              currency:
                                type: string
                                example: USD
                            required:
                              - direction
                              - differentialAmount
                              - currency
                        required:
                          - id
                          - buy
                          - sell
                          - buyAmount
                          - sellAmount
                          - quoteAmount
                          - createdAt
                          - expiresAt
                          - reversalDetails
                    required:
                      - quote
                  message:
                    type: string
                    example: Data fetched successfully
                required:
                  - data
              examples:
                default_example:
                  value:
                    status: success
                    message: Reverse quote generated successfully
                    data:
                      quote:
                        id: 223e4567-e89b-42d3-a456-426614174000
                        buy: USD
                        sell: USDC
                        buyAmount: 999.5
                        sellAmount: 1000
                        quoteAmount: 999.5
                        createdAt: '2026-07-13T10:00:00.000Z'
                        expiresAt: '2026-07-13T10:00:30.000Z'
                        reversalDetails:
                          direction: DEBIT
                          differentialAmount: 0.75
                          currency: USD
        '400':
          description: Bad Request
          content:
            application/json:
              examples:
                default_example:
                  value:
                    status: error
                    message: Query validation failed
        '401':
          description: Unauthorized
          content:
            application/json:
              examples:
                default_example:
                  value:
                    status: error
                    message: >-
                      The authorization key provided is either invalid or
                      expired, please try again
        '404':
          description: Trade not found
          content:
            application/json:
              examples:
                default_example:
                  value:
                    status: error
                    message: Trade not found
                    error:
                      code: TRADE_NOT_FOUND
        '409':
          description: Conflict
          content:
            application/json:
              examples:
                default_example:
                  value:
                    status: error
                    message: Request with this idempotency key is currently processing
                    error:
                      code: IDEMPOTENCY_IN_FLIGHT
                      details: Please wait for the original request to complete
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              examples:
                default_example:
                  value:
                    status: error
                    message: Idempotency key reused with different parameters
                    error:
                      code: IDEMPOTENCY_MISMATCH
                      details: >-
                        This idempotency key was already used with different
                        request parameters
        '500':
          description: Reverse quote request failed
          content:
            application/json:
              examples:
                default_example:
                  value:
                    status: error
                    message: Something went wrong, please try again later
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````