> For the complete documentation index, see [llms.txt](https://docs.tylt.money/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tylt.money/tylt-crossramp-fiat-crypto-solutions/eu-open-banking/open-banking-payin-eur-gbp-usdc/create-a-pay-in-instance.md).

# Create a Pay-in Instance

This endpoint allows you to create a new payment instance and receive a URL that can be used to launch the Tylt CrossRamp Open Banking Pay-In widget. Through the widget, the merchant's end customer can make a deposit or payment to the merchant using Open Banking. The payment is settled in USDC into the merchants wallet.

**Endpoint**

<mark style="color:green;">**`POST`**</mark>`https://api.tylt.money/v2/prime-fiat/instance/payin`

**Request Headers**

{% tabs %}
{% tab title="First Tab" %}

<table data-full-width="true"><thead><tr><th width="133">Name</th><th width="79">Type</th><th width="167">Example</th><th>Description</th></tr></thead><tbody><tr><td>X-TLP-APIKEY</td><td>string</td><td>93ee3c5e133697251b5362bcf9cc8532476785t8768075616f58d88</td><td>Your Tylt API Key, used to identify your account in API requests.</td></tr><tr><td>X-TLP-SIGNATURE</td><td>string</td><td>d0afef3853dfc8489c8b9affa5825171fdd7y7685675e4966a05f66ed2b3eaf9462b3c9c0</td><td>HMAC SHA-256 signature generated using the API Secret Key to secure the request.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
When using the API, ensure to include your API Key and generate the signature for the request payload using your API Secret. The tables provided above contain example values for illustration purposes only. Please refer to the code snippets for detailed instructions on how to sign the request and generate the signature properly.
{% endhint %}

**Request Body**

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

<table data-header-hidden><thead><tr><th width="204"></th><th width="121"></th><th></th></tr></thead><tbody><tr><td><strong>Field Name</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>userDetails</code></td><td><code>JSON Object</code></td><td><p>Custom fields associated with the end user making a payment to the merchant. These fields are echoed back in webhook notifications and other API responses for tracking and reconciliation.You may send an empty object (<code>{}</code>).<br></p><p><strong>Reserved keys (auto-populate payment widget)</strong><br></p><p>The following keys are reserved. If you include any of them, they will be used to pre-fill the corresponding fields in the hosted payment widget:</p><ul><li><code>firstName</code> (string)</li><li><code>lastName</code> (string)</li><li><code>email</code> (string)</li><li><code>country</code> (string)</li><li><code>dob</code> (string, format: <code>YYYY-MM-DD</code>)<br></li></ul><p>If a reserved field is not provided, the end user will be prompted to enter that field in the widget (if required by the flow).</p></td></tr><tr><td><code>merchantOrderId</code></td><td><code>string</code></td><td>Mandatory. A UUID used by the merchant to reference this instance or any transaction related to it.</td></tr><tr><td><code>callBackUrl</code></td><td><code>string</code></td><td>Mandatory. The URL to which payment status updates are sent.</td></tr><tr><td><code>redirectUrl</code></td><td><code>string</code></td><td>Mandatory. The URL to redirect the user after completing the payment.</td></tr><tr><td><code>amount</code></td><td><code>number</code></td><td>Mandatory. This is the amount the user wants to deposit in EUR, GBP.</td></tr><tr><td><code>currencySymbol</code></td><td><code>string</code></td><td>Mandatory. Supported Currency is "EUR" , "GBP" only.</td></tr><tr><td><code>transferType</code></td><td><code>string</code></td><td>Settlement destination. Supported values are <code>"internal"</code> and <code>"external"</code>. Defaults to <code>"internal"</code>.</td></tr><tr><td><code>settlementType</code></td><td><code>string</code></td><td>Settlement schedule. Defaults to <code>"instant"</code>. Other approved values may use the <code>T+N</code> format, such as <code>"T+1"</code></td></tr><tr><td><code>walletDetails</code></td><td><code>object</code></td><td>External wallet address to which the USDC, USDT settlement will be delivered. Required if settlementType is <code>"external"</code></td></tr><tr><td><p><code>walletDetails.address</code></p><p><br></p></td><td><code>string</code></td><td>External wallet address to which the USDC, USDT settlement will be delivered.</td></tr><tr><td><p><code>walletDetails.network</code></p><p><br></p></td><td><code>string</code></td><td>Blockchain network associated with the wallet address, such as <code>"ETH"</code> or <code>"BSC"</code> or  <code>"TRX"</code> or  <code>"POL"</code></td></tr><tr><td><code>merchantDetails</code></td><td><code>JSON Object</code></td><td><p>The <code>merchantDetails</code> object identifies the merchant on whose behalf the transaction is being processed. This information is required for transaction attribution, reconciliation, risk screening, and regulatory reporting.<br><br>If the integrator is acting as a Merchant of Record, the details of the underlying end merchant must be provided<br><br>If the integrator is the end merchant, the details of its own business must be provided. <br><br>The following fields must be provided inside the <code>merchantDetails</code> object:</p><ul><li><strong>merchantName</strong><br>The legal or DBA name of the merchant.</li><li><strong>merchantUrl</strong><br>The official website URL of the merchant. This must be a valid HTTPS URL representing the merchant’s active operating website.</li><li><strong>merchantInternalId</strong><br>A unique internal identifier assigned by the merchant. This identifier is used for reconciliation, reporting, and ongoing transaction tracking and must remain consistent across transactions.</li></ul><p>All fields within <code>merchantDetails</code> are mandatory. Transactions submitted without this object, or with incomplete merchant details, will be rejected.<br><br>Transactions with new <code>merchantDetails</code> go through an automated internal review process. </p></td></tr><tr><td><code>cryptoUi</code></td><td><code>number</code></td><td>Controls the visual mode of the hosted payment widget. Default is <code>1</code>. If set to <code>1</code>, the widget UI is adapted to showcase a crypto purchase flow. If set to <code>0</code>, the widget UI is adapted to showcase a fiat payment flow.</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

{% endtab %}
{% endtabs %}

**Code Snippet**

{% tabs %}
{% tab title="Internal Tansfer" %}

<pre class="language-javascript"><code class="lang-javascript">const axios = require('axios');
const crypto = require('crypto');

// Replace with your API Key and Secret
const apiKey = 'your-api-key';
const apiSecret = 'your-api-secret';

// Request body
const requestBody = {
    merchantOrderId: 'b73b73b-87wtbc-q36gbc-331n3', // please use a unique order id per request
    callBackUrl: 'https://www.test.com/callback',
    redirectUrl: 'https://www.test.com/callback',
    amount: 10.00,
    currencySymbol: 'EUR',
    merchantDetails: {
        merchantName: "Example Merchant Ltd",
        merchantUrl: "https://www.examplemerchant.com",
        merchantInternalId: "merchant-12345" 
    },
    userDetails: {
            firstName: "Test",
            lastName: "User",
            email: `testuser@testemail.com`,
            country: "Poland",
            dob: "1990-01-01",
            DocumentType: "Identity Card",
            DocumentNumber: "426349253ZY8",
            DocumentURL : "https://kyc.gaming.com/b1278191.jpeg"          
<strong>    }
</strong><strong>};
</strong>
// Convert request body to JSON
const raw = JSON.stringify(requestBody);

// Function to create HMAC SHA-256 signature
const createSignature = (secret, data) => {
    return crypto.createHmac('sha256', secret)
                 .update(data)
                 .digest('hex');
};

// Generate signature
const signature = createSignature(apiSecret, raw);

// Define headers
const headers = {
    "X-TLP-APIKEY": apiKey,
    "X-TLP-SIGNATURE": signature
};

// Send the request
axios.post('https://api.tylt.money/v2/prime-fiat/instance/payin', raw, { headers })
    .then(response => console.log("Success:", response.data))
    .catch(error => console.error("Error:", error));

</code></pre>

{% endtab %}

{% tab title="External Transfer" %}

<pre class="language-javascript"><code class="lang-javascript">const axios = require('axios');
const crypto = require('crypto');

// Replace with your API Key and Secret
const apiKey = 'your-api-key';
const apiSecret = 'your-api-secret';

// Request body
const requestBody = {
    merchantOrderId: 'b73b73b-87wtbc-q36gbc-331n3', // please use a unique order id per request
    callBackUrl: 'https://www.test.com/callback',
    redirectUrl: 'https://www.test.com/callback',
    amount: 10.00,
    currencySymbol: 'EUR',
    merchantDetails: {
        merchantName: "Example Merchant Ltd",
        merchantUrl: "https://www.examplemerchant.com",
        merchantInternalId: "merchant-12345" 
    },
    userDetails: {
            firstName: "Test",
            lastName: "User",
            email: `testuser@testemail.com`,
            country: "Poland",
            dob: "1990-01-01",
            DocumentType: "Identity Card",
            DocumentNumber: "426349253ZY8",
            DocumentURL : "https://kyc.gaming.com/b1278191.jpeg"          
<strong>    },
</strong><strong>    transferType: "external",
</strong>    settlementType: "T+1"
    walletDetails: {
    address:"0x48AF3Bd03E9c707e037a3d8623eEXXXXXXXXXXB3",
    network:"POL"
    }
<strong>};
</strong>
// Convert request body to JSON
const raw = JSON.stringify(requestBody);

// Function to create HMAC SHA-256 signature
const createSignature = (secret, data) => {
    return crypto.createHmac('sha256', secret)
                 .update(data)
                 .digest('hex');
};

// Generate signature
const signature = createSignature(apiSecret, raw);

// Define headers
const headers = {
    "X-TLP-APIKEY": apiKey,
    "X-TLP-SIGNATURE": signature
};

// Send the request
axios.post('https://api.tylt.money/v2/prime-fiat/instance/payin', raw, { headers })
    .then(response => console.log("Success:", response.data))
    .catch(error => console.error("Error:", error));

</code></pre>

{% endtab %}
{% endtabs %}

**Response**

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

```json
{
  "msg": "Instance created successfully",
  "data": {
    "instanceId": "c8439580-1d48-4d47-9a0e-c4a559a35913",
    "merchantOrderId": "ivytest1787206071196",
    "url": "https://app.tylt.money/prime-eur-instance/c8439580-1d48-4d47-9a0e-c4a559a35913",
    "userDetails": {
      "email": "s89.510922@gmail.com",
      "firstName": "John",
      "lastName": "Doe",
      "country": "DE",
      "dob": "1990-01-01"
    },
    "merchantDetails": {
      "merchantName": "Test Merchant Store",
      "merchantUrl": "https://teststore.com"
    },
    "fiatAmount": 5,
    "fiatCurrencySymbol": "EUR",
    "cryptoAmount": 5.84,
    "cryptoCurrencySymbol": "USDC",
    "toReleaseAmount": 5.47,
    "fees": 0.37,
    "rate": 0.8564,
    "effectiveRate": 0.9141,
    "walletDetails": {
      "address": "0x82e679f09bfd0c28506314dd851e379a083b5094",
      "network": "BSC"
    },
    "cryptoSettlementDetails": {
      "Status": "Pending",
      "hash": "Pending",
      "address": "0x82e679f09bfd0c28506314dd851e379a083b5094",
      "Network": "BSC",
      "transferType": "external",
      "settlementType": "T+1",
      "settlementTime": "Pending"
    }
  }
}

```

{% endtab %}

{% tab title="Response Fields" %}

| Field                                    | Type   | Description                                                                                                                              |
| ---------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `instanceId`                             | String | Unique identifier assigned by Tylt to the Pay-In instance.                                                                               |
| `merchantOrderId`                        | String | Unique order identifier provided by the merchant for transaction identification and reconciliation.                                      |
| `url`                                    | String | URL used to redirect the end user to the Tylt Open Banking Pay-In flow.                                                                  |
| `userDetails`                            | Object | End-user information associated with the transaction. This information is provided by the merchant at the time of user/account creation. |
| `merchantDetails`                        | Object | Merchant information associated with the transaction. This information is provided by the merchant at the time of account creation.      |
| `fiatAmount`                             | Number | Fiat amount to be paid by the end user.                                                                                                  |
| `fiatCurrencySymbol`                     | String | Fiat currency used for the transaction, such as `EUR` or `GBP`.                                                                          |
| `cryptoAmount`                           | Number | Gross crypto amount calculated for the transaction.                                                                                      |
| `cryptoCurrencySymbol`                   | String | Crypto asset applicable to the transaction, such as `USDC` or `USDT`.                                                                    |
| `toReleaseAmount`                        | Number | Net crypto amount to be credited or settled after applicable fees and pricing adjustments.                                               |
| `fees`                                   | Number | Total fees applied to the transaction, expressed in the crypto currency.                                                                 |
| `rate`                                   | Number | Base fiat-to-crypto conversion rate used for the transaction.                                                                            |
| `effectiveRate`                          | Number | Effective conversion rate after applicable fees, spread, or commercial pricing.                                                          |
| `walletDetails`                          | Object | Contains the destination wallet details for transactions requiring an external crypto transfer.                                          |
| `walletDetails.address`                  | String | Destination blockchain wallet address.                                                                                                   |
| `walletDetails.network`                  | String | Blockchain network to be used for the external transfer, such as `BSC`.                                                                  |
| `cryptoSettlementDetails`                | Object | Contains information relating to the crypto settlement of the transaction.                                                               |
| `cryptoSettlementDetails.Status`         | String | Current crypto settlement status, such as `Pending`.                                                                                     |
| `cryptoSettlementDetails.hash`           | String | Blockchain transaction hash. May be `Pending` until the external settlement transaction is initiated or broadcast.                       |
| `cryptoSettlementDetails.address`        | String | Destination wallet address for the crypto settlement.                                                                                    |
| `cryptoSettlementDetails.Network`        | String | Blockchain network used for settlement, such as `BSC`.                                                                                   |
| `cryptoSettlementDetails.transferType`   | String | Determines the settlement destination. `external` indicates transfer to an external wallet; `internal` indicates internal crediting.     |
| `cryptoSettlementDetails.settlementType` | String | Configured settlement schedule, such as `instant` or `T+1`.                                                                              |
| `cryptoSettlementDetails.settlementTime` | String | Settlement completion time or current settlement-time status. May be `Pending` until settlement is completed.                            |
| {% endtab %}                             |        |                                                                                                                                          |
| {% endtabs %}                            |        |                                                                                                                                          |
