Pinata Docs
Search…
Hash Metadata

Endpoint

/pinning/hashMetadata

Description

This endpoint allows the sender to change the name and custom key-values associated with a piece of content stored on Pinata.
Changes made via this endpoint only affect the metadata for the hash passed in.

Type

PUT

Headers

pinata_api_key: (put your personal pinata api key here)
pinata_secret_api_key: (put your personal pinata secret api key here)

OR

Authorization: Bearer (put your pinata JWT here)

Body

1
{
2
ipfsPinHash: (required) - The hash of the content you with to change the pin policy for,
3
name: (optional) - A new name for Pinata to associate with the hash provided,
4
keyvalues: (optional) - The updated keyvalues you want associated with the hash provided
5
}
Copied!

Adding or modifying key-values

To add or modify existing key-values, simply provide them in the following format for the key-values object:
1
keyvalues: {
2
newKey: 'newValue', //this adds a keyvalue pair
3
existingKey: 'newValue' //this modifies the value of an existing key if that key already exists
4
}
Copied!

Removing key-values

To remove a key-value pair, simply provide null as the value for an existing key like so:
1
keyvalues: {
2
existingKeyToRemove: null //this removes a keyvalue pair
3
}
Copied!

Response

If the operation is successful, you will receive back an "OK" REST 200 status.

Postman Example

JavaScript With Axios Example

In the javascript example below, we pass in our API keys from elsewhere (hopefully in a secure way).
1
const axios = require('axios');
2
3
export const changeMetadataForHash = (pinataApiKey, pinataSecretApiKey, hash) => {
4
const url = `https://api.pinata.cloud/pinning/hashMetadata`;
5
const body = {
6
ipfsPinHash: hash,
7
name: 'myNewName',
8
keyvalues: {
9
newKey: 'newValue',
10
existingKey: 'newValue',
11
existingKeyToRemove: null
12
}
13
};
14
return axios
15
.put(url, body, {
16
headers: {
17
pinata_api_key: pinataApiKey,
18
pinata_secret_api_key: pinataSecretApiKey
19
}
20
})
21
.then(function (response) {
22
//handle response here
23
})
24
.catch(function (error) {
25
//handle error here
26
});
27
};
Copied!

We want your feedback!

Have a suggestion? Have a complaint? Confused about something in the documentation? Just want to say hi?
We want to make Pinata the best product available. That involves listening to our users and addressing their needs.
Send us an email at [email protected] and we'll see how we can help.
Last modified 3mo ago