> For the complete documentation index, see [llms.txt](https://docs-processing.crypto-chief.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-processing.crypto-chief.com/payments/creating-a-payin.md). Agents can also search and read this documentation through its [MCP server](https://docs-processing.crypto-chief.com/~gitbook/mcp).

# Creating a PayIn

## **Create PayIn Order**

<mark style="color:green;">`POST`</mark> `https://api-processing.crypto-chief.com/v1/payments/order/create`

This endpoint initializes a payment session. To use it correctly, you must first choose your Business Logic Mode.

### 1. The Two Payment Mechanics

The system operates in two fundamentally different modes defined by the `mode` parameter.

#### 🏛️ Mode: FIAT

> "I want to receive the equivalent of 100 USD."

* Logic: You set a fixed price in fiat currency (USD, EUR, INR).
* Exchange Rate: The system calculates the crypto amount dynamically at the moment of payment.
* Volatility: The system handles the exchange rate risk.
* Best For: E-commerce shops, SaaS subscriptions, goods priced in fiat.

#### ⛓️ Mode: CRYPTO

> "I want to receive exactly 50.5 USDT."

* Logic: You set a fixed amount of tokens.
* Exchange Rate: Ignored. 1 Token = 1 Token.
* Volatility: You receive exactly what was requested, regardless of dollar value.
* Best For: Wallet top-ups, crypto-native services, transfers.

***

### 2. Common Parameters (Required for Both)

These parameters must be included in every request.

**Headers**

| Name           | Value                                                                                          |
| -------------- | ---------------------------------------------------------------------------------------------- |
| Content-Type   | `application/json`                                                                             |
| X-CC-Timestamp | Unix time in seconds                                                                           |
| X-CC-Nonce     | Unique per request                                                                             |
| X-CC-Signature | [Signed request](https://docs-processing.crypto-chief.com/getting-started/signing-requests.md) |
| Merchant       | `Merchant ID`                                                                                  |

**Body**

<table><thead><tr><th>Name</th><th width="112">Type</th><th width="130">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>order_id</code></td><td>string</td><td>true</td><td><p>Unique external ID (Idempotency key).</p><p>Latin letters (<code>A-Z</code>, <code>a-z</code>), digits, <code>_</code>, <code>-</code> and <code>:</code>, up to 200 characters. Otherwise <code>400 INVALID_ORDER_ID</code>. Case is ignored: <code>INV-1</code> and <code>inv-1</code> are the same <code>order_id</code>.</p><p>A repeat with a taken <code>order_id</code> before the order's <code>expired_at</code> returns the existing order (<code>200</code>) in its current status if it matches the first request on <code>mode</code>, <code>amount_fiat</code> and <code>currency</code> (fiat) or <code>amount_crypto</code> and <code>asset.coin</code> (crypto). A concrete <code>asset.network</code> (not <code>ANY</code>) must match too. Amounts are compared as numbers (<code>"50"</code> = <code>"50.00"</code>). The original <code>to_address</code> selection must also match: a retry cannot add, remove, or change an explicit destination. EVM address casing is ignored; base58 address casing is significant. Other fields are not compared.</p><p>A repeat with different values, at or after <code>expired_at</code>, or with an <code>order_id</code> starting with <code>wl:</code> (any case), returns <code>400 ORDER_ALREADY_EXIST</code>.</p></td></tr><tr><td><code>user_id</code></td><td>string</td><td>true</td><td>Internal user identifier.</td></tr><tr><td><code>mode</code></td><td>string</td><td>true</td><td><code>"fiat"</code> or <code>"crypto"</code></td></tr><tr><td><code>to_address</code></td><td>string</td><td>false</td><td>Address of an existing, unfrozen transit wallet owned by your project (and by the calling merchant on White Label). The platform uses this destination if available; it never substitutes another address. Static and master wallets are rejected. See “Choosing an existing deposit address” below.</td></tr><tr><td><code>master_wallet_address</code></td><td>string</td><td>false</td><td><p>Address of one of your project's <strong>master wallets</strong>; it must match the chain family of the payment network. The deposit (transit) wallet for the order is then taken from — or minted under — this master, so the sweep destination is deterministic.</p><p>An invalid or foreign master returns <code>400</code>. With a pinned master, a multi-asset order only offers assets of the master's chain family (<code>400</code> if none of the order's assets match).</p><p>Memo/tag-based networks (e.g. XRPL) honour the preference as well: they keep one shared tagged deposit wallet per master, and each order is told apart by its destination tag. The preference is <strong>ignored</strong> (validated, but not applied) only when <code>to_address</code> / a predefined destination is used, because no deposit wallet is created in that flow.</p></td></tr><tr><td><code>environment</code></td><td>string</td><td>false</td><td><p><code>"mainnet"</code> or <code>"testnet"</code>. Constrains the asset the platform <strong>picks</strong> for this order to the real chains or the test ones.</p><p>It has <strong>no effect when you name a concrete network</strong> in <code>asset.network</code> — that is your choice and is honoured on either environment. It matters when the platform selects for you: an order created with <code>ANY_NETWORK</code>, or any order in <code>fiat</code> mode. Without it, such an order could be assigned a test-network asset while you expected a real payment.</p><p>When omitted, your project's default environment is used (set in the cabinet on the project page). A value that is neither of the two returns <code>400 ENVIRONMENT_INVALID</code> rather than falling back to the default — a typo must not decide where real money is expected. If test networks are not enabled for your project, <code>"testnet"</code> returns <code>400 TESTNET_NOT_ALLOWED</code>.</p></td></tr><tr><td><code>lifetime_sec</code></td><td>int</td><td>false</td><td>Order expiration time<br>Default: <code>1800</code></td></tr><tr><td><code>url_callback</code></td><td>string</td><td>false</td><td>Webhook URL for status updates. See <a href="https://docs-processing.crypto-chief.com/webhooks/general-information.md#callback-url-requirements">Callback URL requirements</a>.</td></tr><tr><td><code>url_success</code></td><td>string</td><td>false</td><td>Client redirect URL after successful payment.</td></tr><tr><td><code>url_error</code></td><td>string</td><td>false</td><td>Client redirect URL after failed/expired payment.</td></tr><tr><td><code>additional_data</code></td><td>string</td><td>false</td><td>Custom string with metadata.</td></tr><tr><td><code>accuracy_payment_percent</code></td><td>int</td><td>false</td><td><p>Allowed underpayment/overpayment percentage (e.g., <code>2</code> for 2%).</p><p>Min: <code>0</code>. Pass <code>-1</code> to accept any amount (status resolves to <code>paid</code> / <code>paid_less</code> / <code>paid_over</code> by direction); with <code>-1</code> the deposit address is exclusive to the order — no second order may share it (except XRP Ledger, where the destination tag identifies orders).</p><p>Max: <code>15</code><br>Default: <code>5</code><br><br><br></p></td></tr><tr><td><code>is_payment_multiple</code></td><td>bool</td><td>false</td><td><p>Allow the invoice to be paid in several transfers (top-ups).</p><p>While the accumulated amount is below the required one, the order sits in <code>wrong_amount_waiting</code> and a webhook fires on <strong>every</strong> incoming transfer with <code>received_amount_crypto</code>, <code>remaining_amount_crypto</code> and the full <code>payments</code> array. The deposit address stays exclusive to the order and watched for 1 hour past <code>expired_at</code>; after that grace window an underpaid order finalizes as <code>paid_less</code>, an unpaid one as <code>expired</code>. A transfer arriving after finalization is reported as <code>invoice.late_payment</code> without changing the status. Not combinable with address sharing: no second order may use the address meanwhile (except XRP Ledger, where the destination tag identifies orders).</p><p>Default: <code>false</code></p></td></tr></tbody></table>

### Choosing an existing deposit address

Set `to_address` to an unfrozen **transit** wallet in your project. You can use a transit address generated by CryptoChief or one you [registered with your own signer](https://docs-processing.crypto-chief.com/managing-wallets/external-wallets.md). On White Label, the address must also belong to the merchant whose API credentials sign the request.

The supplied address is checked and reserved for this order. An unavailable address causes an error; the platform does not replace it with another address. Explicit destinations are exclusive while reserved, even if another order requests a different amount. On XRP Ledger, the destination tag distinguishes payments: a classic address receives an order-specific tag, while an X-address keeps its supplied tag.

If the response is `waiting_asset_select`, choose one of the returned assets before displaying payment instructions. The reservation is made when the asset is selected. If another order reserves the address first, selection fails; it does not assign a replacement address. A successful `pending` response contains the payment address and, where applicable, its memo or tag.

Resetting the asset preserves the chosen destination and releases the previous asset reservation. Selecting an asset again rechecks availability and reserves that same destination for the new payment details.

Without `to_address`, the platform selects a transit address automatically. To accept deposits on a permanent static wallet, use [Static Deposit webhooks](https://docs-processing.crypto-chief.com/webhooks/static-deposit-webhook.md) instead of creating an invoice.

### 3. Workflow A: FIAT Mode

Requirement: `mode` = `"fiat"`

In this mode, you define the value in traditional currency. The user can pay in various cryptocurrencies, and the system ensures you get the requested value.

**Specific Parameters in Body**

| Name            | Type                                                                                      | Required | Description                                                                                                         |
| --------------- | ----------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------- |
| `amount_fiat`   | string                                                                                    | true     | The cost in fiat (e.g., `"100.50"`)                                                                                 |
| `currency`      | [CURRENCY](https://docs-processing.crypto-chief.com/currencies/list-fiat-currencies.md)   | true     | The fiat code (e.g., `"USD"`, `"EUR"`)                                                                              |
| `course_source` | [DATA\_SOURCE](https://docs-processing.crypto-chief.com/general/exchange-data-sources.md) | false    | <p>The service from which exchange rates are taken for recalculation in the order.<br>Default: <code>any</code></p> |
| assets          | [ASSETS\_POLICY](#assets_policy-object)                                                   | false    | Define which coins are allowed or excluded                                                                          |

#### Example Request

*Invoice for 100 USD*

```json
{
  "order_id": "ord-fiat-01",
  "user_id": "u-1",
  "mode": "fiat",
  "amount_fiat": "100.00",
  "currency": "USD"
}
```

### 4. Workflow B: CRYPTO Mode

Requirement: `mode` = `"crypto"`

In this mode, you define the value in tokens. No conversion takes place. The user must send exactly this amount.

**Specific Parameters in Body**

| Name            | Type                   | Required | Description                         |
| --------------- | ---------------------- | -------- | ----------------------------------- |
| `amount_crypto` | string                 | true     | The cost in fiat (e.g., `"100.50"`) |
| `asset`         | [ASSET](#asset-object) | true     | Define which coin is allowed        |

**Example Request**

*Charge exactly 50.5 USDT on TRON network.*

```json
{
  "order_id": "ord-crypto-01",
  "user_id": "u-1",
  "mode": "crypto",
  "amount_crypto": "50.5",
  "asset": {
    "coin": "USDT",
    "network": "TRON"
  }
}
```

### 5. Response Handling & Next Steps

The API response tells you the current state of the order. Your next step depends on your integration type: Hosted Page (simplest) or Host-to-Host (custom UI).

#### Status: `waiting_asset_select`

Meaning: The order is created, but the specific cryptocurrency is not yet chosen. The `coins` array contains the list of available options.

**👉 Next Step depends on your integration:**

* Option A: Hosted Payment Page
  * Action: Redirect the user to the `payment_link` URL provided in the response.
  * Logic: Our system handles the UI. The user will select the coin on our page. No further API calls required.
* Option B: Host-to-Host (White Label)
  * Action: Render the list of `coins` to the user.
  * Logic: When the user clicks on a specific coin/network, you must call the Select Asset Endpoint to lock the choice and generate the address.
  * Method: [SELECT ASSET](https://docs-processing.crypto-chief.com/payments/creating-a-payin/select-asset.md)

***

#### Status: `pending`

Meaning: The payment method is locked. The wallet address has been assigned.

**👉 Next Step depends on your integration:**

* Option A: Hosted Payment Page
  * Logic: The user will see the QR code and address on our page. No further API calls required.
* Option B: Host-to-Host (White Label)
  * Action: Display the payment details directly in your UI.
  * Data to use: `payment_network`, `payment_coin` , `to_address` and `amount_crypto`.

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "type": "PayIn",
    "uuid": "a15eadd9-d68f-4ddf-8004-5311f0e2b576",
    "order_id": "ord-crypto-1",
    "user_id": "user-1",
    "mode": "crypto",
    "is_test": true,
    "status": "pending",
    "lifetime": 1800,
    "expired_at": "2026-01-15T13:13:11.965064135Z",
    "is_expired": false,
    "can_cancel": true,
    "amount_fiat": null,
    "currency": null,
    "amount_crypto": "0.005",
    "fact_amount_fiat": null,
    "fact_amount_crypto": null,
    "accuracy_payment_percent": 5,
    "to_address": "0x72ddc7ea48f6edb6ee63ca9bd995b9235cd4ffc3",
    "memo": null,
    "from_address": null,
    "txid": null,
    "coins": [
        {
            "chain_family": "EVM",
            "coin": "BNB",
            "network": "BSC_TESTNET"
        }
    ],
    "has_choices": false,
    "url_success": null,
    "url_error": null,
    "url_callback": null,
    "confirmations": 0,
    "required_confirmations": 20,
    "paid_at": null,
    "confirmed_at": null,
    "additional_data": null,
    "created_at": "2026-01-15T12:43:12.049213Z",
    "payment_link": "https://crypto-terminal.crypto-chief.com/pay/a15eadd9-d68f-4ddf-8004-5311f0e2b576",
    "payment_coin": "BNB",
    "payment_network": "BSC_TESTNET",
    "convert": {
        "auto_convert": false,
        "coin": "BNB",
        "convert_coin": null,
        "convert_network": null,
        "course_source": "any",
        "network": "BSC_TESTNET",
        "rate": null
    }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "error": "SERVICE_ERROR",
    "msg": "ORDER_ALREADY_EXIST",
    "ok": false
}
```

{% endtab %}
{% endtabs %}

***

#### **Asset Object**

| Name    | Type                                                                                         | Required | Description                                                                                                                                                                      |
| ------- | -------------------------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| coin    | [COIN](https://docs-processing.crypto-chief.com/blockchain-data/project-assets-available.md) | true     | The cryptocurrency ticker symbol (e.g., `"USDT"`, `"BTC"`, `"ETH"`).                                                                                                             |
| network | [CHAIN](https://docs-processing.crypto-chief.com/general/allowed-chain.md)                   | true     | <p>The blockchain network code (e.g., , <code>ETH\_MAINNET</code> , <code>TRON\_MAINNET</code>).<br>Use <code>"ANY"</code> to indicate all available networks for this coin.</p> |

**JSON Example:**

```json
{
  "coin": "USDT",
  "network": "TRON_MAINNET"
}
```

#### ASSETS\_POLICY **Object**

Used in the `assets` parameter to filter the payment methods shown to the user.

| Name    | Type                       | Required | Description                                                                                                      |
| ------- | -------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------- |
| allow   | [ASSET](#asset-object) \[] | false    | Whitelist. An array of `Asset` objects. If provided, the user will see only these assets. All others are hidden. |
| exclude | [ASSET](#asset-object) \[] | false    | Blacklist. An array of `Asset` objects. These specific assets will be hidden from the user.                      |

**JSON Example:**

```json
{
  "allow": [
    { "coin": "USDT", "network": "ANY" }
  ],
  "exclude": [
    { "coin": "BTC", "network": "ANY" }
  ]
}
```
