> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ca.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 quote from [/v2/exchange/calculate](/api-reference/endpoints/exchange-calculate).

Send the request before the quote expires (`ts_release`), with the quote's currencies, the same amount field and amount, and its `price` exactly as returned. Each quote can be used for one request only.

For every error this endpoint returns and what it means, see [API errors: Exchange at a fixed rate](https://docs.ca.cryptoprocessing.com/api-reference/errors.md#exchange-at-a-fixed-rate).


## OpenAPI

````yaml POST /v2/exchange/fixed
openapi: 3.1.0
info:
  title: Merchant Backend V2
  version: '1.0'
  description: Documentation for merchant backend processing endpoints
servers:
  - url: https://app.ca.cryptoprocessing.com/api
security:
  - xProcessingKey: []
tags:
  - name: Status
  - name: Balance
  - name: Currencies
  - name: Deposit addresses
  - name: Withdrawal
  - name: Exchange
  - name: Invoices
  - name: Transactions
paths:
  /v2/exchange/fixed:
    post:
      tags:
        - Exchange
      summary: Exchange at a fixed exchange rate
      description: >-
        Execute an exchange using a valid quote from
        [/v2/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:
                  oneOf:
                    - type: string
                    - type: number
                  description: >
                    The amount you want to exchange, in `sender_currency`, as a
                    decimal string (for example, `"100"`) or a number. Include
                    either this parameter or `receiver_amount`, not both. It
                    must be the amount field and amount of the quote from
                    `/v2/exchange/calculate`.


                    Up to 8 decimal places.
                receiver_amount:
                  oneOf:
                    - type: string
                    - type: number
                  description: >
                    The amount you want to receive, in `receiver_currency`,
                    before the exchange fee, as a decimal string (for example,
                    `"100"`) or a number. Include either this parameter or
                    `sender_amount`, not both. It must be the amount field and
                    amount of the quote from `/v2/exchange/calculate`.


                    Up to 8 decimal places.
                foreign_id:
                  type: string
                  maxLength: 255
                  description: "Unique ID of this exchange in your system, up to\_255\_characters. It must be unique among your withdrawals and exchanges, and it's case-insensitive."
                price:
                  oneOf:
                    - type: string
                    - type: number
                  description: "The quote's `price` from `/v2/exchange/calculate` (units of `receiver_currency` for\_1\_unit of `sender_currency`), exactly as returned: a rounded value or one with extra trailing zeros doesn't match the quote."
                  example: '0.99978134'
              required:
                - sender_currency
                - receiver_currency
                - foreign_id
                - price
            examples:
              "Convert 100\_USDC to USD":
                value:
                  sender_currency: USDC
                  receiver_currency: USD
                  sender_amount: 100
                  foreign_id: exchange_123
                  price: '0.99978134'
              "Convert USDC to receive 100\_USD":
                value:
                  sender_currency: USDC
                  receiver_currency: USD
                  receiver_amount: 100
                  foreign_id: exchange_123
                  price: '0.99980412'
              "Convert 0.01\_ETH to USDC":
                value:
                  sender_currency: ETH
                  receiver_currency: USDC
                  sender_amount: '0.01'
                  foreign_id: exchange_123
                  price: '2464.10773508'
      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: `exchange`.'
                      sender_amount:
                        type: string
                        description: >-
                          The amount exchanged from `sender_currency`: the
                          `sender_amount` from the request, or the amount
                          calculated for the `receiver_amount` you sent. It
                          doesn't include the exchange fee (see `fee_amount`).
                      sender_currency:
                        type: string
                        description: The currency being exchanged from.
                      receiver_amount:
                        type: string
                        description: >-
                          The amount the exchange gives in `receiver_currency`:
                          the `receiver_amount` from the request, or the amount
                          calculated for the `sender_amount` you sent. It's the
                          amount before the exchange fee: if the fee is charged
                          in `receiver_currency`, the amount added to your
                          balance is `receiver_amount` − `fee_amount`.
                      receiver_currency:
                        type: string
                        description: The currency being exchanged to.
                      fee_amount:
                        type: string
                        description: >-
                          The exchange fee. If it's charged in
                          `sender_currency`, the amount taken from your balance
                          is `sender_amount` + `fee_amount`; if it's charged in
                          `receiver_currency`, the amount added to your balance
                          is `receiver_amount` − `fee_amount`. `0.00000000` when
                          no fee is charged, for example for an exchange between
                          the same currency on different networks.
                      fee_currency:
                        type: string
                        description: >-
                          The currency the exchange fee is charged in:
                          `sender_currency` or `receiver_currency`.
                      price:
                        type: string
                        description: "The quoted exchange rate from `/v2/exchange/calculate`: units of `receiver_currency` for\_1\_unit of `sender_currency`."
                        example: '0.99978134'
                      status:
                        type: string
                        description: >-
                          Exchange status. An [exchange
                          callback](/api-reference/callbacks/exchange-callbacks)
                          is sent when the status changes to `confirmed`.
              examples:
                "Convert 100\_USDC to USD":
                  value:
                    data:
                      sender_currency: USDC
                      sender_amount: '100.00000000'
                      receiver_currency: USD
                      receiver_amount: '99.97813400'
                      fee_currency: USD
                      fee_amount: '0.99978134'
                      price: '0.99978134'
                      id: 132541744
                      foreign_id: exchange_123
                      type: exchange
                      status: processing
                "Convert USDC to receive 100\_USD":
                  value:
                    data:
                      sender_currency: USDC
                      sender_amount: '100.01959184'
                      receiver_currency: USD
                      receiver_amount: '100.00000000'
                      fee_currency: USD
                      fee_amount: '1.00000000'
                      price: '0.99980412'
                      id: 132541748
                      foreign_id: exchange_123
                      type: exchange
                      status: processing
                "Convert 0.01\_ETH to USDC":
                  value:
                    data:
                      sender_currency: ETH
                      sender_amount: '0.01000000'
                      receiver_currency: USDC
                      receiver_amount: '24.64107735'
                      fee_currency: USDC
                      fee_amount: '0.02464107'
                      price: '2464.10773508'
                      id: 132541752
                      foreign_id: exchange_123
                      type: exchange
                      status: processing
        '400':
          description: Bad Request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationOrMalformedJson'
              examples:
                Quote expired, used or not matching:
                  value:
                    errors:
                      price: Fix time is up. Exchange price is changed.
                Not enough balance:
                  value:
                    errors:
                      sender_amount: >-
                        Not enough balance. You have required at least <amount>
                        <currency>
                Sender currency doesn't exist:
                  value:
                    errors:
                      sender_currency: The selected sender currency is invalid.
                Receiver currency doesn't exist:
                  value:
                    errors:
                      receiver_currency: The selected receiver currency is invalid.
                Same currency on both sides:
                  value:
                    errors:
                      receiver_currency: >-
                        The receiver currency and sender currency must be
                        different.
                Pair not supported or currency not enabled:
                  value:
                    errors:
                      sender_amount: Exchange is unavailable for given currencies
                Amount zero or negative:
                  value:
                    errors:
                      sender_amount: The sender amount must be greater than 0.
                Amount not a number:
                  value:
                    errors:
                      sender_amount: The sender amount must be a number.
                Both amounts sent:
                  value:
                    errors:
                      receiver_amount: >-
                        The receiver amount field can not be used when the
                        sender amount field is presented.
                Missing fields:
                  value:
                    errors:
                      sender_currency: The sender currency field is required.
                      receiver_currency: The receiver currency field is required.
                      receiver_amount: >-
                        The receiver amount field is required when the sender
                        amount field is not presented.
                      foreign_id: The foreign id field is required.
                      price: The price field is required.
                Price not a number:
                  value:
                    errors:
                      price: The price must be a number.
                Sender currency not a string:
                  value:
                    errors:
                      sender_currency: The sender currency must be a string.
                Foreign ID already used:
                  value:
                    errors:
                      foreign_id: The foreign id has already been taken.
                "Foreign ID longer than\_255\_characters":
                  value:
                    errors:
                      foreign_id: The foreign id may not be greater than 255 characters.
                Malformed JSON:
                  value:
                    error: Bad content format
                    code: bad_content_format
        '403':
          $ref: '#/components/responses/HeaderAuthorization'
        '429':
          $ref: '#/components/responses/TooManyRequests'
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
              description: >
                A map of request field names to a human-readable validation
                error message for that field. The exact set of possible keys and
                messages is endpoint-specific — see [API
                errors](/api-reference/errors#errors-by-endpoint) for the full
                reference.
              additionalProperties:
                type: string
                description: Human-readable validation error message for this field.
        - 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, or the API key does not have access to
              the endpoint. Refer to
              [Errors](/api-reference/errors#general-errors) for troubleshooting
              steps.
          examples:
            Bad signature header:
              value:
                error: Bad signature header
                code: bad_header_signature
            API key does not have the required ability:
              value:
                error: The API key does not have access to this endpoint.
                code: api_key_ability_required
            No signature header:
              value:
                error: No signature header
                code: required_header_signature
            No key header:
              value:
                error: No key header
                code: required_header_key
    TooManyRequests:
      description: >
        Too Many Requests


        You sent too many requests in a short time. The limit is counted per API
        key, so requests from all your servers that use the same key count
        together. Wait before you send the request again, increasing the delay
        if you get `429` again, and handle this error by its status code, not by
        a particular response body. See [Too many
        requests](/api-reference/errors#too-many-requests-429-too-many-requests).
  securitySchemes:
    xProcessingKey:
      type: apiKey
      description: Your [API key](/merchant-administration/generate-and-activate-api-keys).
      in: header
      name: X-Processing-Key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.