You can Update Private & Public bins using the Update API.
Root
https://api.jsonbin.io/v3
Route
/b/<BIN_ID>
Request Type
Request Headers
Header | Value | Required |
Content-Type | application/json | Yes |
X-Master-Key | <YOUR_API_KEY> | No |
X-Bin-Versioning | <true / false> | No |
Content-Type
Content-Type needs to be set to application/json. The request will result in an error in-case of a missing Content-Type header.
X-Master-Key
X-Master-Key needs to be passed in-order to Update a Private bin. In-order to get the key, you need to sign-up and navigate to API Keys page.
Note: One can update a Public record without passing an X-Master-Key.
X-Bin-Versioning
You can control the Bin versioning using this header. By default, the versioning is turned off for all the Private bins. If you want to enable the versioning, you need to pass the above header with a value of true.
Note: Bin versioning is enabled for all the Public bins by default. Only the owner of the bin can turn off the Version control by passing the X-Master-Key along with X-Bin-Versioning set to false
Basic Code Samples
curl -v\
-H "Content-Type: application/json" \
-H "X-Master-key: <YOUR_API_KEY>" \
--request PUT \
--data '{"sample": "Hello World"}' \
https://api.jsonbin.io/v3/b/<BIN_ID>
let req = new XMLHttpRequest();
req.onreadystatechange = () => {
if (req.readyState == XMLHttpRequest.DONE) {
console.log(req.responseText);
}
};
req.open("PUT", "https://api.jsonbin.io/v3/b/<BIN_ID>", true);
req.setRequestHeader("Content-Type", "application/json");
req.setRequestHeader("X-Master-Key", "<YOUR_API_KEY>");
req.send('{"sample": "Hello World"}');
import requests
url = 'https://api.jsonbin.io/v3/b/<BIN_ID>'
headers = {
'Content-Type': 'application/json',
'X-Master-Key': '<YOUR_API_KEY>'
}
data = {"sample": "Hello World"}
req = requests.put(url, json=data, headers=headers)
print(req.text)
require 'net/http'
require 'json'
uri = URI("https://api.jsonbin.io/v3/b/<BIN_ID>")
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
req = Net::HTTP::Put.new(uri)
req['Content-Type'] = 'application/json'
req['X-Master-Key'] = '<YOUR_API_KEY>'
req.body = {"sample": "Hello World"}.to_json
http.request(req)
end
puts res.body
Request Response
Success 200
{
"record": {
"sample": "Hello World"
},
"metadata": {
"parentId": "<BIN_ID>",
"private": true
}
}
Error 400, 401, 403, 404
{
"message": "<ERROR_MESSAGE>"
}
Status Code | Error Message |
---|---|
400 Bad Request |
You need to pass Content-Type set to application/json |
400 Bad Request |
Invalid Bin Id provided |
400 Bad Request |
Bin cannot be blank |
404 Not Found |
Bin not found |
401 Unauthorized |
You need to pass X-Master-Key in the header to update a private bin |
401 Unauthorized |
Invalid X-Master-Key provided or the bin does not belong to your account |
403 Forbidden |
Free users cannot update a record over 500kb. Upgrade to Pro plan https://jsonbin.io/pricing to update records upto 1mb |
403 Forbidden |
Requests exhausted. Buy additional requests at https://jsonbin.io/pricing |
403 Forbidden |
Versioning is not available for the Free users. Upgrade to Pro plan https://jsonbin.io/pricing to avail this feature |
400 Bad Request |
Schema Doc Validation Mismatch: key:val |