# Create order

## <mark style="color:$warning;">\[POST]</mark> /api/v2/order

Creates an order. If a quote is provided, it uses the pricing from it.

Request body type:

{% code overflow="wrap" expandable="true" %}

```typescript
type RequestBody = {
  quoteId?: string;
  userCountryIsoCode: string; 
  userEmail: string;
  userIp: string;
  deposit: {
    paymentChannel: PaymentChannel;
    currencyType: CurrencyType;
    currencyCode: string;
    carrierCode?: string;
    countryIsoCode?: string; // required if currencyType is fiat
    amount?: number;
  },
  payout: {
    paymentChannel: PaymentChannel;
    currencyType: CurrencyType;
    currencyCode: string;
    carrierCode?: string;
    countryIsoCode?: string; // required if currencyType is fiat
    amount?: number;
  };
  fieldsToCreateOrder: Record<string, any>; // union of required fields from deposit and payout
  orderParams?: string; // merchant-defined reference
  callbackUrl?: string; // button URL on status page in the widget
  webhookUrl?: string; // optional webhook URL for this specific order status updates, it will override the default one set for the merchant
}
```

{% endcode %}

Request body example:

{% code overflow="wrap" expandable="true" %}

```json
{
    "userCountryIsoCode": "NG",
    "userEmail": "testuser+ng@fonbnk.com",
    "userIp": "223.134.123.12",
    "deposit": {
        "paymentChannel": "bank",
        "currencyType": "fiat",
        "currencyCode": "NGN",
        "countryIsoCode": "NG"
    },
    "payout": {
        "paymentChannel": "crypto",
        "currencyType": "crypto",
        "currencyCode": "POLYGON_USDT",
        "amount": 1
    },
    "fieldsToCreateOrder": {
        "blockchainWalletAddress": "0x5b7ae3c6c87f4a3f94b35c77233b13191ebfad20",
        "phoneNumber": "2348012345678",
        "bankCode": "1",
        "bankAccountNumber": "1234567890"
    }
}
```

{% endcode %}

Response type:

{% code overflow="wrap" expandable="true" %}

```typescript
type Response = {
  quoteId: string;
  quoteExpiresAt: Date;
  deposit: {
    paymentChannel: PaymentChannel;
    currencyType: CurrencyType;
    currencyCode: string;
    currencyDetails: OrderCurrencyDetails;
    cashout: Cashout;
    fieldsToCreateOrder: RequiredField[];
    transferType: TransferType;
  },
  payout: {
    paymentChannel: PaymentChannel;
    currencyType: CurrencyType;
    currencyCode: string;
    currencyDetails: OrderCurrencyDetails;
    cashout: Cashout;
    fieldsToCreateOrder: RequiredField[];
  }
}
```

{% endcode %}

Response example:

{% code overflow="wrap" expandable="true" %}

