In this quickstart you will learn how to create, issue, and verify credentials.

What are credentials?

A digital credential is an electronic record issued by a trusted source that certifies specific information about a person or entity. Crossmint makes it easy to issue, manage, and verify credentials onchain, following the W3C VC standard.

Verifiable Credentials is an Enterprise feature. Contact Sales for access.

Integration steps

1. Create a Developer Account

To get started, create a developer account in the Crossmint Staging Console. Open that link, sign in, and accept the dialog to continue.

Crossmint offers two consoles: staging, for development and testing, and production.

2. Get an API Key

Once you log in to the console, the next step is to create an .

Click the "Integrate" tab and click on the "API Keys" option on top.

Within the “Server-side keys” section, click the “Create new key” button in the top right. Then, check the scopes credentials.create, credentials.read, and credentials:templates.create under the “Verifiable Credentials” category and create your key. Save this key for the next step.

3. Create a Credential Template

Every Verifiable Credential must belong to a template. Verifiable Credentials within a template share the same schema (referred to as “type” in the template definition), default-metadata, encryption, storage, and chain configurations. A credential template is equivalent to an NFT collection.

For the purpose of this quickstart, we will create a template with the following parameters:

  • Type: crossmint:bedea4c5-4cea-425b-99c7-797ecbc8bc13:CourseCompletionCertificate. Types allow you to specify the attributes you are interested in certifying. They also act as a protective measure, preventing the addition of unauthorized fields and, as a result, the tampering of the Verifiable Credential. You can define your own.

  • Encryption: none. This means the Verifiable Credential data will be stored in plain text. To encrypt the data, read about the supported encryption modalities.

  • Storage: crossmint. This means the Verifiable Credential data will be stored by Crossmint. To store the data at the location of your choice, or in decentralized storage, read about the supported storage modalities.

The credential’s revocation state is stored in the chain provided (polygon-amoy), along with public (non-confidential) metadata related to your credential’s template.

createTemplate.js
const apiKey = "YOUR_API_KEY";
const env = "staging"; // or "www"

const url = `https://${env}.crossmint.com/api/v1-alpha1/credentials/templates`;
const options = {
    method: "POST",
    headers: {
        accept: "application/json",
        "content-type": "application/json",
        "x-api-key": apiKey,
    },
    body: JSON.stringify({
        credentials: {
            type: "crossmint:bedea4c5-4cea-425b-99c7-797ecbc8bc13:CourseCompletionCertificate",
            encryption: "none",
            storage: "crossmint",
            subject: {
                properties: {
                    course: {
                        type: "string",
                        title: "Course",
                        description: "Course name",
                    },
                    grade: {
                        type: "string",
                        title: "Grade",
                        description: "Grade received",
                    },
                },
                required: ["course", "grade"],
            },
        },
        metadata: {
            name: "Certificate of Completion",
            description: "A certificate issued upon completion of a course",
            imageUrl: "https://www.crossmint.com/assets/crossmint/logo.png",
        },
        chain: "polygon-amoy",
    }),
};

fetch(url, options)
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch((err) => console.error("error:" + err));

Save the id from the response as your TEMPLATE_ID for the next step.

4. Issue a Credential

With a template created, we can start issuing credentials. To do this, we need to enter the subject’s email address, or wallet address, if they have one.

Then, we need to specify the exact data required by the Verifiable Credential type, i.e. course name and grade. The credential’s contents are identified by the “subject” key within the credential.

If you don’t include an expiration date, the credential will not expire. You can always revoke the credential in the future, if necessary.

issueCredential.js
const apiKey = "YOUR_API_KEY";
const env = "staging"; // or "www"
const templateId = "YOUR_TEMPLATE_ID";
const recipientEmail = "TEST_EMAIL_ADDRESS";

const url = `https://${env}.crossmint.com/api/v1-alpha1/credentials/templates/${templateId}/vcs`;
const options = {
    method: "POST",
    headers: {
        accept: "application/json",
        "content-type": "application/json",
        "x-api-key": apiKey,
    },
    body: JSON.stringify({
        recipient: `email:${recipientEmail}:polygon-amoy`,
        credential: {
            // The CourseCompletionCertificate credential type requires course and grade declarations
            subject: {
                course: "Blockchain 101",
                grade: "A",
            },
            expiresAt: "2034-02-02",
        },
    }),
};

fetch(url, options)
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch((err) => console.error("error:" + err));

