Hash Pin Policy

Endpoint

Description

This endpoint allows the sender to change the pin policy for an individual piece of content.

Changes made via this endpoint only affect the content for the hash passed in. They do not affect a user's account level pin policy.

To read more about pin policies, please check out the Regions and Replications documentation.

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

{
ipfsPinHash: (the hash of the content you with to change the pin policy for),
newPinPolicy: {
regions: [
{
id: (id of a region you want to pin to (see available regions below)),
desiredReplicationCount: (amount of replications you want in that region)
},
{
same region format as above
},
.
.
.
]
}
}

The ids of currently available public regions are:

  • FRA1 - Frankfurt, Germany (max 2 replications)

  • NYC1 - New York City, USA (max 2 replications)

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).

We also pass in the hash to change the pin policy for, as well as the new pin policy.

const axios = require('axios');
‚Äč
export const changeHashPinPolicy = (pinataApiKey, pinataSecretApiKey, ipfsPinHash) => {
const url = `https://api.pinata.cloud/pinning/hashPinPolicy`;
const body = {
ipfsPinHash: ipfsPinHash,
newPinPolicy: {
regions: [
{
id: 'FRA1',
desiredReplicationCount: 2
},
{
id: 'NYC1',
desiredReplicationCount: 2
}
]
}
};
return axios
.put(url, body, {
headers: {
pinata_api_key: pinataApiKey,
pinata_secret_api_key: pinataSecretApiKey
}
})
.then(function (response) {
//handle response here
})
.catch(function (error) {
//handle error here
});
};

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.