# Generate Metadata

### Overview&#x20;

Metadata is what we refer to as a structure [that conforms to HIP412](https://hips.hedera.com/hip/hip-412), to ensure that it is processable for down-stream clients such as wallets like [Hashpack](https://www.hashpack.app/). Upon successful validation, you will be provided a **CID** as a unique reference to an IPFS pin for minting NFTs.

You should handle the media uploads by default, this is handled through the[ tools provided by filebase](https://filebase.com/), or [using NFTup](https://nft.storage/docs/quickstart/#uploading-files--directories-via-the-nftup-application) for directories.&#x20;

Below is an example of valid metadata, but the validation has been handcrafted in the API to strictly handle many variations of HIP412, based on spec and examples.

If your JSON structure does **not comply with the rules of the aforementioned HIP a status of 422** will be returned with a detailed error response on the issue.

![Basic metadata to generate CID](/files/HM5MG8YxnRNz6uz1yikI)

### Environment Variables

Remember, for complete management of NFT over an API for the creation, minting, metadata generation, and advanced transfer feature you need both the **NFT\_STORAGE\_TOKEN** and **MIRROR\_NODE\_URL** set.

{% content-ref url="/pages/-MFt0JwWQ92EtUIar8y9" %}
[Environment Variables](/deployment/environment-variables.md)
{% endcontent-ref %}

<mark style="color:green;">`POST`</mark> `https://hedera-serverless-consensus.vercel.app/api/nft/metadata`

Generate the metadata based on a valid structure

#### Headers

| Name                                        | Type   | Description                                                       |
| ------------------------------------------- | ------ | ----------------------------------------------------------------- |
| x-api-key<mark style="color:red;">\*</mark> | String | The **API\_SECRET\_KEY** from the client's environment variables. |

#### Request Body

| Name                                 | Type | Description                     |
| ------------------------------------ | ---- | ------------------------------- |
| {}<mark style="color:red;">\*</mark> | json | Compliant HIP412 JSON structure |

{% tabs %}
{% tab title="200: OK Returns a CID" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="401: Unauthorized Header Auth Missing/invalid" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity JSON structure does not comply with HIP412" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}


---

# 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.trust.enterprises/rest-api/nft-ecosystem/generate-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.
