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

# Settle a trade

> Settles an existing trade.

Settles an existing trade.

Use this endpoint to:

* Move a trade from its pending settlement window into a terminal settled state
* Confirm settlement timing for reconciliation

<Note>**Idempotency required.** This POST requires an `Idempotency-Key` header. Keys are cached for 24 hours. 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 (bad trade ID, missing fields, etc.)                |
| 401    | `The authorization key provided is either invalid or expired, please try again` | Mint a fresh JWT — see [Authentication](/v2/authentication)                     |
| 404    | `Trade not found`                                                               | `tradeId` doesn't resolve to a record on this org                               |
| 409    | `The trade cannot be settled`                                                   | The trade isn't in a settleable state (already settled, not yet executed, etc.) |
| 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    | `An internal error has occurred`                                                | Trade may or may not have settled — GET the trade by ID before retrying         |

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


## OpenAPI

````yaml POST /v2/brokerage/{orgId}/trade/settle
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}/trade/settle:
    post:
      tags:
        - Trade
      summary: Settle a trade
      description: >-
        Settles an existing trade.


        **Idempotency (V2 only):** This endpoint requires an `Idempotency-Key`
        header. Keys are cached for 24 hours. Reusing a key with the same
        parameters returns the cached response; different parameters return a
        422 error.
      operationId: settleTrade
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            format: uuid
            example: 323e4567-e89b-42d3-a456-426614174000
          description: >-
            V2 only. Unique key for an idempotent settle trade request. Valid
            for 24 hours.
        - 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 being settled
              required:
                - tradeId
      responses:
        '200':
          description: Trade settled successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - success
                      - error
                    example: success
                  data:
                    type: object
                    properties:
                      trade:
                        type: object
                        properties:
                          id:
                            type: string
                            format: uuid
                            example: 123e4567-e89b-42d3-a456-426614174000
                          buy:
                            type: string
                            example: USD
                          sell:
                            type: string
                            example: USDC
                          referencedUnit:
                            type: string
                            example: USD
                          referencedAmount:
                            type: number
                            example: 1000
                          amount:
                            type: number
                            example: 999.25
                          status:
                            type: string
                            example: SETTLED
                          transactedAt:
                            type: string
                            example: '2026-07-13T10:01:00.000Z'
                          quoteId:
                            type: string
                            format: uuid
                            example: 223e4567-e89b-42d3-a456-426614174000
                          clientReferenceId:
                            type:
                              - string
                              - 'null'
                            example: customer-settlement-20260713-001
                          settledAt:
                            type:
                              - string
                              - 'null'
                            example: '2026-07-13T10:02:00.000Z'
                          settlementStartTime:
                            type:
                              - string
                              - 'null'
                            example: '2026-07-13T10:00:30.000Z'
                        required:
                          - id
                          - buy
                          - sell
                          - referencedUnit
                          - referencedAmount
                          - amount
                          - status
                          - transactedAt
                          - quoteId
                          - clientReferenceId
                          - settledAt
                          - settlementStartTime
                    required:
                      - trade
                  message:
                    type: string
                    example: Data fetched successfully
                required:
                  - data
              examples:
                default_example:
                  value:
                    status: success
                    message: Trade settled successfully
                    data:
                      trade:
                        id: 123e4567-e89b-42d3-a456-426614174000
                        buy: USD
                        sell: USDC
                        referencedUnit: USD
                        referencedAmount: 1000
                        amount: 999.25
                        status: SETTLED
                        transactedAt: '2026-07-13T10:01:00.000Z'
                        quoteId: 223e4567-e89b-42d3-a456-426614174000
                        clientReferenceId: customer-settlement-20260713-001
                        settledAt: '2026-07-13T10:02:00.000Z'
                        settlementStartTime: '2026-07-13T10:00:30.000Z'
        '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: Trade cannot be settled
          content:
            application/json:
              examples:
                default_example:
                  value:
                    status: error
                    message: The trade cannot be settled
                    error:
                      code: TRADE_NOT_SETTLEABLE
        '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: Internal Server Error
          content:
            application/json:
              examples:
                default_example:
                  value:
                    status: error
                    message: An internal error has occurred
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````