Add Schema API
You could use Collections to group the bins of a specific kind. Other reasons to use Collections is to validate your JSON records.
A Schema Doc can be attached to the Collection using Add Schema API.
Root
https://api.jsonbin.io/v3
Route
/c/<COLLECTION_ID>/schemadoc/add
Request Type
PUT
Request Headers
Below are the list of Accepted Request Headers if you are trying to Attach a Schema Doc to a Collection.
Request Header | Value | Required |
---|---|---|
X-Master-Key | <API_KEY> | Yes |
X-Schema-Doc-Id | <SCHEMA_ID> | Yes |
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-Schema-Doc-Id Required
You need to pass X-Schema-Doc-Id which you wish to attach to the Collection.
Code Samples
curl -v\
-H "X-Schema-Doc-Id: <SCHEMA_DOC_ID>" \
-H "X-Master-key: <YOUR_API_KEY>" \
--request PUT \
https://api.jsonbin.io/v3/c/<COLLECTION_ID>/schemadoc/add
Request Response
Success Status Code: 200
{
"collectionName": "<COLLECTION_NAME>",
"schemaDocId": "<ATTACHED_SCHEMA_DOC_ID>",
"metadata": {
"id": "<COLLECTION_ID>",
"createdAt": "<DATE/TIME>"
}
}
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
Invalid X-Collection-Id provided
Check if the X-Collection-Id is valid and belongs to your account.
You need to pass X-Schema-Doc-Id in the header
X-Schema-Doc-Id need to be passed to attach it to the Collection.
Invalid Schema Id provided
The Schema Id you've provided is invalid or does not belong to your account.