Save the credential id from the response for the next step.

5. Retrieve a Credential

​​You can retrieve a Verifiable Credential using different identifiers associated with the credential itself or the NFT associated with the credential.

getCredential.js
const apiKey = "YOUR_API_KEY";
const env = "staging"; // or "www"
const credentialId = "YOUR_CREDENTIAL_ID";

const url = `https://${env}.crossmint.com/api/v1-alpha1/credentials/${credentialId}`;
const options = {
    method: "GET",
    headers: {
        accept: "application/json",
        "x-api-key": apiKey,
    },
};

fetch(url, options)
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch((err) => console.error("error:" + err));

6. Verify a Credential

Verifying a credential can be done in different ways, the easiest one is to call the verify API route. You can also accomplish this with the SDK.

To verify a credential’s validity via API use the following script:

verifyCredential.js
const apiKey = "YOUR_API_KEY";
const env = "staging"; // or "www"
const credentialId = "YOUR_CREDENTIAL_ID";

const url = `https://${env}.crossmint.com/api/v1-alpha1/credentials/verification/verify`;
const options = {
    method: "POST",
    headers: {
        "accept": "application/json",
        "content-type": "application/json",
        "x-api-key": apiKey,
    },
    body: JSON.stringify({
        // paste credential object here
        credential : {
            id: "urn:uuid:e6b3dc76-a337-437b-ac1b-3d330e66e1a6",
            ...
        }
    })
};

fetch(url, options)
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch((err) => console.error("error:" + err));

7. Revoke a Credential (Optional)

To revoke a credential, you can directly use the revoke credential API:

revokeCredential.js
const apiKey = "YOUR_API_KEY";
const env = "staging"; // or "www"
const credentialId = "YOUR_CREDENTIAL_ID";

const url = `https://${env}.crossmint.com/api/v1-alpha1/credentials/${credentialId}`;
const options = {
    method: "DELETE",
    headers: {
        accept: "application/json",
        "x-api-key": apiKey,
    },
};

fetch(url, options)
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch((err) => console.error("error:" + err));

Learn More

For more detailed information about Verifiable Credentials, please visit the dedicated Verifiable Credentials section which includes comprehensive guides on:

In this quickstart you will learn how to create, issue, and verify credentials.

What are credentials?

A digital credential is an electronic record issued by a trusted source that certifies specific information about a person or entity. Crossmint makes it easy to issue, manage, and verify credentials onchain, following the W3C VC standard.

Verifiable Credentials is an Enterprise feature. Contact Sales for access.

Integration steps

1. Create a Developer Account

To get started, create a developer account in the Crossmint Staging Console. Open that link, sign in, and accept the dialog to continue.

Crossmint offers two consoles: staging, for development and testing, and production.

2. Get an API Key

Once you log in to the console, the next step is to create an .

Click the "Integrate" tab and click on the "API Keys" option on top.

Within the “Server-side keys” section, click the “Create new key” button in the top right. Then, check the scopes credentials.create, credentials.read, and credentials:templates.create under the “Verifiable Credentials” category and create your key. Save this key for the next step.

3. Create a Credential Template

Every Verifiable Credential must belong to a template. Verifiable Credentials within a template share the same schema (referred to as “type” in the template definition), default-metadata, encryption, storage, and chain configurations. A credential template is equivalent to an NFT collection.

For the purpose of this quickstart, we will create a template with the following parameters:

  • Type: crossmint:bedea4c5-4cea-425b-99c7-797ecbc8bc13:CourseCompletionCertificate. Types allow you to specify the attributes you are interested in certifying. They also act as a protective measure, preventing the addition of unauthorized fields and, as a result, the tampering of the Verifiable Credential. You can define your own.

  • Encryption: none. This means the Verifiable Credential data will be stored in plain text. To encrypt the data, read about the supported encryption modalities.

  • Storage: crossmint. This means the Verifiable Credential data will be stored by Crossmint. To store the data at the location of your choice, or in decentralized storage, read about the supported storage modalities.

The credential’s revocation state is stored in the chain provided (polygon-amoy), along with public (non-confidential) metadata related to your credential’s template.

createTemplate.js
const apiKey = "YOUR_API_KEY";
const env = "staging"; // or "www"

