Create Schema

Request

post
/api/v1/Schema
Create a Schema
Parameters
Header
content-type*
Set to application/json
authorization
Set to Bearer {access-token} . The token should be a admin token
Body
name*
string
schema name
schema*
string
json schema
status
DRAFT | PUBLISHED
Responses
200: OK
Success Response of entity Created
Sample Schema Request Payload
{
"name": "{schema-name}",
"schema": "{ \"$schema\": \"http://json-schema.org/draft-07/schema\", \"type\": \"object\", \"properties\": { \"Place\": { \"$ref\": \"#/definitions/Place\" } }, \"required\": [ \"Place\" ], \"title\": \"Place\", \"definitions\": { \"Place\": { \"$id\": \"#/properties/Place\", \"type\": \"object\", \"title\": \"The Place Schema\", \"required\": [ \"name\", \"city\"], \"properties\": { \"name\": { \"type\": \"string\" }, \"city\": { \"type\": \"string\" }}, \"_osConfig\": { \"privateFields\": [ \"name\" ], \"signedFields\": [], \"roles\": [ \"anonymous\" ], \"ownershipAttributes\": [], \"attestationPolicies\": [ { \"name\": \"schemaAttestation\", \"conditions\": \"(ATTESTOR#$.[*]#.contains('board-cbse'))\", \"type\": \"MANUAL\", \"attestorPlugin\": \"did:internal:ClaimPluginActor?entity=board-cbse\", \"attestationProperties\": {} } ], \"credentialTemplate\": { \"@context\": [ \"https://www.w3.org/2018/credentials/v1\", \"{someUrlForTemplate}\" ], \"type\": [ \"VerifiableCredential\", \"{TypeOfCertificate}\" ], \"issuer\": \"{issuerName}\", \"issuanceDate\": \"{issuanceDate}\", \"credentialSubject\": { \"type\": \"Place\", \"name\": \"{name}\"}, \"evidence\": { \"type\": \"{SomeType}\"}}, \"certificateTemplates\": { \"html\": \"{templateUrl}\" } }}}}"
}
Important Fields in Response Body
Field
Type
Description
result.{Schema}.osid
string
The ID of the created schema in the registry, used for retrieval and modification of the entity

Usage

cURL

curl --location --request POST '{registry-url}/api/v1/Schema' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "{schema-name}",
"schema": "{ \"$schema\": \"http://json-schema.org/draft-07/schema\", \"type\": \"object\", \"properties\": { \"Place\": { \"$ref\": \"#/definitions/Place\" } }, \"required\": [ \"Place\" ], \"title\": \"Place\", \"definitions\": { \"Place\": { \"$id\": \"#/properties/Place\", \"type\": \"object\", \"title\": \"The Place Schema\", \"required\": [ \"name\", \"city\"], \"properties\": { \"name\": { \"type\": \"string\" }, \"city\": { \"type\": \"string\" }}, \"_osConfig\": { \"privateFields\": [ \"name\" ], \"signedFields\": [], \"roles\": [ \"anonymous\" ], \"ownershipAttributes\": [], \"attestationPolicies\": [ { \"name\": \"schemaAttestation\", \"conditions\": \"(ATTESTOR#$.[*]#.contains('board-cbse'))\", \"type\": \"MANUAL\", \"attestorPlugin\": \"did:internal:ClaimPluginActor?entity=board-cbse\", \"attestationProperties\": {} } ], \"credentialTemplate\": { \"@context\": [ \"https://www.w3.org/2018/credentials/v1\", \"{someUrlForTemplate}\" ], \"type\": [ \"VerifiableCredential\", \"{TypeOfCertificate}\" ], \"issuer\": \"{issuerName}\", \"issuanceDate\": \"{issuanceDate}\", \"credentialSubject\": { \"type\": \"Place\", \"name\": \"{name}\"}, \"evidence\": { \"type\": \"{SomeType}\"}}, \"certificateTemplates\": { \"html\": \"{templateUrl}\" } }}}}"
}'

HTTPie

printf '{
"name": "{schema-name}",
"schema": "{ \"$schema\": \"http://json-schema.org/draft-07/schema\", \"type\": \"object\", \"properties\": { \"Place\": { \"$ref\": \"#/definitions/Place\" } }, \"required\": [ \"Place\" ], \"title\": \"Place\", \"definitions\": { \"Place\": { \"$id\": \"#/properties/Place\", \"type\": \"object\", \"title\": \"The Place Schema\", \"required\": [ \"name\", \"city\"], \"properties\": { \"name\": { \"type\": \"string\" }, \"city\": { \"type\": \"string\" }}, \"_osConfig\": { \"privateFields\": [ \"name\" ], \"signedFields\": [], \"roles\": [ \"anonymous\" ], \"ownershipAttributes\": [], \"attestationPolicies\": [ { \"name\": \"schemaAttestation\", \"conditions\": \"(ATTESTOR#$.[*]#.contains('board-cbse'))\", \"type\": \"MANUAL\", \"attestorPlugin\": \"did:internal:ClaimPluginActor?entity=board-cbse\", \"attestationProperties\": {} } ], \"credentialTemplate\": { \"@context\": [ \"https://www.w3.org/2018/credentials/v1\", \"{someUrlForTemplate}\" ], \"type\": [ \"VerifiableCredential\", \"{TypeOfCertificate}\" ], \"issuer\": \"{issuerName}\", \"issuanceDate\": \"{issuanceDate}\", \"credentialSubject\": { \"type\": \"Place\", \"name\": \"{name}\"}, \"evidence\": { \"type\": \"{SomeType}\"}}, \"certificateTemplates\": { \"html\": \"{templateUrl}\" } }}}}"
}'| http POST '{registry-url}/api/v1/Schema' \
Authorization:'Bearer {access-token}' \
Content-Type:'application/json'
{registry-url} is usually http://localhost:{port}. The port can be found under the registry section in the docker-compose.yml file and is usually 8081