Create a basic JSON-LD Credential
Introduction
This guide will demonstrate how to create a verifiable credential using VII Core.
Prerequisites
You need access to the MATTR VII APIs. If you’re experiencing any difficulties, contact us.
In order to create a credential, you will need 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 see the tutorial on issuing a ZKP-enabled credential.
Create a Credential
Create a credential by making an API request as follows (replacing the issuer and subject IDs in the below example with DIDs from your tenant) :
Request
1POST https://YOUR_TENANT_SUBDOMAIN.vii.mattr.global/core/v1/credentials
1{
2 "issuer": {
3 "id": "did:key:z6MkndAHigYrXNpape7jgaC7jHiWwxzB3chuKUGXJg2b5RSj",
4 "name": "tenant"
5 },
6 "@context": [
7 "https://www.w3.org/2018/credentials/v1",
8 "https://schema.org"
9 ],
10 "subjectId": "did:key:z6MkfxQU7dy8eKxyHpG267FV23agZQu9zmokd8BprepfHALi",
11 "type": [
12 "VerifiableCredential",
13 "CourseCredential"
14 ],
15 "claims": {
16 "givenName": "Chris",
17 "familyName": "Shin",
18 "educationalCredentialAwarded": "Certificate Name"
19 },
20 "persist": false,
21 "revocable": false
22}
The issuer.id
contains the DID of the issuer, this issuer attests the claims in the credential.
The @context
must include the reference to the W3C credential definition "https://www.w3.org/2018/credentials/v1"
and this example will use a common data vocab https://schema.org
which is referenced in the claims
field.
The subjectId
defines the DID of the subject. The issued credential attests claims about the subject.
type
is an array of credential types that must start with VerifiableCredential
. It indicates what sort of information a credential holds.
Response
1{
2 "id": "c6667bb7-9442-49a5-bb0b-fce269e97fc6",
3 "credential": {
4 "@context": [
5 "https://www.w3.org/2018/credentials/v1",
6 {
7 "@vocab": "https://w3id.org/security/undefinedTerm#"
8 },
9 "https://schema.org"
10 ],
11 "type": [
12 "VerifiableCredential",
13 "CourseCredential"
14 ],
15 "issuer": {
16 "id": "did:key:z6MkndAHigYrXNpape7jgaC7jHiWwxzB3chuKUGXJg2b5RSj",
17 "name": "tenant"
18 },
19 "issuanceDate": "2021-07-26T01:05:05.152Z",
20 "credentialSubject": {
21 "id": "did:key:z6MkfxQU7dy8eKxyHpG267FV23agZQu9zmokd8BprepfHALi",
22 "givenName": "Chris",
23 "familyName": "Shin",
24 "educationalCredentialAwarded": "Certificate Name"
25 },
26 "proof": {
27 "type": "Ed25519Signature2018",
28 "created": "2021-07-26T01:05:06Z",
29 "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..o6hnrrWpArG8LQz2Ex_u66_BtuPdp3Hkz18nhNdNhJ7J1k_2lmCCwsNdmo-kNFirZdSIMzqO-V3wEjMDphVEAA",
30 "proofPurpose": "assertionMethod",
31 "verificationMethod": "did:key:z6MkndAHigYrXNpape7jgaC7jHiWwxzB3chuKUGXJg2b5RSj#z6MkndAHigYrXNpape7jgaC7jHiWwxzB3chuKUGXJg2b5RSj"
32 }
33 },
34 "issuanceDate": "2021-07-26T01:05:05.152Z"
35}
The returned credential
object is the credential, with id
and issuanceDate
shown as meta-data.
If you wish to create a credential that supports revocation, please see the Maintain a Revocation List tutorial.
To hold an issued credential in a registry, please see the Use a Credential Registry tutorial.