Create 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. Compact Credentials include two types of claims, which are all included on the credential top level:
-
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.
-
Custom claims: These can be any claims the issuer wishes to add to the credential, as long their value is either a boolean, a string or a number.
-
Request
Make the following request to create and sign a new Compact Credential:
POST https://api.sovrin.one/v2/credentials/compact/sign
{
"payload": {
"iss": "did:web:learn.vii.au01.sovrin.one",
"nbf": 1704099600,
"exp": 1767258000,
"name": "Emma Jane Tasma",
"type": "Course Credential",
"code": "HS.278",
"certificationName": "Working at Heights",
"certificationLevel": "Level 4",
"issuerName": "Advanced Safety Training",
},
"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: Example for a custom claim. -
exp: Example for a custom claim. -
name: Enter the name to appear on the credential. -
type: Example for a custom claim. -
code: Example for a custom claim. -
certificationName: Example for a custom claim. -
certificationLevel: Example for a custom claim. -
issuerName: Example for a custom claim. -
revocable: When set to true, the created credential can later be revoked. When set to false, the credential cannot be revoked.
Response
{
"id": "bKcrxojFSuSZvI5qhKInxA",
"decoded": {
"iss": "did:web:learn.vii.au01.sovrin.one",
"nbf": 1704099600,
"type": "Course Credential",
"exp": 1767258000,
"name": "Emma Jane Tasma",
"code": "HS.278",
"certificationName": "Working at Heights",
"certificationLevel": "Level 4",
"issuerName": "Advanced Safety Training",
"status": {
"index": 3,
"url": "https://learn.vii.au01.sovrin.one/core/v2/credentials/compact/revocation-lists/887cd140-e4d7-4518-b70f-305b23778848"
},
"jti": "bKcrxojFSuSZvI5qhKInxA"
},
"encoded": "CSC:/1/2KCE3IQEJB5DCMSMGZITM5QBE2QFSALWVQAXQI3ENFSDU53FMI5GYZLBOJXC45TJNEXGC5JQGEXG2YLUORZC4Z3MN5RGC3AFDJSZE7YQHIAACAACOFBW65LSONSSAQ3SMVSGK3TUNFQWYBA2NFLDPEDENZQW2ZLPIVWW2YJAJJQW4ZJAKRQXG3LBMRRW6ZDFMZEFGLRSG44HCY3FOJ2GSZTJMNQXI2LPNZHGC3LFOJLW64TLNFXGOIDBOQQEQZLJM5UHI43SMNSXE5DJMZUWGYLUNFXW4TDFOZSWYZ2MMV3GK3BAGRVGS43TOVSXETTBNVSXQGCBMR3GC3TDMVSCAU3BMZSXI6JAKRZGC2LONFXGOZTFPBYGS4TZNIZDAMRWFUYDCLJQGE5AAAIAACRAEAYDPB2WQ5DUOBZTULZPNRSWC4TOFZ3GS2JOMF2TAMJONVQXI5DSFZTWY33CMFWC6Y3POJSS65RSF5RXEZLEMVXHI2LBNRZS6Y3PNVYGCY3UF5ZGK5TPMNQXI2LPNYWWY2LTORZS6OBYG5RWIMJUGAWWKNDEG4WTINJRHAWWENZQMYWTGMBVMIZDGNZXHA4DIOAH3BAFA3FHFPDIRRKK4SM3ZDTKQSRCPRCYIA7RFUZYQI3RIGDHIGLAODJ6K2F245DTLIIKXAD35TORFQ7MVRJCIEPH6SC6NGA4HRMK76H5V6GXP66FFNX7MNYC6MYVU7ZLLXYVLXBU"
}
-
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: If revocable was set to true in 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.