Create a credential

Introduction

This guide will demonstrate how to create a Verifiable Credential using our Platform Core.

Pre-Requisites

You need access to the MATTR Platform APIs. If you're experiencing difficulty, contact us

In order to create a credential, you will need to know the following information:

  • Issuer DID
  • Subject DID
  • Credential Type
  • JSON-LD Claim names as defined by schema.org
  • Claim values

If you wish to use our experimental ZKP feature, the issuer DID must be of "method":"key" and "keyType":"bls12381G2". If you create a Verifiable Credential using that DID as the issuer DID, the platform will automatically detect this capability and issue a ZKP-enabled BBS+ credential for you.

Create a Credential

Create a Credential by providing a payload:

POST https://tenant.platform.mattr.global/v1/credentials

Request

{
"issuer": {
"id": "did:key:z6MkndAHigYrXNpape7jgaC7jHiWwxzB3chuKUGXJg2b5RSj",
"name": "tenant"
},
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://schema.org"
],
"subjectId": "did:key:z6MkfxQU7dy8eKxyHpG267FV23agZQu9zmokd8BprepfHALi",
"type": [
"VerifiableCredential",
"Course"
],
"claims": {
"givenName": "Chris",
"familyName": "Shin",
"educationalCredentialAwarded": "Certificate Name"
}
}

The issuer.id contains the DID of the issuer. The issuer attests the claims in the credential.

The subjectId defines the DID of the subject. The issued credential attests claims about the subject.

type is the Credential Type. It indicates what sort of information a credential holds.

The claims attributes reference the JSON-LD definitions in schema.org:

Response

{
"id": "03bb9930-eb18-11ea-a057-530317397ea3",
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://schema.org"
],
"type": [
"VerifiableCredential",
"Course"
],
"issuer": {
"id": "did:key:z6MkndAHigYrXNpape7jgaC7jHiWwxzB3chuKUGXJg2b5RSj",
"name": "tenant"
},
"issuanceDate": "2020-08-30T23:24:54.876Z",
"credentialSubject": {
"id": "did:key:z6MkfxQU7dy8eKxyHpG267FV23agZQu9zmokd8BprepfHALi",
"givenName": "Chris",
"familyName": "Shin",
"educationalCredentialAwarded": "Certificate Name"
},
"proof": {
"type": "Ed25519Signature2018",
"created": "2020-08-30T23:24:55Z",
"jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..BSHdalZrYml0slwgAXFVF5uAcg2DbPMfwatturKs8TnuxBxylQDnS3JkORORVmO73Ruh7h8KJvVvHO4pE5NsCQ",
"proofPurpose": "assertionMethod",
"verificationMethod": "did:key:z6MkndAHigYrXNpape7jgaC7jHiWwxzB3chuKUGXJg2b5RSj#z6MkndAHigYrXNpape7jgaC7jHiWwxzB3chuKUGXJg2b5RSj"
}
}
}

The credential contains the Verifiable Credential object.