```json
{
    "quoteId": "6928130ca263ba8d44fad2cf",
    "quoteExpiresAt": "2025-11-27T09:29:56.167Z",
    "deposit": {
        "paymentChannel": "bank",
        "currencyType": "fiat",
        "currencyCode": "NGN",
        "currencyDetails": {
            "countryIsoCode": "NG"
        },
        "cashout": {
            "amountBeforeFees": 10000,
            "amountAfterFees": 9650,
            "chargedFees": [
                {
                    "id": "service_fee",
                    "type": "percentage",
                    "recipient": "platform",
                    "amount": 250
                },
                {
                    "id": "merchant_fee",
                    "type": "percentage",
                    "recipient": "merchant",
                    "amount": 100
                }
            ],
            "totalChargedFees": 350,
            "chargedFeesPerRecipient": {
                "platform": 250,
                "merchant": 100
            },
            "amountBeforeFeesUsd": 6.821794,
            "amountAfterFeesUsd": 6.583031,
            "chargedFeesUsd": [
                {
                    "id": "service_fee",
                    "type": "percentage",
                    "recipient": "platform",
                    "amount": 0.170545
                },
                {
                    "id": "merchant_fee",
                    "type": "percentage",
                    "recipient": "merchant",
                    "amount": 0.068218
                }
            ],
            "totalChargedFeesUsd": 0.238763,
            "exchangeRate": 1465.89,
            "exchangeRateAfterFees": 1519.0571,
            "chargedFeesPerRecipientUsd": {
                "platform": 0.170545,
                "merchant": 0.068218
            },
            "feeSettings": [
                {
                    "id": "service_fee",
                    "recipient": "platform",
                    "type": "percentage",
                    "value": 2.5,
                    "min": 0,
                    "max": "Infinity"
                },
                {
                    "id": "merchant_fee",
                    "recipient": "merchant",
                    "type": "percentage",
                    "value": 1,
                    "min": 0,
                    "max": "Infinity"
                }
            ]
        },
        "fieldsToCreateOrder": [
            {
                "key": "phoneNumber",
                "label": "Phone Number",
                "required": true,
                "type": "phone"
            },
            {
                "key": "bankCode",
                "label": "Bank name",
                "required": true,
                "type": "enum",
                "options": [
                    {
                        "label": "Sandbox Bank",
                        "value": "1"
                    },
                    {
                        "label": "Sandbox Bank 2",
                        "value": "2"
                    },
                    {
                        "label": "Sandbox Bank 3",
                        "value": "3"
                    }
                ]
            },
            {
                "key": "bankAccountNumber",
                "label": "Bank Account Number",
                "required": true,
                "type": "string"
            },
            {
                "key": "depositSandboxForcedFlow",
                "type": "enum",
                "label": "Sandbox deposit forced flow",
                "required": false,
                "defaultValue": "deposit_success",
                "options": [
                    {
                        "label": "Deposit success",
                        "value": "deposit_success"
                    },
                    {
                        "label": "Deposit invalid",
                        "value": "deposit_invalid"
                    },
                    {
                        "label": "Deposit underpayment (50%)",
                        "value": "deposit_underpayment"
                    },
                    {
                        "label": "Deposit overpayment (200%)",
                        "value": "deposit_overpayment"
                    }
                ]
            }
        ],
        "transferType": "manual"
    },
    "payout": {
        "paymentChannel": "crypto",
        "currencyType": "crypto",
        "currencyCode": "POLYGON_USDT",
        "currencyDetails": {
            "network": "POLYGON",
            "asset": "USDT",
            "contractAddress": "0x3b3a06b48119c035a2e86afdb69d9ad930643b3d"
        },
        "cashout": {
            "amountBeforeFees": 6.583031,
            "amountAfterFees": 6.582386,
            "chargedFees": [
                {
                    "id": "gas",
                    "type": "flat_amount",
                    "recipient": "blockchain",
                    "amount": 0.000645
                }
            ],
            "totalChargedFees": 0.000645,
            "chargedFeesPerRecipient": {
                "blockchain": 0.000645
            },
            "amountBeforeFeesUsd": 6.583031,
            "amountAfterFeesUsd": 6.582386,
            "chargedFeesUsd": [
                {
                    "id": "gas",
                    "type": "flat_amount",
                    "recipient": "blockchain",
                    "amount": 0.000645
                }
            ],
            "totalChargedFeesUsd": 0.000645,
            "exchangeRate": 1,
            "exchangeRateAfterFees": 1.0001,
            "chargedFeesPerRecipientUsd": {
                "blockchain": 0.000645
            },
            "feeSettings": [
                {
                    "id": "gas",
                    "recipient": "blockchain",
                    "type": "flat_amount",
                    "value": 0.000645,
                    "min": 0,
                    "max": "Infinity"
                }
            ]
        },
        "fieldsToCreateOrder": [
            {
                "key": "blockchainWalletAddress",
                "type": "string",
                "label": "Your wallet address",
                "required": true
            },
            {
                "key": "blockchainMemo",
                "type": "string",
                "label": "Memo",
                "required": false
            },
            {
                "key": "payoutSandboxForcedFlow",
                "type": "enum",
                "label": "Sandbox payout forced flow",
                "required": false,
                "defaultValue": "payout_success",
                "options": [
                    {
                        "label": "Payout success",
                        "value": "payout_success"
                    },
                    {
                        "label": "Payout failed",
                        "value": "payout_failed"
                    }
                ]
            }
        ]
    }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fonbnk.com/server-to-server/api-endpoints/create-order.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
