> ## 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.

# Create an exchange order

> Send the checked form and route snapshot, save the order number from the response, and reuse the original key if you lose the creation response.

Create the order after the customer approves the amount and account details and [preflight](https://exchanger-api.iexexchanger.com/en/guides/exchange/quote-and-preflight.md) returns `can_create_order: true`. The API returns the order number and initial status.

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

The key needs the `public-api:exchange:orders:create` scope. The order belongs to the key owner. Generate an [HMAC v2 signature](https://exchanger-api.iexexchanger.com/en/start/authentication.md) for every request. [Request and response reference](https://exchanger-api.iexexchanger.com/en/api-reference/exchange/post-private-exchange-orders.md)

## 1. Prepare the body and save a retry key

| Field | Value |
| - | - |
| `route_id` | The selected exchange route ID. |
| `amount` | The amount the customer sends, as a decimal string. The equivalent field is `income_amount`. |
| `from_requisite` and `to_requisite` | Account details for either side when required by the form. Equivalent fields are `income_account` and `outcome_account`. |
| `fields_in`, `fields_out`, `direction_fields`, `user_fields` | Additional fields with keys from `operation_contract.contract.dynamic_fields`. For file fields, pass an [upload token](https://exchanger-api.iexexchanger.com/en/guides/exchange/files-and-verifications.md). |
| `snapshot` | The optional complete object from `result.preflight.snapshot`. Send it to have the exchange check the route settings before writing. |
| Other quote parameters | The same `type_rate`, `city_id`, `selected_fees`, `checkbox_agreements`, and any other parameters you used. |

Send one field from each pair of aliases. If you send both, their values must match. You can omit `outcome_amount` and its alias `receive_amount`. The exchange calculates the final amount to receive.

This example uses files from [preflight](https://exchanger-api.iexexchanger.com/en/guides/exchange/quote-and-preflight.md). Store a separate body and key for each new order. Adapt the example to your test installation and account details.

```bash Prepare theme={null}
jq -e --slurpfile input preflight-input.json '
  select(.state == 0 and .result.preflight.can_create_order == true)
  | select(.result.preflight.snapshot | type == "object")
  | $input[0] + {snapshot: .result.preflight.snapshot}
' preflight-response.json > order-input.json
```

The method accepts an optional `Idempotency-Key`. For a safe retry after a lost response, generate a key once for this order and save it alongside the request body.

```bash Key for a new order theme={null}
node -e "process.stdout.write(require('node:crypto').randomUUID())" > order-key.txt
```

## 2. Send the request

```bash Request theme={null}
node request.mjs POST '/api/v3/private/exchange/orders' \
  --json order-input.json \
  --idempotency-key "$(cat order-key.txt)"
```

```json 201 Created · response excerpt theme={null}
{
  "state": 0,
  "result": {
    "order": {
      "public_id": "2696843857965",
      "tracking_id": "01a1ff69-1d03-7c35-aa9e-784a66d64f88",
      "status": {
        "key": "pending_payment"
      },
      "amounts": {
        "give": "10",
        "receive": "12.5"
      }
    }
  }
}
```

Save `tracking_id` for order requests and `public_id` to display the order number. The example order is awaiting payment. Read the actual status and available actions from the API, then [get the payment instructions](https://exchanger-api.iexexchanger.com/en/guides/exchange/payment-and-status.md).

Order creation recalculates the amounts and checks the current limits and reserve. If `result.order.amounts` differs from the quote, show the customer the current order terms before payment. Use the amount and account details returned in the payment instructions.

## When the customer selects a city

Read `city_id` from the `id_<ID>` key in `result.operation.attributes.city_detail` for the chosen route. If cash handover is enabled for the city, include the agreed `handover` object in preflight as well.

| `handover.method` value | What to include |
| - | - |
| `office` | An `office_id` from `handover.offices`. |
| `courier` | The delivery address in `address`. |
| `agreement` | The `method` field is sufficient. |

## Split the amount across receiving accounts

When `result.operation.attributes.sell_currency.attributes.extra_out.enabled` is `true` in the route details, read `min_trigger_amount`, `min_payout_amount`, and `max_fields`. Send `extra_out` in preflight and order creation in place of one receiving account.

```json Order body excerpt theme={null}
{
  "extra_out": {
    "enabled": true,
    "fields": [
      { "label": "TEST-DESTINATION-A", "amount": "5" },
      { "label": "TEST-DESTINATION-B", "amount": "7.5" }
    ]
  }
}
```

Substitute account details for the selected currency and the amount for each share. The API truncates each share to that currency's precision. During creation, it checks that the allocation total equals the actual amount to receive. Adjust the shares if the rate or fee changes that amount. An AML check required for the receiving account rejects the split. Use one account and run preflight again.

## Retries and errors

| Situation | What to do |
| - | - |
| The response was lost | Retry the same method, path, and query parameters with the saved `order-input.json` and `order-key.txt`. Sign the new HTTP request with a fresh nonce. |
| HTTP 201 with `Idempotency-Replayed: true` | The response contains the saved result. Read the current status with a separate GET request. |
| HTTP 409, `idempotency_in_progress` | Wait for `Retry-After`, then try again with the same key and body. |
| HTTP 409, `idempotency_conflict` | Reconcile the original request and its outcome before creating another order. |
| HTTP 422 with field or snapshot errors | Fix the form or refresh the quote, then run preflight again. |
| HTTP 404 for a previously available route | If you sent a snapshot, check that the route is still in the catalog. For the same case without a snapshot, the API returns HTTP 422 with a `route` error. |
| HTTP 409, `validation_failed` for a file field | The API cannot claim the file token for this order. Check whether it is still valid and whether another order already claimed it. Upload a new file for the order if needed. |

If the original request created the order, a retry with the same key and body returns the saved answer even after the snapshot expires. If the API explicitly rejected the original request because of its snapshot, request a fresh quote and prepare a corrected request.

> [card] [Get payment instructions](https://exchanger-api.iexexchanger.com/en/guides/exchange/payment-and-status.md)
>
> Payment details, payment state, and available actions.

> [card] [Retry without a duplicate](https://exchanger-api.iexexchanger.com/en/guides/reliability/idempotency.md)
>
> Key format, replay behavior, and errors.


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