In the realm of Verifiable Credentials (VC), each credential must be associated with a schema. This schema outlines the fields and their respective types that the credential contains.

The purpose of this schema is to ensure the authenticity of a VC. It acts as a protective measure, preventing any tampering by adding unauthorized fields.

It’s important to note that all credentials within a single collection will share the same schema. This shared schema is referred to as the ‘credential type’.

By adhering to this structure, we can maintain the integrity and verifiability of the credentials, ensuring they serve their purpose effectively.

Create a type

To create a credential type you need to call our API specifying a schema for the credential subject. The subject address field is already present in the base VerifiableCredential type.

{
  "credentialSubjectSchema": [
    // Cannot change this field name, "credentialSubjectSchema"
    { "name": "username", "type": "string" },
    { "name": "courses_completed", "type": "uint64" }
  ]
}

POST https://staging.crossmint.com/api/unstable/credentials/types
The response will be the credential type id.
The possible types for each fiels are:

  • bool
  • uint8
  • uint16
  • uint32
  • uint64
  • uint128
  • uint256
  • address
  • string
  • string[]
  • bytes
  • bytes32
  • CustomObject
  • CustomObject[] (array of CustomObject is supported)

Get a Credential Type

GET https://staging.crossmint.com/api/unstable/credentials/types/{credentialTypeId}

Create complex types

To define a complex object, add the nested object’s schema to the type array.

{
    "credentialSubjectSchema": [
        {
            "name": "username",
            "type": "string"
        },
        {
            "name": "courses_completed",
            "type": "uint64"
        },
        {
            "name": "courses",
            "type": "Course[]"
        }
    ],
    "Course": [
        {
            "name": "name",
            "type": "string"
        },
        {
            "name": "grades",
            "type": "uint64[]"
        },
        {
            "name": "class",
            "type": "Class"
        }
    ],
    "Class": [
        {
            "name": "name",
            "type": "string"
        },
        {
            "name": "teacher",
            "type": "string"
        }
    ]
}

Type Enforcement

All credentials inside a collection must match the schema. Trying to issue or verify a credential with different fields name or type will result in an error