In the realm of Verifiable Credentials, each credential must be associated with a schema. The credential’s schema is referred to as “type”.

Credential types outline the attributes and their respective data types that the credential contains. The purpose of types is to ensure the credential’s authenticity. Types allow you to specify the attributes you are interested in certifying and act as a protective measure, preventing the addition of unauthorized attributes and, as a result, the tampering of the Verifiable Credential.

It’s important to note that all credentials within a single template will share the same type. Trying to issue or verify a credential with different field names or types will result in an error.

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

Example Types

Credentials play a crucial role in verifying and validating various aspects of identity, achievement, and authorization. Below are some examples of credential types you can create and manage through Crossmint:

Proof of Employment

  • Purpose: Issued to individuals that want to prove their employment.
  • Name: ProofOfEmployment
ProofOfEmployment {
    position: string;
    department: string;
    startDate: string;
}

The payload used to create this type is the following:

{
    "credentialSubjectSchema": [
        {
            "name": "position",
            "type": "string"
        },
        {
            "name": "department",
            "type": "string"
        },
        {
            "name": "startDate",
            "type": "string"
        }
    ]
}

To reference this example type in your credential template definition, use crossmint:5fe6040e-07a1-48bb-97a3-b588a7e927d2:ProofOfEmployment.

Course Completion Certificates

  • Purpose: Issued to students upon the successful completion of a course. The certificate may indicate that the student has mastered a specific skill or knowledge.
  • Type: CourseCompletionCertificate
CourseCompletionCertificate {
    course: string;
    grade: string;
}

If you want to use this example type in your credential template definition, you can reference it as crossmint:5fe6040e-07a1-48bb-97a3-b588a7e927d2:CourseCompletionCertificate.

Membership Credentials

  • Purpose: Provided to individuals who are members of a specific organization or club. The certificate may grant access to exclusive resources and events.
  • Name: Membership
Membership {
  organizationName: string;
  membershipType: string;
  issueDate: string;
  benefits: string[];
  status: string;
}

If you want to use this example type in your credential template definition, you can reference it as crossmint:5fe6040e-07a1-48bb-97a3-b588a7e927d2:Membership.

Event Participation Certificates

  • Purpose: Issued to individuals who attend or participate in specific events.
  • Name: EventParticipation
EventParticipation {
  eventName: string;
  eventDate: string;
  location: string;
  description: string;
}

If you want to use this example type in your credential template definition, you can reference it as crossmint:5fe6040e-07a1-48bb-97a3-b588a7e927d2:EventParticipation.

Complex Types

The possible data types supported for type attributes are:

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

The case that follows creates a hierarchical data model within a credential, showcasing the flexible data representation that is possible. credentialSubjectSchema holds an array of Course objects, while the Class object is referenced in the Course declaration.

{
    "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"
        }
    ]
}

Types Creation Quickstart

This example creates a custom type, CourseCompletionCertificate, for a credential that represents a course completion. The credential will contain two fields: course and passed.

Copy the createType.js file in the tab above, add your API key to the X-API-KEY header (or create one if you haven’t already) and run via node.

node createType.js

The response, shown below, includes the credential type name.

Response
{
    "id": "crossmint:5fe6040e-07a1-48bb-97a3-b588a7e927d2:CourseCompletionCertificate",
    "typeSchema": {
        "CourseCompletionCertificate": [
            {
                "name": "course",
                "type": "string"
            },
            {
                "name": "grade",
                "type": "string"
            }
        ]
    }
}

The type id defined will be used when you create your credential template.

You can also utilize the POST /credentials/types/ endpoint to generate a random uuid for the new credential type.

To follow along and test the API calls use a tool like Postman or our API playground.