> ## 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 market rate

> Execute an exchange immediately at the current market rate, without requesting a quote.

The response shows the exchange rate used (`price`) and the fee. An [exchange callback](https://docs.ca.cryptoprocessing.com/api-reference/callbacks/exchange-callbacks.md) with `status` `confirmed` is sent when the exchange is completed.

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


## OpenAPI

````yaml POST /v2/exchange/now
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/now:
    post:
      tags:
        - Exchange
      summary: Exchange at market rate
      description: >-
        Execute an exchange immediately at the current market rate, without
        requesting a quote.
      operationId: post-exchange-now
      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.


                    Up to 8 decimal places, or fewer for some currency pairs.
                    The minimum is the `min_amount` of `sender_currency` in
                    [/v2/currencies/rates](/api-reference/endpoints/currencies-rates).
                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.


                    Up to 8 decimal places, or fewer for some currency pairs.
                    The minimum is the `min_amount` of `receiver_currency` in
                    [/v2/currencies/rates](/api-reference/endpoints/currencies-rates),
                    for the pair in the opposite direction.
                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."
              required:
                - sender_currency
                - receiver_currency
                - foreign_id
            examples:
              "Convert 100\_USDC to USD":
                value:
                  sender_currency: USDC
                  receiver_currency: USD
                  sender_amount: 100
                  foreign_id: exchange_123
              "Convert USDC to receive 100\_USD":
                value:
                  sender_currency: USDC
                  receiver_currency: USD
                  receiver_amount: 100
                  foreign_id: exchange_123
              "Convert 0.01\_ETH to USDC":
                value:
                  sender_currency: ETH
                  receiver_currency: USDC
                  sender_amount: '0.01'
                  foreign_id: exchange_123
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    required:
                      - sender_currency
                      - sender_amount
                      - receiver_currency
                      - receiver_amount
                      - fee_currency
                      - fee_amount
                      - price
                      - id
                      - foreign_id
                      - type
                      - status
                    properties:
                      sender_currency:
                        type: string
                        description: The currency being exchanged from.
                      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`).
                      receiver_currency:
                        type: string
                        description: The currency being exchanged to.
                      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`.
                      fee_currency:
                        type: string
                        description: >-
                          The currency the exchange fee is charged in:
                          `sender_currency` or `receiver_currency`.
                      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.
                      price:
                        type: string
                        description: "The exchange rate used: units of `receiver_currency` for\_1\_unit of `sender_currency`."
                        example: '0.99978134'
                      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`.'
                      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:
                Exchange rate not available:
                  value:
                    errors:
                      message: Exchange rate not available at this time
                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
                Sender amount below the minimum:
                  value:
                    errors:
                      sender_amount: The sender_amount must be at least <amount> <currency>
                Receiver amount below the minimum:
                  value:
                    errors:
                      receiver_amount: The receiver_amount must be at least <amount> <currency>
                Sender amount above the maximum:
                  value:
                    errors:
                      sender_amount: >-
                        The sender_amount may not be greater than <amount>
                        <currency>
                Sender amount with too many decimal places:
                  value:
                    errors:
                      sender_amount: We can process only <decimals> decimal places
                Receiver amount with too many decimal places:
                  value:
                    errors:
                      receiver_amount: We can process only <decimals> decimal places
                Sender amount zero or negative:
                  value:
                    errors:
                      sender_amount: The sender amount must be greater than 0.
                Receiver amount zero or negative:
                  value:
                    errors:
                      receiver_amount: The receiver 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.
                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.