# Minting an NFT

Use this endpoint to mint an NFT to an existing wallet, identified by one of the following parameters:

* wallet address
* wallet ID
* email address
* phone number

Make sure to supply a contract ID for a contract that your account has permission to mint on. Need help getting set up? [Reach out to us](mailto:kyle@zelus.io)

## Endpoint Details

| Description | Data                                                                                 |
| ----------- | ------------------------------------------------------------------------------------ |
| API Name    | [postNftMint](https://sandbox.api.labs.zelus.io/docs/api-json#/NFT/post_v1_nft_mint) |
| HTTP Method | POST                                                                                 |
| URL         | `/v1/nft/mint`                                                                       |

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

#### Headers

| Key          | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| x-api-key    | API\_KEY           |

#### Query Parameters

| Parameter      | Type             | Description                                                 |
| -------------- | ---------------- | ----------------------------------------------------------- |
| **contractId** | string           | Identifier for the contract, formatted as `contract_<UUID>` |
| **nftTokenId** | string           | Identifier for the NFT. (required)                          |
| **quantity**   | number, optional | Number of NFTs to mint.                                     |

User can be identified by one of the parameter:

| Parameter         | Type             | Description                          |
| ----------------- | ---------------- | ------------------------------------ |
| **walletAddress** | string, optional | Address                              |
| **walletId**      | string, optional | Wallet ID (`wallet_UUID`)            |
| **email**         | string, optional | Wallet email                         |
| **phone**         | string, optional | Wallet phone, format: "+12223334444" |

#### Payload Example:

```json
{
  "contractId": "contract_6635e90e-31f0-11ee-be56-0242ac120002",
  "nftTokenId": "123456",
  "quantity": 2,
  "walletId": "wallet_43fba5e9-e2ae-4417-a198-16c646c7c9f1"
}
```

{% endtab %}

{% tab title="Response" %}

#### Successful Response

```json
{
  "result": {
    "status": "pending",
    "id": "wallet_43fba5e9-e2ae-4417-a198-16c646c7c9f1"
  }
}
```

#### Error Response

```json
{
  "error": {
    "code": 400,
    "message": "Error message"
  }
}
```

#### Error Messages

* Validation error:
  * `{ "code: 400, "message": "Validation error: \"email\" with value \"...\" fails to match the Email pattern" }`
* More than one user identifier:
  * `{ "code": 400, "message": "Validation error: \"value\" failed custom validation because More than one wallet identifier is defined in the request." }`
* Contract not assigned:
  * `{ "code": 400, "message": "Contract not found" }`
* Unauthorized API Key:
  * `{ "code": 400, "message": "Invalid API key" }`
* Wallet not found:
  * `{ "code": 400, "message": "Wallet not found" }`
    {% endtab %}
    {% endtabs %}

## Examples

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

```bash
curl -X POST "https://sandbox.api.labs.zelus.io/v1/nft/mint" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "contractId": "contract_6635e90e-31f0-11ee-be56-0242ac120002",
  "nftTokenId": "1",
  "quantity": 1,
  "walletId": "wallet_43fba5e9-e2ae-4417-a198-16c646c7c9f1"
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://sandbox.api.labs.zelus.io/v1/nft/mint"
headers = {
    "x-api-key": "YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "contractId": "contract_6635e90e-31f0-11ee-be56-0242ac120002",
    "nftTokenId": "2",
    "quantity": 1,
    "walletId": "wallet_43fba5e9-e2ae-4417-a198-16c646c7c9f1"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const axios = require('axios');

const url = "https://sandbox.api.labs.zelus.io/v1/nft/mint";
const headers = {
    "x-api-key": "YOUR_API_KEY",
    "Content-Type": "application/json"
};
const data = {
    contractId: "contract_6635e90e-31f0-11ee-be56-0242ac120002",
    nftTokenId: "3",
    quantity: 1,
    walletId: "wallet_43fba5e9-e2ae-4417-a198-16c646c7c9f1"
};

axios.post(url, data, { headers: headers })
    .then(response => console.log(response.data))
    .catch(error => console.error(error));
```

{% endtab %}
{% endtabs %}
