Using the UPDATE API, you can Update Public and Private bins.

Root
https://api.jsonbin.io/
Route
/b/<BIN_ID>
Request Type
PUT
Request Headers
Header Value Required
Content-Type application/json Yes
secret-key <YOUR_SECRET_KEY> Optional
versioning false Optional
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.

secret-key

secret-key is an optional header. It is required when you need to Update a Private record. You can find your secret-key on the API Keys page after signing-in.

versioning

versioning is an optional header. You need to pass versioning: false header to disable versioning while you are Updating a record. Note that you can disable versioning on Private records only.

Note

Use versioning: false header to disable versioning if you are going to update the records frequently.

Important

You cannot Disable Versioning on Public Records (even if you've created a record using a secret-key).

More on Versioning header

Updating a newly Created Bin, using versioning: false header will result in updating the base record only. No further versions will be created whatsoever.

Updating a Bin where the versions were created already, in this case, the last version of the bin will get updated. For example, a bin having 7 versions already, and then you start passing the versioning: false header, it will keep on updating the 7th version of the bin.

Basic Code Samples
curl --header "Content-Type: application/json" \
       --request PUT \
       --data '{"sample": "Hello World"}' \
       https://api.jsonbin.io/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/b/<BIN_ID>", true);
req.setRequestHeader("Content-type", "application/json");
req.send('{"Sample": "Hello World"}');
import requests
url = 'https://api.jsonbin.io/b/<BIN_ID>'
headers = {'Content-Type': 'application/json'}
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/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.body = {"Sample": "Hello World"}.to_json
  http.request(req)
end

puts res.body
Request Response
Success
200
Note

Success response will slightly differ if versioning is disabled.

{
  "success":true,
  "data":{
    "Sample":"Hello World"
  },
  "version": 1,
  "parentId":"<BIN_ID>"
}
Error
422, 404, 401
{
  "message": "<ERROR_MESSAGE>",
  "success": false
}
Status Code Error Message
422 Unprocessible Entity
Expected content type - application/json

Fix: You need to pass Content-Type: application/json in the headers.

422 Unprocessible Entity
JSON cannot be empty

Fix: You cannot store an empty JSON record, hence, you need to pass some data to store it.

422 Unprocessible Entity
Invalid Bin ID

Fix: You need to pass a valid Bin ID in-order to Update a bin.

404 Not Found
Bin not found

Fix: Check your Bin ID and pass a Valid Bin ID.

401 Unauthorized
Need to provide a secret-key to UPDATE private bins

Fix: While Updating a Private record, you need to pass secret-key header to update the Private record.

401 Unauthorized
Invalid secret key provided

Fix: Ensure you provide a valid secret-key while Updating a Private record.