Create a Semantic Compact Credential
The Semantic Compact Credential represents the credential claims inside of a W3C Verifiable Credential data model which is then signed as a Compact Credential.
If you need a credential that is more compact at the expense of not using a semantic data model, then look at the tutorial for issuing a Compact Credential.
Prerequisites
-
Access to Sovrin APIs. If you’re experiencing any difficulties, contact us.
-
Issuer DID: This is a did:web that identifies the issuer who attests the claims in the credential are accurate. Refer to create a did:web if you need assistance in creating one. You can only sign Compact Credentials using DIDs with a P-256 key type. Note that Sovrin creates
did:webwith this key type by default. -
Claim values: The claims you wish to include in the credential. This is the information attested by the issuer. Semantic Compact Credentials include two types of claims:
-
Standard claims: These must be in a specific structure and format for the credential to be valid. Refer to the example request below for more information. Standard claims are included in the credential top level.
-
Custom claims: These claims must comply with the W3C Verifiable Credentials Data Model 1.0 and its vocabulary context. Custom claims are included inside a vc object inside the credential.
-
Request
Make the following request to create and sign a Semantic Compact Credential:
POST https://api.sovrin.one/v2/credentials/compact-semantic/sign
{
"payload": {
"iss": "did:web:learn.vii.au01.sovrin.one",
"nbf": 1704099600,
"exp": 1767258000,
"vc": {
"type": "Course Credential",
"credentialSubject": {
"name": "Emma Tasma",
"code": "HS.278",
"certificationName": "Working at Heights",
"certificationLevel": "Level 4",
"issuerName": "Advanced Safety Training",
"expiry": "2026-01-01"
}
}
},
"revocable": true
}
-
iss: Use the DID that identifies the credential's issuer, which attests the claims in the credential. This must be a publicly available and resolvable did:web for the credential to be valid and verifiable. -
nbf: Set the time and date the credential will be valid from ( in Unix Epoch time) .
exp: Set the time and date the credential will expire (in Unix Epoch time).
-
vc: This object includes all custom claims in the credential, which must comply with the W3C Verifiable Credentials Data Model 1.0 and its vocabulary context. -
revocable: When set to true, the created credential can later be revoked. When set to false, the credential cannot be revoked.
Response
{
"id": "urn:uuid:78e19496-8521-424b-8315-35fb1ecaf681",
"decoded": {
"iss": "did:web:learn.vii.au01.sovrin.one",
"nbf": 1704099600,
"vc": {
"@context": [
"https://www.w3.org/2018/credentials/v1"
],
"type": [
"VerifiableCredential",
"Course Credential"
],
"credentialSubject": {
"name": "Emma Tasma",
"code": "HS.278",
"certificationName": "Working at Heights",
"certificationLevel": "Level 4",
"issuerName": "Advanced Safety Training",
"expiry": "2026-01-01"
}
},
"exp": 1767258000,
"status": {
"index": 0,
"url": "https://learn.vii.au01.sovrin.one/core/v2/credentials/compact-semantic/revocation-lists/1fe00d6c-904f-497e-bbe1-a3cfdc0b8368"
},
"jti": "urn:uuid:78e19496-8521-424b-8315-35fb1ecaf681"
},
"encoded": "CSS:/1/2KCE3IQEJB5DCMSMGZITM5QBE2QFSAOZUYAXQI3ENFSDU53FMI5GYZLBOJXC45TJNEXGC5JQGEXG2YLUORZC4Z3MN5RGC3AFDJSZE7YQMJ3GHI3IIBRW63TUMV4HJALYEZUHI5DQOM5C6L3XO53S45ZTFZXXEZZPGIYDCOBPMNZGKZDFNZ2GSYLMOMXXMMLEOR4XAZMCORLGK4TJMZUWCYTMMVBXEZLEMVXHI2LBNRYUG33VOJZWKICDOJSWIZLOORUWC3DRMNZGKZDFNZ2GSYLMKN2WE2TFMN2KMZDOMFWWK2SFNVWWCICUMFZW2YLEMNXWIZLGJBJS4MRXHBYWGZLSORUWM2LDMF2GS33OJZQW2ZLSK5XXE23JNZTSAYLUEBEGK2LHNB2HG4TDMVZHI2LGNFRWC5DJN5XEYZLWMVWGOTDFOZSWYIBUNJUXG43VMVZE4YLNMV4BQQLEOZQW4Y3FMQQFGYLGMV2HSICUOJQWS3TJNZTWMZLYOBUXE6LKGIYDENRNGAYS2MBRAQNGSVRXSA5AAAIAACRAEAADPB7GQ5DUOBZTULZPNRSWC4TOFZ3GS2JOMF2TAMJONVQXI5DSFZTWY33CMFWC6Y3POJSS65RSF5RXEZLEMVXHI2LBNRZS6Y3PNVYGCY3UFVZWK3LBNZ2GSYZPOJSXM33DMF2GS33OFVWGS43UOMXTCZTFGAYGINTDFU4TANDGFU2DSN3FFVRGEZJRFVQTGY3GMRRTAYRYGM3DQB6YIBIHRYMUS2CSCQSLQMKTL6Y6ZL3ICWCAUPGIGEOOWODF77V7ZJPVLGAQC2ZUP7MASXIRTIRRPOIIBKNHKZ4LHROPWBPBCYTKA3GXWIRD736HIJNQENTSFUYIPQ77BG4ZPCTXYIY"
}
-
id: Unique credential identifier. This is required when revoking a credential. -
decoded: This is the decoded version of the credential. It includes all the information from the request above, with the addition of the following elements:-
status: Ifrevocablewas set totruein the request, this object is used to provide the URL and index of the credential revocation status. -
jti: This JWT ID identifies this credential and is identical to the id element. -
encoded: The base32 encoded string representation of the mobile credential. CSC stands for COSE_SIGN Compact profile. You will use this element to convert the credential into a format that can be shared with a holder.
-
What's next?
Now that you have created the credential, you can format it as a QR code, a PDF document, an Apple digital pass or a Google digital pass.