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

# Exchange funds internally

> Exchange funds from one currency to another within a single budget.

## How it works

The following diagram describes the different steps required to exchange funds internally with Equals. Click on the image to enlarge it.

<img src="https://mintcdn.com/equalsmoney-0d00329a/Gcy_W3pNLgh52Qmj/images/diagram-exchange-in-budget.svg?fit=max&auto=format&n=Gcy_W3pNLgh52Qmj&q=85&s=d434cf0d68189922815a1310857b24af" alt="Diagram showing the steps required to exchange funds internally" width="2444" height="1691" data-path="images/diagram-exchange-in-budget.svg" />

## Exchange currencies within a budget

<Note>
  **POST** `/v2/orders/trade`
</Note>

### Before you start

To exchange currencies within a budget, you first need to [create a quote](/pages/payments/create-quotes) where:

* `type.from` and `type.to` are set to `balance`
* at least one of `sourceCurrency.amount` or `targetCurrency.amount` is provided
* `sourceCurrency.currency.budgetId` and `targetCurrency.currency.budgetId` are set to the ID of the parent budget

For example, to convert 10 `GBP` to `USD`:

<CodeGroup>
  ```bash Sample request theme={null}
  curl -i -X POST \
    'https://api.equalsmoney.com/v2/orders/quote?accountId=F12345' \
    -H 'Authorization: ApiKey YOUR_API_KEY_HERE' \
    -H 'Content-Type: application/json' \
    -d '{
      "sourceCurrency": {
        "amount": 10,
        "currency": {
          "budgetId": "b489ea2c-0dd1-4fb1-b345-de5a596a5527",
          "currencyCode": "GBP"
        }
      },
      "targetCurrency": {
        "currency": {
          "budgetId": "b489ea2c-0dd1-4fb1-b345-de5a596a5527",
          "currencyCode": "USD"
        }
      },
      "settlementDate": "20231001",
      "type": {
        "from": "balance",
        "to": "balance"
      }
    }'
  ```

  ```bash Request structure theme={null}
  curl -i -X POST \
    'https://api.equalsmoney.com/v2/orders/quote?accountId={accountId}' \
    -H 'Authorization: ApiKey YOUR_API_KEY_HERE' \
    -H 'Content-Type: application/json' \
    -d '{
      "sourceCurrency": {
        "amount": number,
        "currency": {
          "budgetId": "string",
          "currencyCode": "string"
        }
      },
      "targetCurrency": {
        "currency": {
          "budgetId": "string",
          "currencyCode": "string"
        }
      },
      "settlementDate": "string",
      "type": {
        "from": "string",
        "to": "string"
      }
    }'
  ```
</CodeGroup>

### Request

Use this request to exchange currencies within a budget, using the `orderId` and `quoteRequestId` returned when you [created a quote](/pages/payments/create-quotes).

<CodeGroup>
  ```bash Sample request theme={null}
  curl -i -X POST \
    'https://api.equalsmoney.com/v2/orders/trade?accountId=F12345' \
    -H 'Authorization: ApiKey YOUR_API_KEY_HERE' \
    -H 'Content-Type: application/json' \
    -d '{
      "orderId": "FPLZQVE5G2ZZKS",
      "quoteRequestId": "SLQMQKRV8NR32DA3T0GZ7OC1SNDKO7X1HH"
    }'
  ```

  ```bash Request structure theme={null}
  curl -i -X POST \
    'https://api.equalsmoney.com/v2/orders/trade?accountId={accountId}' \
    -H 'Authorization: ApiKey YOUR_API_KEY_HERE' \
    -H 'Content-Type: application/json' \
    -d '{
      "orderId": "string",
      "quoteRequestId": "string"
    }'
  ```
</CodeGroup>

#### Query parameters

<ParamField body="accountId" type="string" required>
  The ID of the account that you're creating an order for.

  Allowable values: An existing `accountId`
</ParamField>

#### Request body schema

<ParamField body="orderId" type="string" required>
  The ID of the order.

  Allowable values: An existing `orderId` (≤ 36 characters)
</ParamField>

<ParamField body="quoteRequestId" type="string" required>
  The ID of the quote request.

  Allowable values: An existing `quoteRequestId` (≤ 36 characters)
</ParamField>

### Response

If your request is successful, you'll receive a `200` response.

<CodeGroup>
  ```json Sample response theme={null}
  {
    "orderId": "FPLZQVE5G2ZZKS",
    "quoteRequestId": "SLQMQKRV8NR32DA3T0GZ7OC1SNDKO7X1HH",
    "settlement": {
      "date": "20230825",
      "price": {
        "amount": 10,
        "currency": "EUR"
      },
      "charges": {
        "fee": 0
      }
    },
    "quote": {
      "rate": 1,
      "inverseRate": 1,
      "fromGbpAmount": 10,
      "from": {
        "amount": 10,
        "currency": "GBP"
      },
      "to": {
        "amount": 10,
        "currency": "EUR"
      },
      "direction": "1"
    }
  }
  ```

  ```json Response structure theme={null}
  {
    "orderId": "string",
    "bank": "string",
    "settlement": {
      "date": "string",
      "price": {
        "amount": number,
        "currency": "string"
      },
      "charges": {
        "fee": number,
        "margin": number,
        "other": number
      }
    },
    "trade": {
      "rate": number,
      "inverseRate": number,
      "from": {
        "amount": number,
        "currency": "string"
      },
      "to": {
        "amount": number,
        "currency": "string"
      },
      "direction": "string"
    }
  }
  ```
</CodeGroup>

For more detailed information about this request and its response, [see the API reference](/api-reference/payments/create-an-order).
