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

> Creates a new quote for a currency pair and amount, returning a quote ID and guaranteed rate.

Creates a new quote for a specific currency pair and amount, returning a quote ID and guaranteed rate valid for 3 seconds by default. Set `quoteForSeconds` to extend validity up to 60 seconds.

Use this endpoint to:

* Get real-time exchange rates
* Lock in rates for trading
* Calculate exchange amounts
* Review applicable fees and margins

<Note>**Idempotency required.** This POST requires an `Idempotency-Key` header. Keys are cached for 30 minutes. Reusing the same key with the same body returns the cached response; reusing it with different parameters returns a 422 error.</Note>

## Errors

| Status | Message                                                                         | Notes                                                                                      |
| ------ | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| 400    | `Query validation failed`                                                       | Request didn't match schema (e.g. unsupported currency pair, missing required field)       |
| 401    | `The authorization key provided is either invalid or expired, please try again` | Mint a fresh JWT — see [Authentication](/v2/authentication)                                |
| 409    | `Request with this idempotency key is currently processing`                     | See [Errors → Idempotency](/v2/errors#idempotency-errors)                                  |
| 422    | `Idempotency key reused with different parameters`                              | New body → new key                                                                         |
| 500    | `Error while creating a quote, please try again later`                          | Pricing engine or upstream rate provider unavailable. Retry with a **new** idempotency key |

See the full [v2 error reference](/v2/errors) for retry semantics and idempotency-specific codes.


## OpenAPI

````yaml POST /v2/brokerage/{orgId}/generate_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: v2.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:
  /v2/brokerage/{orgId}/generate_quote:
    post:
      tags:
        - Trade
      summary: Generate quote
      description: >
        Creates a new quote for a specific currency pair and amount, returning a
        quote ID and guaranteed rate valid for 3 seconds.
              
        Use this endpoint to:
                - Get real-time exchange rates
                - Lock in rates for trading
                - Calculate exchange amounts
                - Review applicable fees and margins
              
        **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: generateQuote
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            format: uuid
            example: 123e4567-e89b-12d3-a456-426614174000
          description: >-
            Unique key to ensure idempotent requests. UUID v4 recommended. Valid
            for 30 minutes.
        - schema:
            type: string
          in: path
          name: orgId
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                amount:
                  type: number
                  exclusiveMinimum: 0
                  example: 1000
                buy:
                  type: string
                  example: USDC
                sell:
                  type: string
                  example: USD
                referencedUnit:
                  type: string
                  example: USDC
                quoteForSeconds:
                  type: number
                  enum:
                    - 3
                    - 15
                    - 30
                    - 45
                    - 60
                  default: 3
                  example: 3
                  description: Requested quote expiry validity in seconds.
              required:
                - amount
                - buy
                - sell
                - referencedUnit
      responses:
        '200':
          description: success
          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: 123e4567-e89b-12d3-a456-426614174000
                            description: Unique identifier for the quote
                          userId:
                            type: string
                            format: uuid
                            example: 123e4567-e89b-12d3-a456-426614174001
                            description: >-
                              Unique identifier of the user who generated the
                              quote
                          buy:
                            type: string
                            example: USD
                            description: >-
                              Currency the user wants to buy (quote's target
                              currency)
                          sell:
                            type: string
                            example: USDC
                            description: >-
                              Currency the user wants to sell (quote's base
                              currency)
                          referencedUnit:
                            type: string
                            example: USD
                            description: Currency symbol used to reference the input amount
                          referencedAmount:
                            type: number
                            example: 1000
                            description: >-
                              Input amount in the referenced unit provided by
                              the user
                          quoteAmount:
                            type: number
                            example: 999.800000007998
                            description: >-
                              Calculated amount the user will receive or pay,
                              based on the reference amount
                          createdAt:
                            type: string
                            example: '2024-11-25T15:05:34.945Z'
                            description: UTC Timestamp when the quote was generated
                          expiryTimeinSeconds:
                            type: number
                            example: 3
                            description: Number of seconds until the quote expires
                  message:
                    type: string
                    example: Data fetched successfully
              examples:
                default_example:
                  value:
                    status: success
                    data:
                      quote:
                        id: 123e4567-e89b-12d3-a456-426614174000
                        userId: 123e4567-e89b-12d3-a456-426614174001
                        buy: USD
                        sell: USDC
                        referencedUnit: USD
                        referencedAmount: 1000
                        quoteAmount: 999.800000007998
                        createdAt: '2024-11-25T15:05:34.945Z'
                        expiryTimeinSeconds: 3
        '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
        '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: Quote request failed
          content:
            application/json:
              examples:
                default_example:
                  value:
                    status: error
                    message: Error while creating a quote, please try again later
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````