# Upload File and Metadata

With the following endpoint, you are able to upload a token and optional to also define placeholder values or also a complete metadata code for the metadata override.

{% hint style="info" %}
Please keep in mind that if you upload the metadata in a payload, the metadata must be escaped. \
[Online JSON Escape /Unescape Tool](https://www.freeformatter.com/json-escape.html#before-output)<https://www.freeformatter.com/json-escape.html#before-output>
{% endhint %}

#### Endpoint

```
/v2/UploadNft
```

#### Body

Define the body for the request fitting for your token upload. Please remove the fields that don't apply for your upload. You have the option of uploading the file as BASE64 Content, URL Link, or IPFS Hash. If you submit Metadata, it will be used instead of the project's Metadatatemplate. You may submit either Metadata or MetadataPlaceholder, but not both.

```json
{
  "tokenname": "string",
  "displayname": "string",
  "description": "string",
  "previewImageNft": {
    "mimetype": "string",
    "fileFromBase64": "string",
    "fileFromsUrl": "string",
    "fileFromIPFS": "string"
  },
  "subfiles": [
    {
      "subfile": {
        "mimetype": "string",
        "fileFromBase64": "string",
        "fileFromsUrl": "string",
        "fileFromIPFS": "string"
      },
      "description": "string",
      "metadataPlaceholder": [
        {
          "name": "string",
          "value": "string"
        }
      ]
    }
  ],
  "metadataPlaceholder": [
    {
      "name": "string",
      "value": "string"
    }
  ],
  "metadataOverride": "string",
  "priceInLovelace": 0
}
```

For this example, we specified the body like that:

```json
{
  "tokenname": "thetoken1",
  "displayname": "The Token 1",
  "description": "This is a test",
  "previewImageNft": {
    "mimetype": "image/png",
    "fileFromIPFS": "QmfA66piVcujJoSmL1fu1beJS2agvadXbzwv4hX4dnzqWY"
  },
  "subfiles": [
    {
      "subfile": {
        "mimetype": "image/png",
        "fileFromIPFS": "QmPep292dYH9CXH9AcMgbcEohXUc3P8ERbAfw7r9HM3AdY"
      }
    }
  ],
  "metadataPlaceholder": [
    {
      "name": "background",
      "value": "green"
    }
  ]
}
```

Instead of giving the metadata via MetadataOverride, we used the metadataPlaceholder method to define custom fields. Please keep in mind that this placeholder method only works, if the custom fields are specified in the [metadata template](/nmkr-studio/project/metadata-template.md).\
\
If you want to use the Metadata Override, [please read here](#using-the-metadata-override-instead-of-the-placeholder).

#### Curl

```json
curl -X 'POST' \
  'https://studio-api.nmkr.io/v2/UploadNft/1420d55a-e194-4aa6-b57d-6d0f0d3b0738' \
  -H 'accept: text/plain' \
  -H 'Authorization: Bearer 1ac2cb0abea146f7bb8a90701dad311c' \
  -H 'Content-Type: application/json' \
  -d '{
  "tokenname": "thetoken1",
  "displayname": "The Token 1",
  "description": "This is a test",
  "previewImageNft": {
    "mimetype": "image/png",
    "fileFromIPFS": "QmfA66piVcujJoSmL1fu1beJS2agvadXbzwv4hX4dnzqWY"
  },
  "subfiles": [
    {
      "subfile": {
        "mimetype": "image/png",
        "fileFromIPFS": "QmPep292dYH9CXH9AcMgbcEohXUc3P8ERbAfw7r9HM3AdY"
      }
    }
  ],
  "metadataPlaceholder": [
    {
      "name": "background",
      "value": "green"
    }
  ]
}'
```

#### &#x20;Response

```json
{
  "nftId": 13174329,
  "nftUid": "8deedfd7-6aa4-45df-be6b-27efa51b8ec3",
  "ipfsHashMainnft": "QmfA66piVcujJoSmL1fu1beJS2agvadXbzwv4hX4dnzqWY",
  "ipfsHashSubfiles": [
    "QmPep292dYH9CXH9AcMgbcEohXUc3P8ERbAfw7r9HM3AdY"
  ],
  "metadata": "{\n  \"721\": {\n    \"63cb7af8c980f0867940e765f36fa53ac948d9af51179742291a553e\": {\n      \"thetoken1\": {\n        \"name\": \"The Token 1\",\n        \"image\": \"ipfs://QmfA66piVcujJoSmL1fu1beJS2agvadXbzwv4hX4dnzqWY\",\n        \"mediaType\": \"image/png\",\n        \"description\": \"This is a test\",\n        \"files\": [\n          {\n            \"name\": \"The Token 1\",\n            \"mediaType\": \"image/png\",\n            \"src\": \"ipfs://QmPep292dYH9CXH9AcMgbcEohXUc3P8ERbAfw7r9HM3AdY\"\n          }\n        ]\n      }\n    },\n    \"version\": \"1.0\"\n  }\n}",
  "assetId": "63cb7af8c980f0867940e765f36fa53ac948d9af51179742291a553e746865746f6b656e31"
}
```

#### Using the Metadata Override instead of the Placeholder

In case you want to submit a complete 721 Metadata JSON, please keep in mint that you have to remove the MetadataPlaceholder fields in the request body and use the Metadata override field.

```json
  "metadataOverride": "string",
```

Continue to send your Curl as you would with the placeholder method, adding the **escaped**  metadata to the field:

```json
  "metadataOverride": "{\r\n  \"721\": {\r\n    \"63cb7af8c980f0867940e765f36fa53ac948d9af51179742291a553e\": {\r\n      \"thetoken1\": {\r\n        \"name\": \"The Token 1\",\r\n        \"image\": \"ipfs:\/\/QmfA66piVcujJoSmL1fu1beJS2agvadXbzwv4hX4dnzqWY\",\r\n        \"mediaType\": \"image\/png\",\r\n        \"background\": \"green\",\r\n        \"description\": \"This is a test\",\r\n        \"files\": [\r\n          {\r\n            \"name\": \"The Token 1\",\r\n            \"mediaType\": \"image\/png\",\r\n            \"src\": \"ipfs:\/\/QmPep292dYH9CXH9AcMgbcEohXUc3P8ERbAfw7r9HM3AdY\"\r\n          }\r\n        ]\r\n      }\r\n    },\r\n    \"version\": \"1.0\"\r\n  }\r\n}",
```


---

# 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.nmkr.io/nmkr-studio-api/api-examples/project/upload-file-and-metadata.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.
