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

# Exchange at a fixed rate

> Execute an exchange using a valid fixed quote from [/exchange/calculate](/api-reference/endpoints/exchange-calculate).

Execute a fixed exchange using a valid quote from [/exchange/calculate](/api-reference/endpoints/exchange-calculate). The exchange request must be sent before the quote expires and must use the same amount and price as in the quote.


## OpenAPI

````yaml POST /exchange/fixed
openapi: 3.0.0
info:
  title: Merchant Backend V2
  version: '1.0'
  description: Documentation for merchant backend processing endpoints
servers:
  - url: https://app.cryptoprocessing.com/api/v2
security:
  - xProcessingKey: []
tags:
  - name: Status
  - name: Balance
  - name: Currencies
  - name: Deposit addresses
  - name: Withdrawal
  - name: Exchange
  - name: Invoices
  - name: Transactions
paths:
  /exchange/fixed:
    post:
      tags:
        - Exchange
      summary: Exchange at a fixed exchange rate
      description: >-
        Execute an exchange using a valid fixed quote from
        [/exchange/calculate](/api-reference/endpoints/exchange-calculate).
      operationId: post-exchange-fixed
      parameters:
        - $ref: '#/components/parameters/XProcessingSignatureHeader'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                sender_currency:
                  type: string
                  description: >-
                    Currency to exchange from. For a list of all available
                    currencies, see [API currency
                    codes](/api-reference/currency-codes).
                receiver_currency:
                  type: string
                  description: >-
                    Currency to exchange to. For a list of all available
                    currencies, see [API currency
                    codes](/api-reference/currency-codes).
                sender_amount:
                  type: number
                  description: >-
                    Amount to send. You must include either this parameter or
                    `receiver_amount`. This value must match the quote returned
                    by `/exchange/calculate`.
                receiver_amount:
                  type: number
                  description: >-
                    Amount to receive. You must include either this parameter or
                    `sender_amount`. This value must match the quote returned by
                    `/exchange/calculate`.
                foreign_id:
                  type: string
                  description: Unique ID of the exchange transaction.
                price:
                  type: number
                  description: >-
                    The quoted exchange rate from `/exchange/calculate`,
                    expressed as units of `receiver_currency` for 1 unit of
                    `sender_currency`. This value must match the quote.
              required:
                - sender_currency
                - receiver_currency
                - foreign_id
                - price
            examples:
              sender_amount:
                value:
                  sender_currency: BTC
                  receiver_currency: EUR
                  sender_amount: 0.003
                  foreign_id: test_foreign_id_0250
                  price: '77314.26444333'
              receiver_amount:
                value:
                  sender_currency: BTC
                  receiver_currency: EUR
                  receiver_amount: 100
                  foreign_id: test_foreign_id_0310
                  price: 77314.40676655
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    required:
                      - id
                      - foreign_id
                      - type
                      - sender_amount
                      - sender_currency
                      - receiver_amount
                      - receiver_currency
                      - fee_amount
                      - fee_currency
                      - price
                      - status
                    properties:
                      id:
                        type: integer
                        description: Transaction ID.
                      foreign_id:
                        type: string
                        description: This exchange's unique identifier in your system.
                      type:
                        type: string
                        description: Transaction type.
                      sender_amount:
                        type: string
                        description: The amount being exchanged.
                      sender_currency:
                        type: string
                        description: The currency being exchanged from.
                      receiver_amount:
                        type: string
                        description: The amount to be received.
                      receiver_currency:
                        type: string
                        description: The currency being exchanged to.
                      fee_amount:
                        type: string
                        description: >-
                          The exchange fee amount. If the fee is charged in the
                          sender currency, the total debited amount is
                          `sender_amount + fee_amount`.
                      fee_currency:
                        type: string
                        description: The currency in which the exchange fee is charged.
                      price:
                        type: string
                        description: >-
                          The quoted exchange rate from `/exchange/calculate`,
                          expressed as units of `receiver_currency` for 1 unit
                          of `sender_currency`.
                      status:
                        type: string
                        description: Exchange status.
              examples:
                sender_amount:
                  value:
                    data:
                      sender_currency: BTC
                      sender_amount: '0.00300000'
                      receiver_currency: EUR
                      receiver_amount: '231.94279333'
                      fee_currency: BTC
                      fee_amount: '0.00015000'
                      price: '77314.26444333'
                      id: 134704049
                      foreign_id: test_foreign_id_0250
                      type: exchange
                      status: processing
                receiver_amount:
                  value:
                    data:
                      sender_currency: BTC
                      sender_amount: '0.00129342'
                      receiver_currency: EUR
                      receiver_amount: '100.00000000'
                      fee_currency: BTC
                      fee_amount: '0.00006467'
                      price: '77314.40676655'
                      id: 134704197
                      foreign_id: test_foreign_id_0310
                      type: exchange
                      status: processing
        '400':
          description: Bad Request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationOrMalformedJson'
              examples:
                Rate expired:
                  summary: Fixed rate has expired
                  value:
                    errors:
                      message: Fix time is up. Exchange price is changed.
                Insufficient balance:
                  summary: Not enough balance for exchange
                  value:
                    errors:
                      sender_amount: 'Insufficient balance. Available: 0.00500000 BTC'
                Invalid sender currency:
                  summary: Sender currency not supported
                  value:
                    errors:
                      sender_currency: Currency not supported
                Invalid receiver currency:
                  summary: Receiver currency not supported
                  value:
                    errors:
                      receiver_currency: Currency not supported
                Invalid amount:
                  summary: Amount below minimum or invalid
                  value:
                    errors:
                      sender_amount: The amount must be at least 0.00010000 BTC
                Missing foreign_id:
                  summary: Foreign ID missing
                  value:
                    errors:
                      foreign_id: The foreign_id field is required
                Malformed JSON:
                  summary: Invalid JSON body
                  value:
                    error: Bad content format
                    code: bad_content_format
        '403':
          $ref: '#/components/responses/HeaderAuthorization'
components:
  parameters:
    XProcessingSignatureHeader:
      name: X-Processing-Signature
      in: header
      required: true
      description: >-
        Hex-encoded HMAC-SHA512 signature of the request body, [generated using
        your secret key](/api-reference/authentication).
      schema:
        type: string
  schemas:
    ValidationOrMalformedJson:
      oneOf:
        - type: object
          title: ValidationError
          description: One or more request parameters failed validation.
          properties:
            errors:
              type: object
              additionalProperties:
                type: string
        - type: object
          title: MalformedJson
          description: >-
            The request body is not valid JSON or the Content-Type header is not
            set to `application/json`.
          properties:
            error:
              type: string
            code:
              type: string
  responses:
    HeaderAuthorization:
      description: |
        Forbidden
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                description: Human-readable error message.
              code:
                type: string
                description: Error code.
            description: >-
              Invalid or missing headers. Refer to
              [Errors](/api-reference/errors#403) for troubleshooting steps.
          examples:
            Bad signature header:
              value:
                error: Bad signature header
                code: bad_header_signature
            No signature header:
              value:
                error: No signature header
                code: required_header_signature
            Bad key header:
              value:
                error: Bad key header
                code: bad_header_key
            No key header:
              value:
                error: No key header
                code: required_header_key
  securitySchemes:
    xProcessingKey:
      type: apiKey
      description: Your [API key](/integration-guide/get-your-api-key).
      in: header
      name: X-Processing-Key

````