Update Bins API

You can Update your JSON bins using the Update Bins API, and you can enable the Version Control as well.

Note that you cannot update the Bin Permissions and Name. In-order to change the Bin Permissions, then check out Change Privacy API for more info.

Root

https://api.jsonbin.io/v3 

Route

/b/<BIN_ID> 

Request Type

PUT

Request Headers

Below are the list of Accepted Request Headers if you are trying to Update a JSON record.

Request Header Value Required
Content-Type application/json Yes
X-Master-Key <API_KEY> Yes
X-Bin-Versioning <true / false> No
Content-Type Required

Set the Content-Type header to application/json. This needs to be passed with every POST request you make on the Create Bins Route. Failing to pass this in the Header will result in an error.

X-Master-Key Required

X-Master-Key is nothing but your Core API Access Key. You will need this Key to access mostly any API end-point on JSONBin. You could find the key on the API Keys page.

X-Bin-Versioning Optionaldefault: false

You can enable Version Control on your Bins by passing the X-Bin-Versioning flag which is set to true. By default, the Version Control on Bin Updates is disabled. You can only save up to 1000 versions of a Bin, post that, it will not create any versions further.

Important You cannot disable version control on Public Bins as it's by design, to prevent the loss of data if someone updates your Public Bin. Though the Owner of the Bin can disable the Version Control if X-Master-Key is passed in the Headers with X-Bin-Versioning set to false.

Code Samples

  • cURL
  • JavaScript (ES6)
  • Python 3
  • Ruby
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 Status Code: 200
{
  "record": {
    "sample": "Hello World"
  },
  "metadata": {
    "parentId": "<BIN_ID>",
    "private": true
  }
}
Error Status Code: 400, 401, 403, 404
{
  "message": "<Error Message>"
}

For more information on the error codes & errors you might possibly encounter, refer to the below section.

Error Reference

  • 400 Bad Request
  • 401 Unauthorized
  • 403 Forbidden
  • 404 Not Found
You need to pass Content-Type set to application/json

You'll encounter this error if you are not passing the Content-Type header. Hence, pass the Content-Type header with a value of application/json.

Invalid Bin Id provided

You'll encounter this error if the Bin Id you are trying to access is invalid. Hence, ensure that the Bin Id you are passing is valid.

Bin cannot be blank

To solve this issue, you need to pass some JSON in the request Body

Schema Doc Validation Mismatch: key:val

You'll encounter this error only when you are trying to Create a record in a specific collection which has a Schema Validation doc attached to it. If your JSON does not match the SchemaDoc, it will result in the above error.

You need to pass X-Master-Key in the header to update a private bin

You'll encounter this error if you are not passing the X-Master-Key header which is required to authenticate your request while creating bins. In-order to fix this, pass the X-Master-Key header with a value of the API Key which you can find on the API Keys page.

Invalid X-Master-Key provided or the bin does not belong to your account

You need to pass the correct X-Master-Key in the Header or the Bin which you are trying to access exists but does not belong to your account.

Free users cannot create a record over 500kb. Upgrade to Pro plan https://jsonbin.io/pricing to create records upto 1mb

You could split your JSON files into multiple smaller files or upgrade your Account to Pro instead.

Requests exhausted. Buy additional requests at https://jsonbin.io/pricing

You'll encounter this error if you've consumed all the available requests. You can purchase additional requests.

Bin not found

Bin which you are trying to Update does not exists.

Create a Free Account

Create an Account View Pricing