> For the complete documentation index, see [llms.txt](https://nivapay.gitbook.io/product-and-api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nivapay.gitbook.io/product-and-api-documentation/api-documentation/nft-minting.md).

# NFT Minting

## Create Order

<mark style="color:green;">`POST`</mark> `https://api-purchase-nft.nivapay.com/merchant/hosted/nftCheckout/order`

Merchant will call this endpoint to generate a new order. Merchant needs to redirect their user to the hosted checkout URL to complete the journey.

#### Headers

| Name                                        | Type   | Description      |
| ------------------------------------------- | ------ | ---------------- |
| X-API-KEY<mark style="color:red;">\*</mark> | string | Merchant API key |

#### Request Body

| Name                                                      | Type           | Description                                                                                                                                                                                                                                  |
| --------------------------------------------------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| crypto\_symbol<mark style="color:red;">\*</mark>          | string         | Symbol of the virtual asset which user wants to pay in. If the SC function requires funds, then this should be the same currency.                                                                                                            |
| user\_last\_name                                          | string         | Last name of your user                                                                                                                                                                                                                       |
| user\_first\_name                                         | string         | First name of your user                                                                                                                                                                                                                      |
| user\_email\_id                                           | string (email) | Email ID of your user                                                                                                                                                                                                                        |
| merchant\_webhook\_url                                    | string (url)   | URL where you want to receive webhook events                                                                                                                                                                                                 |
| merchant\_redirect\_url<mark style="color:red;">\*</mark> | string (url)   | URL to which the user will be redirected back at the end of the journey or when user cancels the session. For SDK integration, pass a dummy value.                                                                                           |
| merchant\_txn\_id                                         | string         | Internal ID provided by the merchant to track this order. This will be passed in the webhook events too.                                                                                                                                     |
| merchant\_user\_id<mark style="color:red;">\*</mark>      | string         | Internal ID provided by the merchant for the user                                                                                                                                                                                            |
| merchant\_id<mark style="color:red;">\*</mark>            | string         | ID assigned to the merchant by Nivapay                                                                                                                                                                                                       |
| crypto\_contract\_address                                 | string         | Contract address is required, if symbol+network is not a native currency, else can be null                                                                                                                                                   |
| contractExecution<mark style="color:red;">\*</mark>       | json           | Smart contract (SC) execution details                                                                                                                                                                                                        |
| network\_params<mark style="color:red;">\*</mark>         | json           | Contains network params                                                                                                                                                                                                                      |
| totalValue<mark style="color:red;">\*</mark>              | string         | Total value of crypto to be paid to the function for this particular call (with above function\_args). Value must not be in wei. You can use big decimals up to 18 digits.                                                                   |
| payableCryptoContractAddress                              | string         | If the virtual asset is an ERC20 / BEP20 token then it’s contract address to uniquely identify it                                                                                                                                            |
| payableCryptoSymbol<mark style="color:red;">\*</mark>     | string         | Symbol of the virtual asset to be paid to the SC function                                                                                                                                                                                    |
| payment                                                   | json           | Required only if the SC function is expected to receive funds for its successful execution                                                                                                                                                   |
| function\_args<mark style="color:red;">\*</mark>          | json           | JSON containing the list of arguments (key-value pairs) this SC function takes. Arguments must adhere to the data type defined in the function ABI registered. Refer to the example below.                                                   |
| smartContractFunctionId<mark style="color:red;">\*</mark> | string         | ID of the SC function registered by the merchant                                                                                                                                                                                             |
| customGasLimit                                            | string         | Gas limit to override the defaultGasLimit specified at the time of registering your SC. If your SC function can vary in terms of computational effort, then it is strongly recommended to set this to avoid “insufficient gas fee” failures. |
| networkName<mark style="color:red;">\*</mark>             | string         | Blockchain network on which this SC exists                                                                                                                                                                                                   |
| crypto\_network<mark style="color:red;">\*</mark>         | string         | Blockchain network of this virtual asset                                                                                                                                                                                                     |

{% tabs %}
{% tab title="201: Created Order created successfully" %}
{% tabs %}
{% tab title="Body" %}

{% endtab %}

{% tab title="Example" %}
{% code overflow="wrap" %}

```json
{
	"order_id": "VKP3OBZ3XG",
	"crypto_symbol": "ETH",
	"crypto_network": "Ethereum",
	"crypto_amount": "2.01434",
	"hash": "1441a7909c087dbbe7ce59881b9df8b9",
	"gateway_url": "https://purchase-nft.nivapay.com/order?order_id=VKP3OBZ3XG&hash=1441a7909c087dbbe7ce59881b9df8b9"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="201: Created Webhook URL is passed but webhook secret is not set" %}
{% tabs %}
{% tab title="Example" %}
{% code overflow="wrap" %}

```json
{
	"order_id": "VKP3OBZ3XG",
	"crypto_symbol": "ETH",
	"crypto_network": "Ethereum",
	"crypto_amount": "2.01434",
	"hash": "1441a7909c087dbbe7ce59881b9df8b9",
	"gateway_url": "https://purchase-nft.nivapay.com/order?order_id=VKP3OBZ3XG&hash=1441a7909c087dbbe7ce59881b9df8b9",
	"info": "Secret is not configured for creating X-Nivapay-Webhook-Signature for signing webhook events. There won't be any webhooks events in this order. Contact Nivapay for configuring the secret."
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="400: Bad Request Wrong crypto currency is provided" %}
{% tabs %}
{% tab title="Example" %}
{% code overflow="wrap" %}

```json
{
	"statusCode": 400,
	"timestamp": "2023-07-20T05:19:18.018Z",
	"message": "payableCryptoSymbol #USDC #Ethereum is invalid",
	"path": "/merchant/hosted/nftCheckout/order",
	"status": false
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="401: Unauthorized Invalid merchant API key" %}
{% tabs %}
{% tab title="Example" %}
{% code overflow="wrap" %}

```json
{
	"statusCode": 401,
	"timestamp": "2024-02-07T07:03:18.153Z",
	"message": "Unauthorized",
	"path": "/merchant/hosted/nftCheckout/order",
	"status": false
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

<table><thead><tr><th width="174">param</th><th width="79">type</th><th width="279">description</th><th>required</th></tr></thead><tbody><tr><td>order_id</td><td>string</td><td>Order ID assigned by Nivapay</td><td>yes</td></tr><tr><td>crypto_symbol</td><td>string</td><td>Symbol of the virtual asset which user wants to pay in. If the SC function requires funds, then this should be the same currency.</td><td>yes</td></tr><tr><td>crypto_contract_address</td><td>string</td><td>Contract address is required, if symbol+network is not a native currency, else can be null</td><td>no</td></tr><tr><td>crypto_network</td><td>string</td><td>Blockchain network of this virtual asset</td><td>yes</td></tr><tr><td>crypto_amount</td><td>string</td><td>Virtual asset amount to be paid to fulfil this order</td><td>yes</td></tr><tr><td>hash</td><td>string</td><td>Secret hash which allows you to access the gateway_url. It is already added as a query param to the gateway_url.</td><td>yes</td></tr><tr><td>gateway_url</td><td>string (url)</td><td>URL to the hosted checkout page where you need to redirect your user</td><td>yes</td></tr></tbody></table>

<details>

<summary>Create Order request example (curl)</summary>

```json
curl --location 'https://api-purchase-nft.nivapay.com/merchant/hosted/nftCheckout/order' \
--header 'Content-Type: application/json' \
--header 'x-api-key: 2b03fc9e-550e-4ffb-9136-92b627f9988b' \
--data-raw '{
    "crypto_symbol": "ETH",
    "crypto_network": “Ethereum”,

"contractExecution": {
		"smartContractFunctionId": "c6214bdf-051f-4000-8879-590d9b03d4af",
		"function_args": {
			"numberOfNFTs": "3",
			"tokenIds": ["1003","1004","1010"],
			"to_addr": "0x8e23ee67d1332ad560396262c48ffbb01f93d052"
		},
		"payment": {
			"payableCryptoSymbol": "ETH",
			"payableCryptoContractAddress": "",
			"totalValue": "1.98"
		},
		"network_params": {
			"networkName": "Ethereum",
			"customGasLimit": "1320837"
		}
	}

    "merchant_id": "M7184835",
    "merchant_user_id": "1xdeavy",
    "merchant_txn_id": "3589cb4a-0830-497d-a92d-c5178eb2ab9f",
    "merchant_redirect_url": "https://nivapay.com",
    "merchant_webhook_url": "https://hooks.nivapay.com/payment-services/",

    "user_email_id": "daves@yahoo.com",
    "user_first_name": "Dave",
    "user_last_name": "Smith"
}'
```

</details>

## Generate Crypto Quote

<mark style="color:green;">`POST`</mark> `https://api-purchase-nft.nivapay.com/merchant/hosted/nftCheckout/cryptoQuote`

Get the amount to be paid in crypto to fulfil the desired NFT Checkout order

#### Headers

| Name                                        | Type   | Description      |
| ------------------------------------------- | ------ | ---------------- |
| X-API-KEY<mark style="color:red;">\*</mark> | string | Merchant API key |

#### Request Body

| Name                                                      | Type   | Description                                                                                                                                                                                                                                  |
| --------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| crypto\_symbol<mark style="color:red;">\*</mark>          | string | Symbol of the virtual asset which user wants to pay in. If the SC function requires funds, then this should be the same currency.                                                                                                            |
| merchant\_id<mark style="color:red;">\*</mark>            | string | ID assigned to the merchant by Nivapay                                                                                                                                                                                                       |
| crypto\_contract\_address                                 | string | Contract address is required, if symbol+network is not a native currency, else can be null                                                                                                                                                   |
| contractExecution<mark style="color:red;">\*</mark>       | json   | Smart contract (SC) execution details                                                                                                                                                                                                        |
| network\_params<mark style="color:red;">\*</mark>         | json   | Contains network params                                                                                                                                                                                                                      |
| totalValue<mark style="color:red;">\*</mark>              | string | Total value of crypto to be paid to the function for this particular call (with above function\_args). Value must not be in wei. You can use big decimals up to 18 digits.                                                                   |
| payableCryptoContractAddress                              | string | If the virtual asset is an ERC20 / BEP20 token then it’s contract address to uniquely identify it                                                                                                                                            |
| payableCryptoSymbol<mark style="color:red;">\*</mark>     | string | Symbol of the virtual asset to be paid to the SC function                                                                                                                                                                                    |
| payment                                                   | json   | Required only if the SC function is expected to receive funds for its successful execution                                                                                                                                                   |
| function\_args<mark style="color:red;">\*</mark>          | json   | JSON containing the list of arguments (key-value pairs) this SC function takes. Arguments must adhere to the data type defined in the function ABI registered. Refer to the example below.                                                   |
| smartContractFunctionId<mark style="color:red;">\*</mark> | string | ID of the SC function registered by the merchant                                                                                                                                                                                             |
| customGasLimit                                            | string | Gas limit to override the defaultGasLimit specified at the time of registering your SC. If your SC function can vary in terms of computational effort, then it is strongly recommended to set this to avoid “insufficient gas fee” failures. |
| networkName<mark style="color:red;">\*</mark>             | string | Blockchain network on which this SC exists                                                                                                                                                                                                   |
| crypto\_network<mark style="color:red;">\*</mark>         | string | Blockchain network of this virtual asset                                                                                                                                                                                                     |

{% tabs %}
{% tab title="200: OK Success" %}
{% tabs %}
{% tab title="Body" %}

{% endtab %}

{% tab title="Example" %}
{% code overflow="wrap" %}

```json
{
	"crypto_amount": "1.031452",
	"allowed": true,
	"message": ""
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="401: Unauthorized Invalid merchant API key" %}
{% tabs %}
{% tab title="Example" %}
{% code overflow="wrap" %}

```json
{
	"statusCode": 401,
	"timestamp": "2024-02-07T07:03:18.153Z",
	"message": "Unauthorized",
	"path": "/merchant/hosted/nftCheckout/cryptoQuote",
	"status": false
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

<table><thead><tr><th width="178">param</th><th width="94">type</th><th width="269">description</th><th>required</th></tr></thead><tbody><tr><td>crypto_amount</td><td>string</td><td>Crypto amount to be paid to fulfil this order</td><td>yes</td></tr><tr><td>allowed</td><td>boolean</td><td>Whether this amount is permissible for payment for the given crypto currency. If this is false then the NFT Checkout order also won't get generated.</td><td>yes</td></tr><tr><td>message</td><td>string</td><td>Message explaining if it is not allowed or Bad request</td><td>no</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://nivapay.gitbook.io/product-and-api-documentation/api-documentation/nft-minting.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