const url = `https://${env}.crossmint.com/api/v1-alpha1/credentials/templates`;
const options = {
    method: "POST",
    headers: {
        accept: "application/json",
        "content-type": "application/json",
        "x-api-key": apiKey,
    },
    body: JSON.stringify({
        credentials: {
            type: "crossmint:bedea4c5-4cea-425b-99c7-797ecbc8bc13:CourseCompletionCertificate",
            encryption: "none",
            storage: "crossmint",
            subject: {
                properties: {
                    course: {
                        type: "string",
                        title: "Course",
                        description: "Course name",
                    },
                    grade: {
                        type: "string",
                        title: "Grade",
                        description: "Grade received",
                    },
                },
                required: ["course", "grade"],
            },
        },
        metadata: {
            name: "Certificate of Completion",
            description: "A certificate issued upon completion of a course",
            imageUrl: "https://www.crossmint.com/assets/crossmint/logo.png",
        },
        chain: "polygon-amoy",
    }),
};

fetch(url, options)
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch((err) => console.error("error:" + err));

Save the id from the response as your TEMPLATE_ID for the next step.

4. Issue a Credential

With a template created, we can start issuing credentials. To do this, we need to enter the subject’s email address, or wallet address, if they have one.

Then, we need to specify the exact data required by the Verifiable Credential type, i.e. course name and grade. The credential’s contents are identified by the “subject” key within the credential.

If you don’t include an expiration date, the credential will not expire. You can always revoke the credential in the future, if necessary.

issueCredential.js
const apiKey = "YOUR_API_KEY";
const env = "staging"; // or "www"
const templateId = "YOUR_TEMPLATE_ID";
const recipientEmail = "TEST_EMAIL_ADDRESS";

const url = `https://${env}.crossmint.com/api/v1-alpha1/credentials/templates/${templateId}/vcs`;
const options = {
    method: "POST",
    headers: {
        accept: "application/json",
        "content-type": "application/json",
        "x-api-key": apiKey,
    },
    body: JSON.stringify({
        recipient: `email:${recipientEmail}:polygon-amoy`,
        credential: {
            // The CourseCompletionCertificate credential type requires course and grade declarations
            subject: {
                course: "Blockchain 101",
                grade: "A",
            },
            expiresAt: "2034-02-02",
        },
    }),
};

fetch(url, options)
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch((err) => console.error("error:" + err));

Save the credential id from the response for the next step.

5. Retrieve a Credential

​​You can retrieve a Verifiable Credential using different identifiers associated with the credential itself or the NFT associated with the credential.

getCredential.js
const apiKey = "YOUR_API_KEY";
const env = "staging"; // or "www"
const credentialId = "YOUR_CREDENTIAL_ID";

const url = `https://${env}.crossmint.com/api/v1-alpha1/credentials/${credentialId}`;
const options = {
    method: "GET",
    headers: {
        accept: "application/json",
        "x-api-key": apiKey,
    },
};

fetch(url, options)
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch((err) => console.error("error:" + err));

6. Verify a Credential

Verifying a credential can be done in different ways, the easiest one is to call the verify API route. You can also accomplish this with the SDK.

To verify a credential’s validity via API use the following script:

verifyCredential.js
const apiKey = "YOUR_API_KEY";
const env = "staging"; // or "www"
const credentialId = "YOUR_CREDENTIAL_ID";

const url = `https://${env}.crossmint.com/api/v1-alpha1/credentials/verification/verify`;
const options = {
    method: "POST",
    headers: {
        "accept": "application/json",
        "content-type": "application/json",
        "x-api-key": apiKey,
    },
    body: JSON.stringify({
        // paste credential object here
        credential : {
            id: "urn:uuid:e6b3dc76-a337-437b-ac1b-3d330e66e1a6",
            ...
        }
    })
};

fetch(url, options)
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch((err) => console.error("error:" + err));

7. Revoke a Credential (Optional)

To revoke a credential, you can directly use the revoke credential API:

revokeCredential.js
const apiKey = "YOUR_API_KEY";
const env = "staging"; // or "www"
const credentialId = "YOUR_CREDENTIAL_ID";

const url = `https://${env}.crossmint.com/api/v1-alpha1/credentials/${credentialId}`;
const options = {
    method: "DELETE",
    headers: {
        accept: "application/json",
        "x-api-key": apiKey,
    },
};

fetch(url, options)
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch((err) => console.error("error:" + err));

Learn More

For more detailed information about Verifiable Credentials, please visit the dedicated Verifiable Credentials section which includes comprehensive guides on: