How to issue a CWT credential (Direct issuance)
CWT credentials represent claims of data that can be cryptographically proven as authentic while being compact enough to fit inside a QR code.
This guide will show you how to create and format a new CWT or Semantic CWT credential.
This guide can be used to create both CWT and Semantic CWT credentials. Any differences in the workflow are highlighted throughout the guide.
Prerequisites
- DIDs:
- 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 a CWT credential using DIDs with a
P-256
key type. MATTR VII createsdid:web
s with this key type (and others) by default.
- Refer to Create a
- Issuer DID: This is a
- Claim values: The claims you wish to include in the credential. This is the information attested by the issuer.
- The identifier of the desired PDF, Apple digital pass or Google digital pass template.
Overview
Direct issuance of a CWT credential comprises the following steps:
Sign the CWT credential
The request to sign the credential is different when youโre signing a CWT or Semantic CWT Credential.
Request
Make a request of the following structure to create and sign a new CWT credential:
POST /v2/credentials/compact/sign
Request body
{
"payload": {
"iss": "did:web:learn.vii.au01.mattr.global",
"nbf": 1704099600,
"exp": 1767258000,
"type": "Course Credential",
"name": "Emma Jane Tasma",
"code": "HS.278",
"certificationName": "Working at Heights",
"certificationLevel": "Level 4",
"issuerName": "Advanced Safety Training",
"expiry": "2026-01-01"
},
"revocable": true,
"isRevoked": false
}
iss
: Use the Issuer DID. This must be a publicly available and resolvabledid:web
for the credential to be valid and verifiable.nbf
: Not before. When set, credential verification will fail if the current time is earlier than the nbf value. Must be expressed as a Unix timestamp.exp
: Expiry. When set, credential verification will fail if the current time is later than the exp value. Must be expressed as a Unix timestamp.type
: Credential type.name
: 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 totrue
, the signed credential can later be revoked. When set tofalse
, the credential cannot be revoked. Defaults tofalse
.isRevoked
: When set totrue
, the signed credential is issued as revoked, and must be unrevoked to become valid. IfisRevoked
is provided (e.g. set to eithertrue
orfalse
),revocable
must be set totrue
. Defaults tofalse
.
Response
{
"id": "bKcrxojFSuSZvI5qhKInxA",
"decoded": {
"iss": "did:web:learn.vii.au01.mattr.global",
"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.mattr.global/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 provided in the request, with the addition of the following elements:status
: Ifrevocable
was set totrue
in the request, this object is used to provide information required for revocation:index
: This indicates the index of this specific credential within the revocation list.url
: References the revocation List which holds the revocation status for this specific credential.
jti
: This JWT ID identifies this credential and is identical to theid
element. Whenrevocable
is set totrue
, this value is persisted on the tenant.
encoded
: The base32 encoded string representation of the CWT credential.CSC
stands forCOSE Sign Compact
profile. You will use this element to convert the credential into a format that can be shared with a holder.
Format the signed CWT credential
Once the CWT credential is signed, you can render it in one of several formats before sharing it.
Format a CWT credential as a QR Code
Request
Make a request of the following structure to format a CWT credential as a QR code:
POST /v2/credentials/compact/qrcode
You can make a similar request to a different endpoint to format a Semantic CWT credential as a QR code:
POST /v2/credentials/compact-semantic/qrcode
Request body
{
"payload": "CSC:/1/2KCE3IQEJB5DCMSMGZITM5QBE2QFSALWVQAXQI3ENFSDU53FMI5GYZLBOJXC45TJNEXGC5JQGEXG2YLUORZC4Z3MN5RGC3AFDJSZE7YQHIAACAACOFBW65LSONSSAQ3SMVSGK3TUNFQWYBA2NFLDPEDENZQW2ZLPIVWW2YJAJJQW4ZJAKRQXG3LBMRRW6ZDFMZEFGLRSG44HCY3FOJ2GSZTJMNQXI2LPNZHGC3LFOJLW64TLNFXGOIDBOQQEQZLJM5UHI43SMNSXE5DJMZUWGYLUNFXW4TDFOZSWYZ2MMV3GK3BAGRVGS43TOVSXETTBNVSXQGCBMR3GC3TDMVSCAU3BMZSXI6JAKRZGC2LONFXGOZTFPBYGS4TZNIZDAMRWFUYDCLJQGE5AAAIAACRAEAYDPB2WQ5DUOBZTULZPNRSWC4TOFZ3GS2JOMF2TAMJONVQXI5DSFZTWY33CMFWC6Y3POJSS65RSF5RXEZLEMVXHI2LBNRZS6Y3PNVYGCY3UF5ZGK5TPMNQXI2LPNYWWY2LTORZS6OBYG5RWIMJUGAWWKNDEG4WTINJRHAWWENZQMYWTGMBVMIZDGNZXHA4DIOAH3BAFA3FHFPDIRRKK4SM3ZDTKQSRCPRCYIA7RFUZYQI3RIGDHIGLAODJ6K2F245DTLIIKXAD35TORFQ7MVRJCIEPH6SC6NGA4HRMK76H5V6GXP66FFNX7MNYC6MYVU7ZLLXYVLXBU",
"width": 800
}
payload
: Use theencoded
element from the response obtained when signing the CWT credential.width
: Optionally specify the desired width of the output QR code. When no width is specified MATTR VII will generate a QR code with an optimised width based on the size of the payload. Maximal value is 1000px.
Response
The response includes a QR code as a PNG file. This QR code contains the encoded credential and can be shared with the intended holder.
Errors
If the provided payload is invalid, the API will return one of the following errors:
400
:- Payload is not a string.
- Payload does not match a CWT credential format.
- The credential has expired.
- Unable to validate or decode the payload.
- Generated QR code is larger than the provided width.
413
:- The payload is too large to be stored in a QR code.
Share the formatted credential
Now that you have the credential rendered in the required format, you can share it with its intended holder.
Share the QR code image using your preferred communication channel (e.g. e-mail, messaging platform, etc.).