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

# Quote an exchange and check the order

> Get the amount to receive for the selected route, pass the signed snapshot to preflight, and resolve form validation issues before creating the order.

Once the customer picks a route, quote the amount they want to send. Run preflight after they fill in the form to check whether the order has enough data to proceed.

The examples use route `2` and test account details. Substitute values from your installation at `https://your-exchange`. The commands use the [quickstart setup](https://exchanger-api.iexexchanger.com/en/start/quickstart.md) and `jq` for JSON processing. For your own HTTP client, follow the [signing rules](https://exchanger-api.iexexchanger.com/en/start/authentication.md).

## 1. Get a quote

```http HTTP request excerpt theme={null}
POST /api/v3/private/exchange/quotes HTTP/1.1
Host: your-exchange
Content-Type: application/json
```

Required scope is `public-api:exchange:quotes:read`. [Request and response reference](https://exchanger-api.iexexchanger.com/en/api-reference/exchange/post-private-exchange-quotes.md)

```json quote-input.json theme={null}
{
  "route_id": 2,
  "amount": "10"
}
```

```bash Request theme={null}
node request.mjs POST '/api/v3/private/exchange/quotes' \
  --json quote-input.json > quote-response.json
```

Send `amount` or its alias `income_amount` as a decimal string, for example `"10.50"`. `result.quote.amounts` contains the calculated amounts on both sides. The calculator accepts `route_id`, `direction_id`, or the two exchanger currency IDs. Supply both currency IDs if you select a pair without a route ID. If you include the route and currencies together, all values must identify the same route.

```json 200 OK · response excerpt theme={null}
{
  "state": 0,
  "result": {
    "quote": {
      "amounts": {
        "give": "10",
        "receive": "12.5"
      }
    }
  }
}
```

Show the customer `result.quote.rate` and the amount to receive. Read `components` and `adjustments` for the calculation breakdown. `base_rate` gives the rate before adjustments. If a city has an independent rate formula, the general base rate may be unavailable. In that case, `base_rate.available` is `false` and `value` and `display` are `null`.

| Selection in the form | What to send in the quote |
| - | - |
| `capabilities.rate` offers fixed or floating rates | `type_rate` with `fixed` or `floating`. |
| The route uses a city rate | `city_id` from the `id_<ID>` key in the route details. Choose a city available for that pair. |
| The customer chooses a fee option | `selected_fees` with the `id` and `scope` from `selector_fees.options`. `selector_fees.mode` governs single or multiple selection. |
| The customer checks an agreement | `checkbox_agreements` with the form keys. The exchange determines the fee amounts. |
| The route offers a card verification choice | `card_verification_required` with `true` or `false`. The route default applies if omitted. |
| The customer enters a promo code | `promo_code`. Check `result.quote.promo.applied`. An invalid or inapplicable code returns HTTP 422 with a `promo_code` field error. |

Use `selected_fees` to send a fee selection in new requests. The request fields `selected_fee_type` and `selector_fees` remain for compatibility. The API ignores `checkbox_fees`. The `selector_fees` response field still describes the available options.

Request another quote when the amount, city, or options change. A quote is an estimate. The funds remain available and the rate can change.

### Amount precision and snapshot expiration

The API accepts a decimal string or a positive JSON number in ordinary decimal notation. Send a string with a decimal point, without an exponent or grouping separators. Store and compare returned amounts with decimal arithmetic to preserve their digits.

| Value | Rule |
| - | - |
| Customer amount | `route.from.decimal` gives the input currency precision. With two decimal places, its smallest unit is `0.01`. The API rounds extra digits to the nearest value and rounds halfway values up. For example, `"10.005"` becomes `"10.01"`. If the amount rounds to zero, the API rejects it. |
| Route limits | The API rounds the minimum up and the maximum down to the precision of the currency on that side. A positive maximum below the smallest unit remains a limit, even if no positive amount is representable within it. |
| Quote and order amounts | `amounts.give` and `amounts.receive` are strings without trailing fractional zeros. These response fields truncate digits beyond the 18th decimal place. Read the amount to receive from the response, which accounts for the rate, fees, and any applied discount or promo code. |
| Snapshot lifetime | The default is 10 minutes. Read the actual deadline from `snapshot.expires_at`. The snapshot checks the route settings. The quote reflects the current calculation, and the rate can change by the time you create the order. |

If the route offers a rate mode, read `quote.rate.selected`. `fixed` and `floating` correspond to `type_rate` values 0 and 1. If you omit the parameter, the exchange applies the route default. The floating mode permits recalculation in statuses allowed by the exchange's settings. The exchange can configure separate recalculation rules for fixed orders. Refresh the order amounts from the API when the state changes.

## 2. Check the completed form

```http HTTP request excerpt theme={null}
POST /api/v3/private/exchange/orders/preflight HTTP/1.1
Host: your-exchange
Content-Type: application/json
```

Either `public-api:exchange:preflight:read` or `public-api:exchange:quotes:read` allows this request. [Request and response reference](https://exchanger-api.iexexchanger.com/en/api-reference/exchange/post-private-exchange-orders-preflight.md)

Add the account details and route fields to the same quote parameters. This example uses the snapshot in `quote-response.json` and test account details. `snapshot` is optional. Supply it to check whether the conditions of the quoted route have changed.

```bash Request theme={null}
jq -e --slurpfile input quote-input.json '
  select(.state == 0 and (.result.snapshot | type == "object"))
  | $input[0] + {
      from_requisite: "SANDBOX-DEMO-SOURCE",
      to_requisite: "SANDBOX-DEMO-DESTINATION",
      snapshot: .result.snapshot
    }
' quote-response.json > preflight-input.json &&
node request.mjs POST '/api/v3/private/exchange/orders/preflight' \
  --json preflight-input.json > preflight-response.json
```

```json 200 OK · response excerpt theme={null}
{
  "state": 0,
  "result": {
    "preflight": {
      "can_create_order": true,
      "missing_fields": [],
      "validation_issues": [],
      "checks": {
        "local": "passed",
        "external": "deferred"
      }
    }
  }
}
```

| What the API returns | Next action |
| - | - |
| `can_create_order: true` | Prepare the creation request. Read the fresh, complete snapshot from `result.preflight.snapshot`. |
| `checks.local: "not_run"` | Complete the fields in `missing_fields` and rerun preflight. |
| `checks.local: "failed"` | Show the messages in `validation_issues`. Use `field` to associate each message with the form. |
| `checks.external: "deferred"` | Some checks run during creation. Continue handling creation errors after preflight succeeds. |
| HTTP 422 with a `snapshot` field error | Request another quote and supply its fresh snapshot. Check `error.details.issues` or `error.details.fields`. |

Read the current form fields in `result.preflight.operation_contract` and the verification requirements in `result.preflight.requirements`. For application logic, read structured `validation_issues` with `field`, `code`, and `message`. The `validation_errors` map remains available for compatibility, and `allowed` has the same value as `can_create_order`.

The snapshot includes `expires_at` and a signature. Copy the complete object. A processed preflight can record an `order.preflight` event for subscribed [webhooks](https://exchanger-api.iexexchanger.com/en/guides/reliability/webhooks.md). Preflight does not create an order.

> [card] [Create an order](https://exchanger-api.iexexchanger.com/en/guides/exchange/create-order.md)
>
> Send the checked order data with a retry key.

> [card] [Handle errors](https://exchanger-api.iexexchanger.com/en/guides/reliability/errors.md)
>
> Error codes, fields, and retry conditions.

## Prompt for your coding agent

> [accordion] Calculate a quote and check the order form
>
> ```text theme={null}
> Implement a server-side quote → order preflight workflow for Exchanger API v3 in [STACK]. The inputs are the selected route, amount, and completed form. Show the user the quoted amount and whether the form is ready to submit.
>
> Check the contract against the documentation:
> - https://exchanger-api.iexexchanger.com/en/guides/exchange/catalog
> - https://exchanger-api.iexexchanger.com/en/guides/exchange/quote-and-preflight
> - https://exchanger-api.iexexchanger.com/en/start/authentication
> - https://exchanger-api.iexexchanger.com/en/guides/reliability/errors
>
> 1. Use signed HTTP on the server. Verify HMAC v2 against the documented example, set a timeout, and read configuration from the environment. Run tests against local mocks with synthetic values. Do not request real credentials or send requests to a live exchanger.
> 2. Call POST /api/v3/private/exchange/quotes with public-api:exchange:quotes:read. Send route_id, the amount as a decimal string, and only the options relevant to the selected route. Read amounts from result.quote.amounts and keep result.snapshot intact.
> 3. Add the snapshot and form fields to the quote input and call POST /api/v3/private/exchange/orders/preflight. Preflight accepts either public-api:exchange:preflight:read or public-api:exchange:quotes:read. Enable the next step only when result.preflight.can_create_order is true. When it is false, display missing_fields and validation_issues. checks.external: deferred means that external checks run during creation.
> 4. Request a fresh quote when the amount, route, or quote options change. On HTTP 422, inspect validation errors for the snapshot field. If the snapshot has expired, quote again and rerun preflight with the intact new object. Handle HTTP errors separately from a validation result delivered in HTTP 200. Return the validated form with result.preflight.snapshot to the caller on success. End the workflow at preflight without creating an order.
>
> Add local tests for a successful quote, decimal strings, unchanged snapshot forwarding, HTTP 200 with can_create_order: false, and a snapshot field error. Report the changed files and the command to run the tests.
> ```


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