Using the CREATE API, you can Create Public and Private bins.

Root
https://api.jsonbin.io/
Route
/b
Request Type
POST
Request Headers
Header Value Required
Content-Type application/json Yes
secret-key <YOUR_SECRET_KEY> Optional
collection-id <YOUR_COLLECTION_ID> Optional
private false Optional
name YOUR_BIN_NAME 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 Create a Public or a Private record. You can find your secret-key on the API Keys page after signing-in.

In-order to Create a Public record via API and listing it on your Dashboard, you need to pass secret-key along with private: false This will list the Public bin you created on your user Dashboard.

collection-id

In-order to add a bin to a specific collection instead of the unsorted category which is the default, you need to pass the collection-id in the header. You can Create a Collection on the Collections page after signing-in. For more info on Creating Collections, please refer to our Create Collections API for more info.

private

By default, if you pass the secret-key in the header, it will Create a Public record. In-order to Create a Public record but also list the record you created on your dashboard, you need to pass
private: false header along with the secret-key header.

name

In-order to set a name for the Bin, you can pass this header with a name for the bin. There are no restrictions to set the name except for the length which is limited to 128 characters.

Important

A bin created without passing a secret-key in the header will be a public bin.

Important

You cannot set a Bin name for Public bins created without secret-key header. Also, Bin names cannot be Updated as of now.

Important

Public bins created without secret-key cannot be deleted.

Note

A bin created passing a secret-key header will be Private by default. In-order to mark the Bin as Public, you need to pass private: false flag.

Basic Code Samples
curl --header "Content-Type: application/json" \
       --request POST \
       --data '{"sample": "Hello World"}' \
       https://api.jsonbin.io/b
let req = new XMLHttpRequest();

req.onreadystatechange = () => {
  if (req.readyState == XMLHttpRequest.DONE) {
    console.log(req.responseText);
  }
};

req.open("POST", "https://api.jsonbin.io/b", true);
req.setRequestHeader("Content-type", "application/json");
req.send('{"Sample": "Hello World"}');
import requests
url = 'https://api.jsonbin.io/b'
headers = {'Content-Type': 'application/json'}
data = {"Sample": "Hello World"}

req = requests.post(url, json=data, headers=headers)
print(req.text)
require 'net/http'
require 'json'

uri = URI("https://api.jsonbin.io/b")
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
  req = Net::HTTP::Post.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
{
  "success":true,
  "data":{
    "Sample":"Hello World"
  },
  "id":"<BIN_ID>"
}
Error
401, 422
{
  "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 Collection ID

Fix: If you are trying to pass collection-id in the header, make sure the ID you are passing is correct.

401 Unauthorized
Invalid secret key provided.

Fix: If you are trying to Create a Private record, ensure that the secret-key you are passing in the header is correct.

422 Unprocessible Entity
Bin Name cannot be longer than 128 characters.

Fix: Do not use more than 128 characters for your bin name.

422 Unprocessible Entity
Bin Name cannot be empty.

Fix: Do not pass the name header empty.