Create AnonCreds Schema

To issue Verifiable Credentials, the issuer will have to first create a Schema and then a Credential Definition.

Create Schema

The request body must contain the schema object, which defines the attributes, name and version of the Schema. This will create a DID-Linked Resource of type anonCredsSchema.

Create a schema on the connected datastore

post

/anoncreds/schema

Body
optionsobject
schemaobject
Responses
curl -L \
  --request POST \
  --url '/anoncreds/schema' \
  --header 'Content-Type: application/json' \
  --data '{"options":{"create_transaction_for_endorser":false,"endorser_connection_id":"3fa85f64-5717-4562-b3fc-2c963f66afa6"},"schema":{"attrNames":["score"],"issuerId":"did:(method):WgWxqztrNooG92RXvxSTWv","name":"Example schema","version":"1.0"}}'
{
  "job_id": "text",
  "registration_metadata": {},
  "schema_metadata": {},
  "schema_state": {
    "schema": {
      "attrNames": [
        "score"
      ],
      "issuerId": "did:(method):WgWxqztrNooG92RXvxSTWv",
      "name": "Example schema",
      "version": "1.0"
    },
    "schema_id": "did:(method):2:schema_name:1.0",
    "state": "finished"
  }
}

Request Body

options (optional)

Optional Key-Value pairs of additional options.

schema (mandatory)

"attrNames": Array of attributes for the schema definition.

"issuerId": Issuer DID, use the did created by the Issuer.

"name": Name of the Schema

"version": Version of the Schema (To update existing Schema, use same name and different version)

Check the new Schema

Retrieve an individual schemas details

get

/anoncreds/schema/{schema_id}

Path parameters
schema_idstringrequired

Schema identifier

Example: did:(method):2:schema_name:1.0
Responses
curl -L \
  --url '/anoncreds/schema/{schema_id}'
{
  "resolution_metadata": {},
  "schema": {
    "attrNames": [
      "score"
    ],
    "issuerId": "did:(method):WgWxqztrNooG92RXvxSTWv",
    "name": "Example schema",
    "version": "1.0"
  },
  "schema_id": "did:(method):2:schema_name:1.0",
  "schema_metadata": {}
}

Last updated

Was this helpful?