Using the SCHEMA DOCS CREATE API, you can CREATE Schema docs which can be used to validate records if attached to a Collection.
Root
https://api.jsonbin.io/v3
Route
/s
Request Type
POST
Request Headers
Header | Value | Required |
Content-Type | application/json | Yes |
X-Master-Key | <YOUR_SECRET_KEY> | Yes |
X-Schema-Doc-Name | <Sample Schema Doc> | Yes |
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 is required to Create a Schema Doc. You can find your X-Master-Key on the API Keys page after signing-in.
X-Schema-Doc-Name
X-Schema-Doc-Name is required to Name your Schema Doc. You can set a name no more than 32 characters.
Basic Code Samples
curl -v\
-H "Content-Type: application/json" \
-H "X-Schema-Doc-Name: User Validation" \
-H "X-Master-Key: <YOUR_API_KEY>" \
--data '<SCHEMA_VALIDATION_JSON>' \
--request POST \
https://api.jsonbin.io/v3/s
let req = new XMLHttpRequest();
req.onreadystatechange = () => {
if (req.readyState == XMLHttpRequest.DONE) {
console.log(req.responseText);
}
};
req.open("POST", "https://api.jsonbin.io/v3/s", true);
req.setRequestHeader("Content-Type", "application/json");
req.setRequestHeader("X-Schema-Doc-Name", "User Validation");
req.setRequestHeader("X-Master-Key", "<YOUR_API_KEY>");
req.send(<SCHEMA_VALIDATION_JSON>);
import requests
url = 'https://api.jsonbin.io/v3/s'
headers = {
'Content-Type': 'application/json',
'X-Schema-Doc-Name': 'User Validation',
'X-Master-Key': '<YOUR_API_KEY>'
}
data = {<SCHEMA_VALIDATION_JSON>}
req = requests.post(url, json=data, headers=headers)
print(req.text)
require 'net/http'
require 'json'
uri = URI("https://api.jsonbin.io/v3/s")
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['X-Schema-Doc-Name'] = 'User Validation'
req['X-Master-Key'] = '<YOUR_API_KEY>'
req.body = {<SCHEMA_VALIDATION_JSON>}.to_json
http.request(req)
end
puts res.body
Request Response
Success 200
{
"record":{
<SCHEMA_VALIDATION_JSON>
},
"metadata": {
"id":"<SCHEMA_DOC_ID>",
"name": "User Validation",
"createdAt": <DATE/TIME>
}
}
Error 400, 401, 403
{
"message": "<ERROR_MESSAGE>"
}
Status Code | Error Message |
---|---|
400 Bad Request |
You need to pass Content-Type set to application/json |
401 Unauthorized |
You need to pass X-Master-Key in the header |
400 Bad Request |
You need to pass X-Schema-Doc-Name header to set a name for the Schema Doc |
400 Bad Request |
X-Schema-Doc-Name cannot be blank |
400 Bad Request |
Name of the Schema Doc cannot be above 32 characters |
400 Bad Request |
Schema Doc cannot be empty |
401 Unauthorized |
Invalid X-Master-Key provided |
403 Forbidden |
Please upgrade to our Pro plan in-order to create a Schema Validation Doc |
403 Forbidden |
You cannot create more than 10 Schema Validation docs. Please delete a Schema Doc and then try again. |
403 Forbidden |
Requests exhausted. Buy additional requests at https://jsonbin.io/pricing |