Using the Delete Bin Versions API, you can delete all the versions of the Bin. We've also developed a functionality where you can delete all the versions of a given bin, and also retain the latest version by overriding it to the base record.
Root
https://api.jsonbin.io/v3
Route
/b/<BIN_ID>/versions
Request Type
DELETE
Request Headers
Header | Value | Required |
X-Master-Key | <YOUR_API_KEY> | Yes |
X-Preserve-Latest | true/false | No |
X-Master-Key
X-Master-Key needs to be passed in-order to Delete the versions of a Private bin or a Public bin. In-order to get the key, you need to sign-up and navigate to API Keys page.
X-Preserve-Latest
Using X-Preserve-Latest header will copy the Latest record to the Base record before deleting all the versions of a bin, thus, retaining the last updated version.
Basic Code Samples
curl -v\
-H "X-Master-key: <YOUR_API_KEY>" \
--request DELETE
https://api.jsonbin.io/v3/b/<BIN_ID>/versions
let req = new XMLHttpRequest();
req.onreadystatechange = () => {
if (req.readyState == XMLHttpRequest.DONE) {
console.log(req.responseText);
}
};
req.open("DELETE", "https://api.jsonbin.io/v3/b/<BIN_ID>/versions", true);
req.setRequestHeader("X-Master-Key", "<YOUR_API_KEY>");
req.send();
import requests
url = 'https://api.jsonbin.io/v3/b/<BIN_ID>/versions'
headers = {
'X-Master-Key': '<YOUR_API_KEY>'
}
req = requests.delete(url, json=None, headers=headers)
print(req.text)
require 'net/http'
require 'json'
uri = URI("https://api.jsonbin.io/v3/b/<BIN_ID>/versions")
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
req = Net::HTTP::Delete.new(uri)
req['X-Master-Key'] = '<YOUR_API_KEY>'
http.request(req)
end
puts res.body
Request Response
Success 200
{
"metadata": {
"id": "<BIN_ID>",
"versionsDeleted": 0
},
"message": "Versions for the Bin are deleted successfully"
}
Error 400, 401, 403, 404
{
"message": "<ERROR_MESSAGE>"
}
Status Code | Error Message |
---|---|
401 Unauthorized |
You need to pass X-Master-Key in the header |
400 Unauthorized |
Invalid Bin Id provided |
401 Unauthorized |
Invalid X-Master-Key provided |
401 Unauthorized |
Bin not found or it doesn't belong to your account |
403 Forbidden |
Requests exhausted. Buy additional requests at https://jsonbin.io/pricing |