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
crossmint:bfb292e7-2700-4924-9213-478f3d71f2d8: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
crossmint:bfb292e7-2700-4924-9213-478f3d71f2d8: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
crossmint:bfb292e7-2700-4924-9213-478f3d71f2d8:Membership
.
Event Participation Certificates
- Purpose: Issued to individuals who attend or participate in specific events.
- Name:
EventParticipation
crossmint:bfb292e7-2700-4924-9213-478f3d71f2d8:EventParticipation
.
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
.
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.
Response
POST /credentials/types/
endpoint to generate a random uuid for the new credential type.
For internal use within Crossmint, reference the type using
id
. The $id
will be included as the credentials
schema by Crossmint but should not be used to reference the type in Crossmint APIs."crossmint:bfb292e7-2700-4924-9213-478f3d71f2d8:CourseCompletionCertificate"
just created.
Example Credential
Types Creation Deep Dive
In the realm of Verifiable Credentials, types are defined using the JSON schema. For more details, refer to the W3C VC JSON Schema. When calling the create type API an invalid JSON schema will result in an error.Type schema structure
Below is an example of a JSON schema structure for defining a credential type:Example Schema Payload
Explanation of Each Part:
- $schema: This should always be set to “https://json-schema.org/draft/2020-12/schema”.
- $id: This field should NOT be defined, will be generated by Crossmint and returned in the response.
- title: Represents the name of the type.
- description: A brief description of the schema.
- type: Must be set to “object”.
- properties: Must include
credentialSubject
as an object.
Important Notes:
- The credential subject is the section that needs to be defined. Any field or nested field can be added, as long as it is valid JSON schema.
- The
credentialSubject.properties.id
will be automatically added with the type “string”, this is used to specify the wallet and therefore the identity of the subject. additionalProperties
should always be set tofalse
to prevent unauthorized fields from being added.- All specified fields should be marked as
required
unless they are optional. This ensures that missing fields will trigger an error during schema validation. additionalProperties
andrequired
apply only at the level they are specified. For nested objects, these need to be repeated.
Type import
If you already have a JSON schema type, you can easily import it by calling the same endpoint with the following structure:importType.js
Response
Important Notes for Import:
- All notes for type creation apply here as well.
credentialSubject.properties.id
will not be added for imported schemas. If the original schema does not include this specification, the resulting credentials will not include the user wallet in thesubject.id
. To know the subject of a credential, checking the NFT owner will be necessary.
To follow along and test the API calls use a tool like Postman or our API
playground.