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-Access-Key | <ACCESS_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-Access-Key Required
You can now update your private records with X-Access-Key header too. Refer to the FAQs for more information on X-Access-Key. Make sure you've granted Bins Update Access Permission to the Access Key you'll be using. You can create Access Keys on 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 -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>
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
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.